Electronic – ESP8266 Relay with 2N2222 transistors

esp8266gpiorelay

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:

schematic

  • 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?

Best Answer

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.