Manual toggle Sonoff Basic R2 by 3 voltage signal?

Hi all, I have just found a Sonoff Basic R2 in my bookshelf and am looking for a better way to use it by integrating it with my sensor.

In particular, I am looking for an easy way to manually toggle the Sonoff using this sensor independently (without needing internet, Wi-Fi, Home Assistant, etc.). This sensor sends 3.3 volts when active and 0 volts when inactive.

What I have tried is using an optocoupler between the sensor and the built-in ‘momentary physical button’ of the Sonoff Basic R2, aiming to simulate the action of pushing that physical button (currently, pushing that button toggles the status of Sonoff)
But then I realized that doing it that way makes the Sonoff accept it as a long-press action instead of a momentary action. I have attach the simple diagram below


I really want to keep the original fw of Sonoff and just need this work standalone without internet, wifi so I’d like to seeking your advise on this before thinking the way to fash ESPHome into Sonoff and uses Automations function

Thanks in anticipation

PLug sensor into ESP32, convert sensor signal into ESPHome automation that closes and opens the pushbutton circuit.

Consider flashing the Sonoff with an alternative firmware such as Tasmota or Esphome, which will enable using the remaining GPIO pins for your sensor, and creating rules/automations based on sensor values to trigger the relay without any external server involvement.

1 Like