Sonoff Dual R3 (Lite) input not recognized

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 used this simple example (without the sensor cse7766 that I don’t have in mine);
  • 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 :wink:

Thank you for your answer.
To better understand the connections, here is a diagram:
Sonoff_DUALR3_002

Here is my ESPHome yaml configuration:

substitutions:
  short_device_name: sonoff-dual-r3-lite
  long_device_name: Sonoff DualR3 Lite

esphome:
  name: $short_device_name

esp32:
  board: esp32dev

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  ap:
    ssid: $short_device_name
    password: !secret wifi_ap_password

captive_portal:

logger:

api:

ota:
  password: !secret ota_password

sensor:
  - platform: uptime
    name: "$long_device_name Uptime"
  - platform: wifi_signal
    name: "$long_device_name WiFi Signal"
    update_interval: 60s

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO32
      mode: INPUT_PULLUP
      inverted: true
    name: "$long_device_name Switch 1"
    on_press:
      - switch.turn_on: relay_1
    on_release:
      - switch.turn_off: relay_1

  - platform: gpio
    pin:
      number: GPIO33
      mode: INPUT_PULLUP
      inverted: true
    name: "$long_device_name Switch 2"
    on_press:
      - switch.turn_on: relay_2
    on_release:
      - switch.turn_off: relay_2

switch:
  - platform: gpio
    name: "$long_device_name Relay 1"
    pin: GPIO27
    id: relay_1
    restore_mode: restore_default_off

  - platform: gpio
    name: "$long_device_name Relay 2"
    pin: GPIO14
    id: relay_2
    restore_mode: restore_default_off

status_led:
  pin:
    number: GPIO13
    inverted: true

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 :wink:

This diagram is from Sonoff, here is the link to the original documentation.

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 :wink: 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 put the device into the correct mode, as per the documentation?

Using the code posted above, I don’t have the modes like in the original firmware. But my code should work in the right “mode”.

Sorry, I misread.

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?

Yes, but the serial adapter that I have doesn’t provide enough power to turn on the esp32 (inside the Sonoff).

Yes, I measure the voltage between N and Sx.

I think the Sonoff Dual R3 and Sonoff Dual R3 Lite are the same with only one difference: the Lite one doesn’t have cse7766 sensor.

In this video, at minute 3:44, you can see that the Sonoff Dual R3 (not Lite) also has 230V on the Sx pin.

This afternoon I will check if the L pin is directly connected to the Sx pin (internally).
I checked and luckily there is no direct connection between the L and Sx pins.

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.

Did you check the device was working fine with original Sonoff manufacturer before flashing it with esphome ? (just in case device has a default !).

Thank you all for the support, today I discovered the problem!

I have more than one Sonoff with bad input pins, which is the cause of my issue.
All other Sonoff work perfectly.

1 Like

Hello @dafo90,
Did you found a solution for this problem?
I have the same Issue, i constantly have 230V on Sx pins and external switchas are not working using the same schema than you