I have several 3 wire 220AC motorized ball valves controlled by Opto Coupler relays. Occasionally when the relays switch, my ESP32 is reset. I have a separate 5V supply powering the boards from the 3v signals from GPIO25,26&27, so I can’t figure out why the microcontroller is being affected, but I read that it is a common issue, and the RC Snubber is the proposed solution.
I can’t figure out if I need 2 snubbers for each relay, which switch the valve open (NO) and closed (NC). I have 220VAC connected to the COM pole on the relay which switches the power to the valve to open it on the NO circuit and close it on the NC circuit. Can I use a single snubber to protect both circuits since only one circuit will be energized at any one time?
Thank you for your advice.
Sometimes a snubber or MOV isn't enough protection from EMI interference. You can add an extra level of isolation by taking advantage of the relay module's opto isolators (at no extra cost). Just remove the jumper and connect your spare 5V supply as shown. IMPORTANT: There's no GND connection from the relay module to the ESP32.
Thank you for these insights. I had already removed the jumper on the relay and used 5v supoly from the (same) PSU. However I was using 3.3v from the ESP and also had ground connected. I am surprised and do not understand why there should not be a ground connected? Should I have a second PSU to power the relays? Of if I remove the ground and supply both sides of the relay with 5v, will that solve my resetting problem?
As an aside I have RF chokes on all AC leads and ferrite beads on the 5v supply leads. Do I need fly back diodes on my circuit?
5V power from the ESP32's USB cable is available at the VIN pin. As you can see from the circuit, we have VIN(5V) --> 1K --> IRLED --> RED LED --> INx (GPIO). The GPIO pin(s) are protected from over-voltage because of the voltage drop of the IRLED (1.1V) and the RED LED (2.0V).
Really, all that's being powered is LEDs ... the GPIO provides the ground path when its switched low (relay activated). A ground connection would disable opto-isolation and provide a path for interference.
You need a 5V power supply connected to the relay module where this PSU isn't connected in any way to the ESP32 VIN or GND pins. It needs to be isolated from the USB power.
Flyback diodes are already included on the relay module (D1 and D2).
Whether you actually need a separate power supply just for the relays is not the point. they draw about 70 mA each so 140 mA for two relays.
Actually, it is usually a green LED - which is about 2 V.
You have saved me explaining - as I usually have to - why it connects to 5 V and not 3.3 V.
Right, getting back to that first diagram, the important point is that even if it is the same 5 V power supply, the 5 V and ground connections travel back as a pair using ribbon or "figure eight" wire to the output terminals of the "separate" supply.
Similarly, the 5 V and ground for the ESP connect back as a pair to the output terminals of the supply itself. This is how the wiring needs to be arranged to avoid interference between the two parts of the system.
The "IN" pin connections travel back as a bundle using ribbon wire to the I/O pins of the ESP, again together with the 5 V connection which is the return for those controls. You always need a return, but it is not always ground - as in this case.
Even though you've had the relays operating using 3.3V, this would be using them almost at the threshold of failure. The relay driver would be so weakly driven that this increases the turn-on time and contact bounce-time. The force on the contacts would be reduced, more arcing, EMI, contact wear, reduced life span, reduced reliability, etc.
Even though any one of the suggestions in this thread could seem to resolve the problem, it's best to implement everything you can as this will boost the durability and reliability of your project.
There's probably more that could be done, but we have no picture or diagram of your setup.
Yep, the whole idea is to pick one with a voltage just above your mains power voltage.
A small one (max current) would be ok to protect a ball valve.
Leo..