I’m not sure if it can be an ESPHome issue or I do something wrong.
I bought several Sonoff Dual R3s (Lite) and flashed them with ESPHome. If I use them whit HA I have no problem: I can switch the relays on and off, but if I try to use them via the physical switch they don’t work. They literally do nothing.
Some more information:
I followed the Tasmota documentation to find out the pinout of this device (it’s same as the Sonoff Dual R3 not Lite);
I connected the physical switch exactly as described in the original Sonoff schematic;
I also noticed a really strange thing: with or without physical switch connected to S1/S2, I always find 230V on the input pin (S1/S2)! Not just in one device (initially I thought it was a defect), but all my devices have this strange behavior.
The last point may be the cause of my issue, but I don’t know why I have 230V in an input pin with no connection and especially how to fix it.
Please share your esphome yaml for that device !
220V on GPIO of ESP is normal as there is no isolation between main power and ESP that’s why you have to be careful and never open device when plugged on main power
I know it’s right to have 230V on the L pin and, depending on the state of the relay, also on Lout pin(s). But if the Sx pin (switch input) is disconnected from any switch and/or any kind of source, I don’t expect to find 230V on it…
You can better understand what I mean in this video at minute 3:44.
How does the ESP detect a closed (or open) switch if there are always 230V on the input pin (Sx)? This is the cause of my problem: I always read “button pressed” (even omitting PULLUP from the configuration and even without connecting any switches).
Via the Home Assistant UI the relays work perfectly.
Thanks for the wiring that is wrong basically If I check Sonoff indications ! The switches have to be wirred between S1/S2 and the second Live input from left, L In itself has to be wired on middle contact ! Can you check this way it works properly ?
thanks for code and it looks all good but it won’t work well with buttons wired this way ! For that wiring, you should do a flip of state of relay at each change of state on inputs
My wall switches are not momentary, therefore my code should propagate the behaviour (or state) from the input (Sx) to the output (Loutx).
In my current situation I only have one switch connected to each input (Sx) and not two as seen in the diagram.
oki so it makes it easier Code looks fine and GPIO are the good ones too so it should work ! You don’t have any automations or scripts in HA that would lock relays state ?
What does ESPHome says in logs when you actuate one of the switches ?
No, I don’t have any automation or scripts, my HA is a fresh install. Even if I try to use the Sonoff without HA (I turn off my Wi-Fi) it doesn’t work.
I see many logs, but when I press or release the switch nothing happens in logs. I think this is related to my main issue: Sonoff cannot detect a change on the input pin (Sx) because I always have 230V, even if the switch is open…
Have you tried using the switches while powering the board from 3.3V? Does that put S1/S2 as 3.3V?
How do you measure the voltage on S1/S2 (between S1/S2 and N?)?
Looking at the PCB, S1/S2 should be connected to N, but it’s difficult to say (I can only find PCB photos for the Dual R3, not the Lite, so they may be different anyway). Is there continuity between N and S1/S2, or between L and S1/S2?
Have you measured the voltage difference between the L and the Sx pins while the device is powered up? There could be a small voltage difference (say a few volt), because the device looks to be using a capacitive dropper and therefore there’s no mains isolation at all.