5 V SPDT Relay
The relay part models a 5 V single-pole double-throw (SPDT) electromechanical relay. A coil magnetically actuates a contact arm that switches the COM terminal between NO (normally-open) and NC (normally-closed). The coil and the contacts are completely isolated, so a low-power microcontroller pin can switch a high-voltage or high-current load it could never touch directly.
Pinout
| Pin | Label | Description |
|---|---|---|
| coil_a | Coil A | Coil terminal |
| coil_b | Coil B | Coil terminal |
| com | COM | Contact arm (common) |
| no | NO | Normally-open contact |
| nc | NC | Normally-closed contact |
Coil polarity does not matter — the relay responds to the magnitude of the coil voltage, so coil_a and coil_b are interchangeable. The COM/NO/NC contacts are electrically isolated from the coil.
Default coil parameters
| Param | Value | Meaning |
|---|---|---|
| coilR | 70 Ω | Coil DC resistance |
| coilL | 0.05 H | Coil inductance |
| vPull | 3.5 V | Pull-in threshold |
| vDrop | 1.5 V | Drop-out threshold |
These can be overridden via the Inspector properties panel. With 5 V across a 70 Ω coil the coil draws roughly 71 mA. The recommended supply range is 3.0–12.0 V (5.0 V nominal).
Coil vs contacts
The relay is two separate circuits in one package:
- Coil side (
coil_a,coil_b) — the control input. Energising the coil creates the magnetic field that throws the contact arm. - Contact side (
com,no,nc) — the switched output. This is galvanically isolated from the coil, which is the whole point of a relay: your 5 V logic never shares a connection with the load it is switching.
Pull-in and drop-out
Contact switching uses hysteresis on the coil voltage:
- Pull-in: when
|V_coil| ≥ vPull(default 3.5 V) the relay energises and COM connects to NO. - Drop-out: when
|V_coil| < vDrop(default 1.5 V) the relay de-energises and COM falls back to NC.
The gap between the two thresholds keeps the contact from chattering near the switching point.
| State | COM connects to |
|---|---|
| Energised (coil on) | NO |
| De-energised (coil off) | NC |
Coil model and the flyback diode
The coil is modelled as a series resistor-inductor (R + L). Because an inductor resists sudden changes in current, switching the coil off produces a large reverse voltage spike — the inductive kick — that can destroy the transistor or pin driving it.
Always add a flyback diode anti-parallel across the coil (cathode to the positive coil terminal). A common choice is a 1N4001. It clamps the spike by giving the collapsing coil current a path to circulate.
de:volt raises a missing-flyback diagnostic if you drive the coil without one, so wire the diode in from the start.
Driving the coil
A microcontroller pin cannot source the ~71 mA the coil needs, so switch it with a transistor:
- NPN collector to
coil_a - NPN emitter to GND
coil_bto +5 V- Base to the microcontroller pin through a resistor
- Flyback diode anti-parallel across the coil
Contact ratings
The contacts are rated for substantial loads — typically 10 A / 250 VAC or 10 A / 30 VDC for this class of relay — which is why a relay is the standard way to switch mains lamps, motors, and other loads from logic-level signals.
Example circuit
Arduino D7 ─── 1 kΩ ─── B [NPN] C ─── coil_a ─┐
E │ ╪ 1N4001 (flyback)
GND coil_b ──┴─── +5 V
Load switching: +V_load ─── COM NO ─── Load ─── GNDEnergise the coil and COM swings from NC to NO, powering the load. Drop the coil and the flyback diode absorbs the kick while COM returns to NC.