I'm trying to develop some hardware/software project using ESP32-DevkitC-V4 board using wired ethernet connection. For the wired ethernet connection I'm using USR-ES1 board which is based on the W5500 chip. I have one board with the ESP32 and USR-ES1 boards. I'm using one of the GPIO lines to control a relay that switches a lamp. The switching electronics is on a separate board that uses a separate power supply. Following is the schematic diagram for my project:
Everything is working well until I switch the lamp. When setting the control line to low (zero), the lamp is switched off and together with it the USR-ES1 stops working. This happens almost every time. What can be the casue for it?
More information on the above question: If I'm not connecting the lamp everything is working fine. That is, I'm leaving everything as it is, the relay is switched, but the lamp is not present in the circuit, everything is well.
I also tried to put capacitors on the 3.3V line and it doesn't help.
Is your mains 5V power supply filtered? I think you have mains transients sailing straight through it (this would happen if its a cheap and nasty supply for instance)
You should be using mains protective earth too, a 2-pin power supply is always bad news.
If your 'lamp' is not an old incandescent type, then a snubber circuit across the relay contacts is likely needed.
1k base resistor should be a lower value if you want to switch a relay reliably.
Base current should be 5-10% of collector current for saturated switching (Hfe does not apply here). A typical value is 470 ohm (510 ohm on common relay modules).
Leo..
There were several threads on this forum asking why the relay contacts welded together when using CFL light bulbs. A slow switching relay and not using a snubber circuit could contribute to that.
Leo..
Thanks everyone for the answers. No matter what I did, I couldn't resolve this reliably. The snubber made it a little better, but still not completely stable. Eventually I replaced the relay with a triac and an opto-coupler with zero crossing detection. This totally resolved the issue. As I see it, the reason to why the triac resolves this is because switching is always done by the triac when the cycle is in zero voltage. So no transient is caused. With the relay the switching could be done at any stage of the cycle. Statistically most of the times while the cycle is in high voltage. The reason why sometimes the problem did not occur with the relays is that switching incidentally was done while the cycle was in low voltage (I think). Anyway, I hope that this will help someone.