Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By sheminasalam
#96301 I have a two relays connected to GPIO 4 and GPIO 5 of an ESP12F module running the Tasmota firmware. The ESP12F and the relays use a 1 A Samsung mobile phone charger to get 5 V DC from the same AC supply. The same AC supply is used for relay side input. The 5 V is stepped down to 3.3 V for the ESP12F by an ASM117 module. The device works without any issues with lights, fans, motors etc but When I connect a ceiling fan through a speed regulator to any relay output, the ESP12F restarts when operating the relay. When I check the console, I see restart reason as hardware watchdog which means there is a voltage spike or dip. What could be happening?

It doesn't restart when the speed regulator is not connected. I have tested with directly connecting the fan and also keeping the regulator at full speed. In both these cases, there is no issue with the ESP8266. Only when regulator speed is set to lower than high does the issue pop up. 90% of time, the problem comes when the relay is turned off.

I already have a 1000 uF electrolytic capacitor and 104 ceramic capacitor across the ESP12F 3.3 V and ground. I also have a 1N4007 across the relay coils.

Circuit
Image

PCB layout without circuit
Image

PCB layout with circuit
Image
User avatar
By eriksl
#96337 I think you already did a decent job, but I found that you need to take one extra precaution to prevent the ESP8266 from resetting randomly when RF spikes are present: the RESET and ChipEnable lines should be decoupled from the power supply.

You can do this as follows: for each of them (separately!) connect the pins to +3V3 over a 10k Ohm resistor (don't leave it out or it won't work). Then connect a fast acting capacitor to the respective pins (like a ceramic one), the exact value isn't that important, I usually use 100 nF. This will prevent RF spikes (either via the 3V3 or via induction) to lower either RESET or ChipEnable.

[EDIT] I see you're already using 10k resistors, so you'll only need to add the capacitors.
[EDIT 2] did you check the datasheet of the AMS voltage regulator? Often voltage regulators have specific demands on input and output capacitors to work ringing-free. Often they want both a electrolytic and a ceramic (or tantalic) capacitor on both sides.

PS if you need to use a decent linear voltage regulator (5V -> 3V3) I can recommend the LM3941 which is designed exactly for this and also (which I think is a huge advantage) comes in a standard TO220 package and they're very affordable, probably cheaper than AMS modules.
User avatar
By esp8266_dude
#96351 You have poor PCB layout (no solid ground layer, etc.). This makes every microcontroller very sensitive to EMC issues.
Also You don't have RC snubbers on relay contacts.
So You have to start with adding this snubbers.
For the beggining, maybe 100nF/630V + 33R/2W.