Actuators & Control · Study deck

Relays and Solenoids: Switching Choice and Safety

A relay, SSR, and MOSFET switch the same load in different ways.

Motor Max is your guide for this deck.

relayssolenoids
Motor Max, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Explain: Putting the diode in the contact path or across the wrong terminals can leave the real fault untouched, so trace the current path during both on-time and turn-off before approving the wiring.
  • Explain: V_spike = -(50×10⁻³ H) × (8A / 5×10⁻³ s) = -80V spike: With a 120V AC supply, the instantaneous voltage across the relay contacts can reach 120V + 80V = 200V just as the contacts separate.
  • Explain: The mistake: An IoT smart plug design uses a standard 10A mechanical relay, rated for resistive loads, to switch a vacuum cleaner drawing 8A in normal operation.
iotclass.org

Major section

Relay Arc Erosion in Inductive Loads

The mistake: An IoT smart plug design uses a standard 10A mechanical relay, rated for resistive loads, to switch a vacuum cleaner drawing 8A in normal operation.

  • V_spike = -(50×10⁻³ H) × (8A / 5×10⁻³ s) = -80V spike: With a 120V AC supply, the instantaneous voltage across the relay contacts can reach 120V + 80V = 200V just as the contacts separate.
  • At 200V and 8A, the arc power is 1,600W concentrated in a microscopic contact area, vaporizing metal from the contact surfaces.
  • For the 8A vacuum motor, the relay should be rated for 8A / 0.4 = 20A minimum.
iotclass.org

Major section

For Kids: Meet the Actuator Crew!

"How does that work?" asked the LED. "Max can barely power me, and I only need a tiny bit of electricity!".

  • "That's my magic trick!" said Relay Ray proudly. "Max sends me a teeny-tiny signal -- like whispering in my ear.
  • I'm the finger, and Ray is the switch!".
  • Solenoid Sally pushed forward with a "THUNK!" "And I do the pushing!
iotclass.org

Major section

Deep Dive: Coil Drivers, Contact Stress, and Kickback Paths

The first sizing check is current.

  • The coil resistance is approximately 5 V / 0.08 A = 62.5 ohm, and the coil consumes 5 V x 0.08 A = 0.4 W while energized.
  • An ESP32 GPIO pin is a logic signal, not a coil supply.
  • The stored energy is easy to estimate.

Key terms

Contact ratings
Contact ratings are a separate problem from coil ratings.

Why it matters

A logic MOSFET often wastes less GPIO current, but the same flyback diode is still needed because the coil energy has not disappeared.

NPN transistor relay driver circuit showing a GPIO input, base resistor, relay coil load, flyback diode, transistor switch, and output waveform.
NPN transistor relay driver circuit showing a GPIO input, base resistor, relay coil load, flyback diode, transistor switch, and output waveform.
iotclass.org

Major section

Deep Dive: Coil Drivers, Contact Stress, and Kickback Paths (continued)

If you assume forced gain of 10, base current is about 80 mA / 10 = 8 mA.

  • The safe pattern is GPIO to transistor or logic-level MOSFET, relay coil to its own supply, and a diode across the coil.
  • The GPIO then supplies only base current or gate charge while the actuator supply provides coil power.
  • Contact ratings are a separate problem from coil ratings.
  • A diode clamp changes the time scale.
iotclass.org

Major section

Deep Dive: Coil Drivers, Contact Stress, and Kickback Paths (continued)

Switching technology changes the loss and failure tradeoff.

  • At turn-off, move to the diode loop: stored magnetic energy circulates locally instead of raising the transistor voltage, which connects device sizing to protection placement.
  • The same 5 V, 80 mA coil might switch a 12 V pump at 2 A, a 24 V valve at 0.4 A, or a mains lamp.
  • A diode across a DC relay coil protects the transistor.
iotclass.org

Major section

Deep Dive: Coil Drivers, Contact Stress, and Kickback Paths (continued)

If a contact says 10 A resistive, that does not automatically mean 10 A motor or transformer load.

  • A motor that runs at 4 A may draw 5 x 4 = 20 A for a short startup interval, and an inductive load can arc as the contacts open.
  • For design margin, a 4 A inductive load is often treated as needing a 10 A to 15 A contact class, plus a snubber, MOV, or other suppression matched to the load.
  • For DC loads that need fast PWM, a MOSFET switch is usually the better actuator driver than either relay type.
iotclass.org

Major section

Deep Dive: Coil Drivers, Contact Stress, and Kickback Paths (continued)

A 12 V latch solenoid drawing 1.2 A for 200 ms uses 12 x 1.2 x 0.2 = 2.88 J per actuation.

  • Relays and solenoids look binary in software, but their current, stored energy, contact stress, and fail-safe state are analog design constraints.
  • A triac-output AC SSR may drop about 1.6 V, so at the same 5 A it dissipates 1.6 x 5 = 8 W and needs a thermal path.
  • An RC snubber or MOV across relay contacts protects the contacts when the load itself is inductive.
iotclass.org

Major section

Deep Dive: Coil Drivers, Contact Stress, and Kickback Paths (continued)

Putting the diode in the contact path or across the wrong terminals can leave the real fault untouched, so trace the current path during both on-time and turn-off before approving the wiring.

  • An inductor opposes changes in its current, and its voltage is V = L x (di/dt).
  • When a transistor switches a relay or solenoid coil off, the current tries to stop almost instantly, so di/dt is enormous and the coil generates a large reverse voltage spike.
  • That spike punches through the switching transistor or microcontroller pin unless a clamp gives the current a safer path.
iotclass.org

Major section

Deep Dive: Coil Drivers, Contact Stress, and Kickback Paths (continued)

With the same 5 V, 80 mA coil, coil resistance is about 62.5 ohm.

  • A relay coil with L = 100 mH and I = 80 mA stores 0.5 x 0.1 x 0.08^2 = 0.00032 J, or 0.32 mJ.
  • That energy is small, but if current is forced from 80 mA to zero in 1 microsecond, the ideal inductor voltage is 0.1 x 0.08 / 1e-6 = 8000 V.
  • A logic MOSFET often wastes less GPIO current, but the same flyback diode is still needed because the coil energy has not disappeared.
iotclass.org

Deck summary

Key takeaways

The mistake: An IoT smart plug design uses a standard 10A mechanical relay, rated for resistive loads, to switch a vacuum cleaner drawing 8A in normal operation.

  • "How does that work?" asked the LED. "Max can barely power me, and I only need a tiny bit of electricity!".
  • The first sizing check is current.
  • If you assume forced gain of 10, base current is about 80 mA / 10 = 8 mA.
  • Switching technology changes the loss and failure tradeoff.
iotclass.org

Retrieval practice

Recall check 1 of 5

Motor Max says: answer from memory, then check your reasoning.

Q1A 12V relay coil switches a 120V AC heater. If the relay fails with contacts welded closed, what happens?

AThe heater stops working because welded contacts block current
BThe heater stays on; welded contacts need fail-safe protection
CThe ESP32 resets because isolation transfers load voltage
DThe relay opens itself after a built-in timeout expires
Show answer

Answer: B When relay contacts weld together (due to arcing from inductive loads or overcurrent), they stay permanently closed.

iotclass.org

Retrieval practice

Recall check 2 of 5

Motor Max says: answer from memory, then check your reasoning.

Q2A microcontroller switches a 12 V DC relay coil through a transistor and the transistor keeps failing. What is the mechanism and the correct fix?

ACoil turn-off creates kickback; add a flyback diode across the coil
BThe coil draws too much steady current; use a bigger transistor and no diode.
CThe relay contacts are arcing into the coil; add a zero-cross SSR on the coil side.
DPWM the coil at 20 kHz so it never fully turns off and cannot spike.
Show answer

Answer: A see answers page

iotclass.org

Retrieval practice

Recall check 3 of 5

Motor Max says: answer from memory, then check your reasoning.

Q3An IoT smart plug uses a relay to switch a 1,500W space heater (120V AC, 12.5A). The relay is rated for 10A at 120V AC. After two months of operation, the relay welds shut and cannot turn off the heater. What caused the failure?

AThe relay coil could not hold the contacts closed reliably
BThe AC line frequency made the relay vibrate until failure
CThe 12.5 A heater overloaded the 10 A contact rating
DRelay contacts weld eventually no matter what load is used
Show answer

Answer: C Contact welding occurs when current exceeds the relay's rated capacity.

iotclass.org

Retrieval practice

Recall check 4 of 5

Motor Max says: answer from memory, then check your reasoning.

Q4A smart door lock uses a solenoid to actuate the bolt. The solenoid draws 2A at 12V for 200ms to retract the bolt. With 8 AA batteries (1.5V each, 2500 mAh), approximately how many lock/unlock cycles can the system perform?

AAbout 10,000 practical cycles after pulse-load derating
BAbout 1,250 cycles, using capacity divided by pulse current
CAbout 22,500 cycles with no derating or standby load
DBattery life depends only on standby current, not actuations
Show answer

Answer: A

iotclass.org

Retrieval practice

Recall check 5 of 5

Motor Max says: answer from memory, then check your reasoning.

Q5Place each relay or solenoid responsibility where it lives so you can trace a safe logic command across the coil boundary to the switched load.

AGPIO Command and Safe State
BTransistor Driver
CCoil and Flyback Path
DContacts or Solenoid Load
Show answer

Answer: A Place each relay or solenoid responsibility where it lives so you can trace a safe logic command across the coil boundary to the switched load.

Q6Complete the relay control code with safety features:

Arelay = Pin(16, Pin.OUT, value=0)
Brelay = Pin(16, Pin.IN, value=0)
Crelay = Pin(16, Pin.OUT, value=1)
Drelay = Pin.ADC(16)
Show answer

Answer: A Relays are initialized as output pins starting LOW (value=0) for safety.

iotclass.org

Print reference

Answers 1 of 2

Answer key.

  1. B · When relay contacts weld together (due to arcing from inductive loads or overcurrent), they stay permanently closed.
  2. A · A coil's stored energy produces V = L(di/dt) on turn-off, a large spike that kills drivers; a reverse-biased flyback diode across a DC coil (or an RC snubber/MOV across AC contacts) safely dissipates the collapsing current.
  3. C · Contact welding occurs when current exceeds the relay's rated capacity.
  4. A
iotclass.org

Print reference

Answers 2 of 2

Answer key.

  1. A · Place each relay or solenoid responsibility where it lives so you can trace a safe logic command across the coil boundary to the switched load.
  2. A · Relays are initialized as output pins starting LOW (value=0) for safety.
iotclass.org