I have a problem using ESP8266-01 with a relay. I would like to control a 110 V light using a 5 V relay.

Here is the circuit I made:


  • I am sure that the code is correct, because when the relay's pins are not connected to 110 V, everything works just fine. I know that because I can hear relay's contacts "click".

  • The problem comes when I connect 110 V lines to the relay. It works fine until I get a boot message. In general, a boot(3,6) message, and everything is restarted.

  • I think the problem is that I use GPIO 0 to control the system. I guess some current flows into the GPIO 0 pin and makes the ESP8266-01 go on boot mode (that is why I put D2), but I am not sure.

  • I really want to use GPIO 0 pin because it is smaller than node MCU.

Any ideas?

  • \$\begingroup\$ This Darlington-type connection of two transistors is probably not doing you any favors. To have an answerable question, please document the required state of the desired GPIO0 at boot. It might be that what you actually want is to built an inverter. Eg presumably you want the bootable state of the ESP to be one that has the load off, and then to override that with software to turn it on. Though there is potentially an issue with capacitance if the mode pin is sampled too quickly on re-boot. Are you sure you can't use another pin? \$\endgroup\$ Nov 17, 2020 at 20:28
  • 1
    \$\begingroup\$ Yes, I very much agree with @Paul Ghobril that a snubber at the AC load side should reduce the EMI causing ESP826601 rebooting problem. Three other workarounds you might try are: (1) Use an optocoupler such as EL817C at the input side, to reduce back EMF generated voltage spikes running back to ESP8266, (2) Old version of ESP8266-01/12 used to have instability problems. One workaround is to use a very stable USB serial adapter/cable (CH430 used to be good) with big by pass capacitors (say 47uF, the bigger the better) for the USB serial cable. / to continue, . . . \$\endgroup\$
    – tlfong01
    Nov 17, 2020 at 21:28
  • \$\begingroup\$ (3) New versions of ESP8266-12 modules have built in USB serial circuits, so external unstable USB serial cables are not needed, might also be considered. PS - My ESP8266 knowledge is two years out of date, so there might be better workarounds. Good luck and cheers. \$\endgroup\$
    – tlfong01
    Nov 17, 2020 at 21:29

2 Answers 2


If everything is ok until you apply the AC voltage on the relay contact, it means it is an electromagnetic compatibility problem.

Use a snubber circuit (RC snubber for example) at the contact of the relay to avoid elecromagnetic interference.


Hello guys thank you for your time,

I found a solution that works pretty good. As Paul Ghobril suggested, a RC snubber helped to solve my problem.

Here is the circuit I used,

enter image description here

Hope it is useful for someone.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.