Hi all,
I made a tank sensor with an ESP32, a HC-SR04 ultrasonic sensor and dual relay board to drive a water pump. The idea is to measure when the tank is full and use the relay to drive a 230v water pump to empty the tank.
If I test runinng with a usb cable from the PC (so I can get logs too) everything run smoothly.
When I connect to the mains, once the switch turns off I loose connection to the ESP. Sometime it reboots, sometime it stay freezed and I need to power it down.
I use an old iPhone USB charger (1A) to power the ciruit and I measured it dreins about 0.26A with the two relays on.
Does anyone have any idea why this happens?
For reference, a piece of the yaml regarding the switch:
Hi Kerosm,
I just tested. It seems everything is working properly of there is no load connect ed to the relay.
Phisically I have a wire coming from the socket that powershell the usb charger and I connect live and neutrale to the 2 relays.
I do not expect the Power from the water pump (it is an acquarium pump) to impact the stabilitĂ of the usb charger.
Why should you connect L and N? Feel free to post your circuitâŠ
Anyway, keep your low voltage wires short and far from pump wiring.
Rc-snubber across pump could also help .
If I understand, you switch L(ine) with one relay and N(eutral) with the other relay. Coming from the mains (in USA âpanelâ) N is connected the C(ommon) of one relay and the Normally Open (NO) of that relay is connected to the N of the pump. Similarly, L from mains to C of the other relay, NO of the other relay to L of the pump. Both relays are energized at the same time.
This wiring is not advisable because when the relays are not energized you would have mains voltage between the two Normally Closed (NC) connectors of the relays. A better way would be: the mains wires connected to NO and the wires of the pump connected to respective C relay connector.
Either way, switching the relays are almost certain to generate interference because there is whatâs called bounce in any mechanical switch and that is doubled because the relays donât contact at the same time. This would aggravate the inherent electrical noise of a motor starting.
In the USA we would only have one relay switching the L from the panel, the N going straight to the pump. I would like to believe that you can do that in Europe, too. This could reduce the electrical noise.
I believe the issue in Europe is that we donât have a fixed wire for live.
We can put the plug in either way and that means either live or neutral is switched.
Obviously you can figure it out which is which but if someone carelessly unplugs it and puts it back then you might have a live wire where you donât want.
I believe that is the reason for the double switching.
However⊠am I dreaming there is such a thing as a double relay?
DPDT relay modules are more rare and thereon expensive. I donât see difference in practice if you use common 2-ch relay module triggered from single pin.
Though I donât see need to switch both line and neutral in the first place.
For example european certified smart plug just switches either orâŠ
True. But this could be a (more likely) a DIY solution where connection points might be exposed.
A smart plug is more contained and whatever the user plugs in to it is on them.
But I agree there shouldnât be a difference.
Hi all,
thx for all the comments. Originally I tought to use 2 relays exacly because I do not know where L is. I tried to use one relay only, but I get the same result.
Here is a picture of the whole cirtuit, I understant it is not so neat and clean:
The USB charger is on the left. On the bottom youâll see 2 wago where I get mains, the plug for the USB charger and the wires that gets to the relay.
The led on the left (beside the USB charger) is a 3.3v to 5v converter.
The RJ45 is used to connect the external HC-SR04 ultrasonic sensor.
to find out which wire is neutral and live, you could measure the voltage between the wire and earth. if there is 230V, youâre on the live wire, if thereâs nothing, youâre on neutral.
Could it be that the charger is not good enough?
It seems there is a few more components than just the ESP there.
Do you have another charger to test with? Beefier one perhaps?
According to the image, there is none.
But you can do the same with L and N.
Either itâs positive or negative.
But I believe the issue is not where the live is now. Itâs where the live is next time you unplug and plug it back in.
A 1A charger is a really small device. I would first try a more powerful charger, such as a 2A charger, as it can definitely compensate for voltage fluctuations better. Next, I think OldSurferDudeâs suggestion is a good one: an additional large capacitor (1000 uF or larger) on the relay/ESP power supply to provide more energy for the switching process, and a small capacitor to compensate for interference (220 nF debouncing).
I hope you donât use the ESP board to power the relays (e.g., USB to the ESP32 development board and relay to the boardâs 5V), but instead supply the 5V supply externally to the ESP board and the relay board. If multiple relays are powered by the ESP32 board, the ESP board could quickly become overloaded.