Electronic – arduino – Do I need a diode to protect the ESP32 from a connected relay

arduinoesp32magnetic fluxrelay

My ESP32 is controlling a relay which I switch on for 500ms (controlled through the internet).

Do I need a diode to protect my ESP32 from voltage spikes when the magnetic flux collapses?

I'm using an ESP-WROOM-32, and the relay specs are (taken from here):

Small and light weight.Specifications:- Contact form: SPST normally
open- Coil Resistance: 1050ohms- Nom Volts: 12 – Pickup Voltage: 8.4V
DC- Rated Current: 11.4mA – Allowable Voltage: 160%- Dropout Voltage:
1.2V DC – Carry Current = 500mA.- Power Consumption (W): 0.1 – Contact Rating: 1A- 12 VOLT

I've been using it without any problems for quite a few days, but I'm wondering if there's a chance it could be damaged randomly, or if there's something in the ESP32 pins that protects it from things like this.

Here's a circuit diagram of my setup:

enter image description here

Best Answer

Basically, yes you need to protect any switching device from the inductive kickback.

Yes, the IO pins have internal protection diodes, but they are meant for ESD protection, they are not meant to be used as part of normal operation, that would be considered bad design. On most chips, the amount of injected current would exceed the safe limits.

So the problem is, you should not be driving the relay power directly from the IO pin to begin with, but with a transistor. As per the relay specification, the voltage of the IO pin is not even guaranteed to operate the relay. Even if it seems to work now, it may not be reliable, especially now that the internal ESD protection diode has already had extra burden on it for which it is not designed for.

Related Topic