Hi, I have a intermittent issue with my ESP32Thingplus disconnecting from my HA/ESPHome API when I trigger an ‘off’ command to a Gravity relay I have connected to it. I know that the device is not rebooting because the relay is physically set to ‘normally closed’ and the YAML on switch on the device is also set to restore off.
switch:
- platform: gpio
pin: GPIO26
# wire on N/C
inverted: true
restore_mode: RESTORE_DEFAULT_OFF
name: "reserve tank switch"
As I said it’s intermittent. The Wi-Fi signal is good.
If it does then you will need some other sort of EMI suppression. An RC snubber across the relay contacts and/or some ferrite cores around the contact cabling. Physical distance between the relay and ESP may also help. It is a complicated subject and there is no simple answer to this.
It took me a great deal of time to stop this happening with my ESPHome irrigation controller. I used ferrite cores on all the valve relay cabling and moved the ESP antenna to an external one located away from the relays and valves.
Tom, it seems like that’s the obvious answer. particularly given it’s intermittent. This is the relay (below) Cant see a flyback diode mentioned. seems really strange it doesn’t have one built in given its for Arduino.
Try cable managing that spaghetti away from the ESP antenna with some cable ties. Keep your high current cabling from the relay away from your signalling cabling too (as much as possible).
Shorten them up as much as possible too. Every single one of those wires is an antenna for sending and receiving EMI.
so after a serious wire haircut and the inclusion of a copper ‘avengers style prison’ for the relay, i can operate the relay without losing connectivity, although i get this curious messages in the log immediately after doing so:
12:51:44][D][pulse_counter:174]: 'tank litres per minute': Retrieved counter: 0.00 pulses/min
[12:51:44][D][sensor:094]: 'tank litres per minute': Sending state 0.00000 L/min with 2 decimals of accuracy
[12:51:47][D][switch:012]: 'tank switch on off' Turning ON.
[12:51:47][D][switch:055]: 'tank switch on off': Sending state ON
[12:52:06][D][esp32.preferences:114]: Saving 1 preferences to flash...
[12:52:06][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[12:52:33][D][sensor:094]: 'tank sensor voltage': Sending state 3.14853 V with 2 decimals of accuracy