Actuators & Control · Study deck

Relays and Solenoids: Switching Choice and Safety

A relay uses moving contacts to switch a load.

Motor Max is your guide for this deck.

relayssolenoids
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Explain: 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.
  • Explain: V_spike = -(50×10⁻³ H) × (8A / 5×10⁻³ s) = -80V spike: This 80 V value is a hypothetical inductor voltage under the assumed current ramp, not a measured contact voltage.
  • Explain: 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.
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: This 80 V value is a hypothetical inductor voltage under the assumed current ramp, not a measured contact voltage.
  • A 120 V RMS AC supply reaches about 170 V at its peak.
  • Contact erosion and welding risk depend on the specific relay, motor inrush, switching phase, suppression and duty cycle.
  • For high-cycle applications or motor loads, use SSRs despite higher cost.
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)

It gives the stored magnetic energy a local path instead of letting transistor voltage rise sharply.

  • 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.
  • If you assume forced gain of 10, base current is about 80 mA / 10 = 8 mA.
iotclass.org

Major section

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

With a forced gain of 10, 80 mA / 10 = 8 mA of base current, which makes 330 Ω a suitable nearby standard resistor for the shown drive.

  • Contact ratings are a separate problem from coil ratings.
  • Switching technology changes the loss and failure tradeoff.
  • A diode clamp changes the time scale.
iotclass.org

Major section

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

A diode across a DC relay coil protects the transistor.

  • 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.
  • If a contact says 10 A resistive, that does not automatically mean 10 A motor or transformer load.
  • An inductor opposes changes in its current, and its voltage is V = L x (di/dt).
iotclass.org

Major section

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

Relays and solenoids look binary in software, but their current, stored energy, contact stress, and fail-safe state are analog design constraints.

  • 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.
  • 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)

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.

  • 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.
  • For DC loads that need fast PWM, a MOSFET switch is usually the better actuator driver than either relay type.
  • That spike punches through the switching transistor or microcontroller pin unless a clamp gives the current a safer path.
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.
  • It gives the stored magnetic energy a local path instead of letting transistor voltage rise sharply.
  • With a forced gain of 10, 80 mA / 10 = 8 mA of base current, which makes 330 Ω a suitable nearby standard resistor for the shown drive.
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 Welded relay contacts stay closed even when the coil is de-energized.

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. The transistor's steady-current rating and supply have been checked, but failures occur when the coil is switched off and there is no suppression path. What is the mechanism and 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.

Q3A smart plug uses a 12 V DC-coil relay rated to switch 10 A at 120 V AC. It switches a 1,500 W resistive heater (12.5 A) and its contacts later weld closed. Which documented mismatch is the strongest cause?

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 see answers page

iotclass.org

Retrieval practice

Recall check 4 of 5

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

Q4A lock uses one 200 ms, 2 A solenoid pulse per cycle from eight 1.5 V AA cells in series, each rated 2,500 mAh. For pulse-energy arithmetic only, assume all rated capacity is usable and ignore standby draw and voltage sag. About how many cycles are possible in this ideal model?

AAbout 22,500 theoretical pulses using 2,500 mAh and 200 ms at 2 A.
BAbout 1,250 pulses by dividing cell capacity directly by pulse current.
CAbout 10,000 pulses by adding an unprovided battery derating factor.
DAbout zero countable pulses because only standby current controls battery life.
Show answer

Answer: A see answers page

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.

iotclass.org

Retrieval practice

Recall check 5 of 5

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

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 4

Answer key.

  1. B · Welded relay contacts stay closed even when the coil is de-energized.
  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.
iotclass.org

Print reference

Answers 2 of 4

Answer key.

  1. C · For the stated resistive heater, 1,500 W / 120 V = 12.5 A, above the relay's 10 A contact rating. That overload is a documented mismatch and a credible cause of contact damage and welding. Choose a properly rated relay for the actual switching duty and provide independent protection against a heater stuck on.
iotclass.org

Print reference

Answers 3 of 4

Answer key.

  1. A · One pulse uses 2 A × 0.2 s / 3600 = 0.000111 Ah, or about 0.111 mAh. Eight cells in series provide 12 V nominal while retaining 2,500 mAh rated capacity, so the ideal pulse-only count is about 22,500. This is not a practical battery-life prediction; pulse sag, standby draw, temperature, ageing, and reserve capacity need measurement.
  2. 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.
iotclass.org

Print reference

Answers 4 of 4

Answer key.

  1. A · Relays are initialized as output pins starting LOW (value=0) for safety.
iotclass.org