When you need a circuit to remember its state without drawing continuous current, you are looking for a latching relay circuit diagram. But "latching" means two entirely different things in electrical design. It either refers to an electromechanical seal-in circuit (using a standard relay and a feedback contact to hold itself energized) or a magnetic latching relay (which uses a permanent magnet and brief current pulses to physically snap the contacts into a new state and stay there, even if power is completely lost).

If your goal is to retain state during a total power failure or minimize battery drain in a solar/off-grid system, the magnetic latching relay is the only correct choice. For this guide, we will design a robust, microcontroller-driven dual-coil magnetic latching circuit, contrast it with the seal-in alternative, and terminate with a concrete component pick for your next build.

The Core Decision: Magnetic Latching vs. Electromechanical Seal-In

Before wiring anything, you must choose the topology. A standard relay wired in a "seal-in" (or self-holding) configuration uses a normally-open (NO) auxiliary contact wired in parallel with the momentary start switch. Once energized, the relay powers its own coil. However, if main power drops, the relay drops out. A magnetic latching relay uses a permanent magnet to hold the armature in place; it only requires a 10ms to 50ms pulse of current to change states.

Criteria Electromechanical Seal-In (Standard Relay) Magnetic Latching Relay (Dual-Coil)
State Retention on Power Loss No. Drops out immediately when VCC is removed. Yes. Permanent magnet holds the last physical state.
Steady-State Power Draw Continuous (typically 30mA - 100mA+ for the coil). Zero. Only draws current during the 20ms switching pulse.
Drive Circuit Complexity Low. One low-side NPN/N-MOSFET switch. Medium. Requires two independent low-side switches (dual-coil) or an H-bridge (single-coil).
Best Use Case Industrial motor starters, saving MCU pins on mains-powered logic. Battery management systems, solar disconnects, UPS bypass routing.
Why Dual-Coil over Single-Coil?
Single-coil latching relays are cheaper and save PCB space, but they require an H-bridge driver to reverse the voltage polarity across the coil to reset the relay. Dual-coil relays have two separate windings (Set and Reset). You simply pulse one coil to set, and the other to reset. For hobbyists and rapid prototyping, dual-coil eliminates the need for complex H-bridge ICs and prevents accidental shoot-through currents.

Topology Deep-Dive: Dual-Coil Magnetic Latching Circuit

We are designing a low-side drive topology for a 5V dual-coil latching relay. This configuration keeps the high-voltage switching isolated from the logic-level control signals and ensures the microcontroller only sources minimal gate current.

Node Labels and Topology Description

  • Node VCC (5V): The main power rail feeding the top of both relay coils.
  • Node SET_COIL & RESET_COIL: The junction between the relay coil and the Drain of the respective MOSFET.
  • Node GATE_SET & GATE_RESET: The microcontroller GPIO pins (e.g., Arduino D8 and D9) routed through 10kΩ pull-down resistors to the MOSFET gates.
  • Node GND: Common ground shared by the microcontroller, the 5V power supply, and the Source pins of both MOSFETs.

Circuit Behavior Table

Understanding the exact logic states is critical. Unlike a standard relay, leaving a GPIO pin HIGH indefinitely on a latching relay coil will overheat and destroy the winding.

MCU SET Pin MCU RESET Pin Relay State Coil Current Flow System Action
LOW LOW Holds Previous State 0 mA Magnet maintains armature position.
HIGH (20ms pulse) LOW SET (NO Closed) ~28 mA through Set Coil Armature snaps to SET; MCU must return pin LOW.
LOW HIGH (20ms pulse) RESET (NC Closed) ~28 mA through Reset Coil Armature snaps to RESET; MCU must return pin LOW.
HIGH HIGH FAULT / CHATTER ~56 mA total Magnetic fields cancel. Relay fails to switch; coils overheat.

Design Walkthrough: Sizing the Drive MOSFETs and Flyback Diodes

Let’s pick real component values based on the Panasonic TQ2-L2-5V dual-coil latching relay. According to the datasheet, the 5V variant has a coil resistance of 178Ω per coil.

1. Calculating Coil Current

Using Ohm’s Law: I = V / R5V / 178Ω = 28.08 mA.
Each coil will draw roughly 28 mA when pulsed. This is well within the limits of small-signal transistors, but we will use MOSFETs for lower voltage drop and zero steady-state gate current.

2. Selecting the Drive Transistor

We need an N-channel MOSFET that fully turns on with a 5V logic signal (Logic-Level Gate). The ON Semiconductor 2N7000 is the bench standard here.

  • Vgs(th) (Gate Threshold Voltage): 2.0V max. A 5V Arduino pin will drive it well into the saturation region.
  • Rds(on) (On-Resistance): ~1.2Ω at Vgs = 5V.
  • Power Dissipation: I² * R = (0.028A)² * 1.2Ω = 0.94 mW. It won't even get warm.
  • Gate Pull-down: Add a 10kΩ resistor from Gate to GND on both MOSFETs. This prevents the relay from accidentally firing during MCU boot-up when GPIO pins are floating high-impedance.

3. Sizing the Flyback Diodes

When the MOSFET turns off, the collapsing magnetic field in the 178Ω coil generates a massive reverse voltage spike (inductive kickback). Without a diode, this spike will punch through the 2N7000's 60V drain-source breakdown limit and destroy the silicon.

  • Diode Pick: 1N4148 switching diode. It handles 300mA peak forward current (more than enough for the 28mA spike) and has a fast reverse recovery time.
  • Placement: Cathode (stripe) to Node VCC, Anode to the MOSFET Drain. Place it physically as close to the relay pins as possible to minimize parasitic trace inductance.

Failure Modes: What Breaks at the Extremes?

A robust circuit design requires anticipating how components fail. Here is the failure-mode contrast for this specific topology.

Critical Safety Note: If you are switching mains voltage (>50V AC) on the relay contacts, ensure proper clearance and creepage distances on your PCB. The TQ2 relay is rated for 2A at 30VDC or 125VAC, but it is not suitable for high-current 240VAC loads. For 15A+ AC loads, use this circuit to drive the coil of a heavy-duty contactor instead.
Failure Event Physical Result Circuit Consequence
Flyback Diode Opens MOSFET Drain spikes to >100V upon turn-off. 2N7000 avalanches and fails short. The associated relay coil remains energized continuously until it melts or the power supply trips.
MOSFET Fails Short (Drain-Source) Coil is permanently connected to GND. Continuous 28mA draw. The relay winding will overheat, degrading the internal permanent magnet and eventually burning out the copper wire insulation.
MCU Pins Driven HIGH Simultaneously Both coils energize in opposing magnetic directions. Net magnetic flux drops to near zero. Relay chatters or fails to move. Total current draw hits 56mA. If held for >1 second, coil thermal limits are exceeded.
Gate Pull-down Resistor Omitted Gate floats during MCU reset/boot sequence. Stray EMI or internal MCU pull-up activation momentarily turns on the MOSFET, causing random, unprompted state changes in the relay.

Step-by-Step Breadboard Testing Sequence

Do not wire the entire circuit and plug in the microcontroller on day one. Follow this isolated verification sequence to protect your MCU.

  1. Bench-Test the Relay Coils: Take two jumper wires connected to a 5V bench supply. Briefly touch them across Coil 1 (pins 1 and 16 on the TQ2). You should hear a distinct click. Verify continuity on the NO contacts with a multimeter. Reverse the polarity to Coil 2 (pins 8 and 9) to verify the reset action.
  2. Wire the Power Stage: Insert the relay, the two 2N7000 MOSFETs, the 1N4148 diodes, and the 10kΩ pull-down resistors onto the breadboard. Wire the VCC and GND rails. Do not connect the MCU yet.
  3. Manual Gate Triggering: Use a jumper wire to manually pull the Gate of the SET MOSFET HIGH to the 5V rail for a split second. The relay should click. Remove the jumper; the relay must stay latched. Repeat for the RESET gate.
  4. Verify Flyback Protection: If you have an oscilloscope, probe the Drain of the MOSFET while triggering it. The voltage should spike to roughly 5.7V (5V + 0.7V diode drop) and clamp. If it spikes to 30V+, your diode is installed backward or is missing.
  5. Integrate the Microcontroller: Power down. Connect Arduino D8 to the SET Gate and D9 to the RESET Gate. Upload a sketch that pulses D8 HIGH for 30ms, waits 2 seconds, pulses D9 HIGH for 30ms, and loops. Verify the relay toggles back and forth reliably.

Decision Tree: Selecting Your Exact Latching Component

Use this decision path to finalize your bill of materials. We evaluate based on system voltage, state-retention requirements, and drive complexity.

System Constraint Condition Recommended Action / Part
Power Loss Behavior State must be maintained if VCC drops to 0V. Proceed to Magnetic Latching Relay. (If state can drop, use a standard 5V relay like the Omron G5V-2).
MCU I/O Availability You have 2 spare GPIO pins available. Proceed to Dual-Coil topology. (If you only have 1 pin, you must use a single-coil relay + H-bridge like the L293D).
System Voltage Logic and Coil power are 5V DC. Select 5V coil variant.
Final Concrete Pick All above conditions met. Panasonic TQ2-L2-5V (DigiKey Part: 255-2844-ND). Rated for 2A/30VDC, 1A/125VAC. Dual-coil, 178Ω, 5VDC.

By standardizing on the Panasonic TQ2-L2-5V driven by 2N7000 MOSFETs, you eliminate the thermal overhead of continuous coil current, guarantee state retention across brownouts, and avoid the PCB routing headaches of single-coil H-bridges. Pulse the gates for 30ms, enforce strict mutual exclusion in your firmware so both pins never go HIGH simultaneously, and your latching circuit will outlast the rest of your system.