Hi, I’m in the middle of a little project and have a question I’m not able to find the answer for.
hopefully someone can help me with this.
I have paired a PIR sensor to a D1 mini, powerd by the internals of an unused usb charger.
the combination of the PIR, D1 mini and power supply are mounted in the wall where the lightswitch would be.
but as I don’t have a relay connected to the D1 mini, I therefore use a Sonoff Mini R4 located in the lampfitting to turn on/off the light.
So the two are not connected together physically, exept that they are fed by the same 230V circuit.
at the moment an automation in HA is connecting the two together and everything is working fine.
problem is when HA is down, the light won’t turn on.
So I would like to have these devices to work independent from HA.
question now is, would it be possible to connect an output pin from the D1 mini directly to an input pin on the Sonoff?
the Sonoff has a feature for connecting a switch to the device, but this input is rated for mains. So sending 3.3 volts the this connector would probably not work as there will be some resistors and stuff to step down the 230V to 3.3V I guess?
So I’m planning on bypassing these components and connecting the output pin from the D1 to the input pin on the Sonoff.
Will this work? is it allowed to use 3.3V from another power source as an input on a different device?
if so, where should I connect the wire to on the Sonoff? does anyone have the schematics for this device?
If you’re sticking with the current setup, you can flash both devices with tasmota and use device group.
Another option is using tasmesh to link both devices.
Setup the mini r4 as broker and d1 mini as the node, then configure rules to toggle the light when motion is detected
Hi, thank you for the reply, I forgot to mention that all my devices are flashed with ESPHome, I don’t use Tasmota.
What I actually want to achieve is when wifi is lost or HA is down, both devices can still work together with use of a wired connection between an output pin from D1 Mini and input pin on the Sonoff.
eventually I took a different approach.
I succeeded in pairing the PIR sensor directly to the Sonoff Mini R4, eliminating the need for the Wemos D1 mini and its power supply in the process.
in case someone is interested, here is a little explanation:
the PIR sensor needs 5 to 12V to operate and has a 3.3V pin out when motion is detected.
there is 5V available on the Sonoff board and an input pin (GPIO27) is accessible on the board to solder a wire to. GPIO27 is used for the S2 connector input and I’m using this pin to connect the pin out from the PIR sensor to.
to take in account; when the sonoff is powered on and there is no connection between S1-S2, the pin GPIO27 is high (3.3V) and the relay (on GPIO26) is ‘off’, only when S2 is connected to S1 will the pin go low (connection to GND) and the relay will go ‘on’.
so in my case where the PIR sensor works ‘inverted’ (in contrast to S2), I had to cut the trace between the GPIO27 solder pad and the S2 circuit to disconnect this pin from the 3.3V comming from the sonoff board, so the 3.3V output from the PIR sensor can be connected to the pin GPIO27.
I ended up using an optocoupler on the S1/S2 connection.
with this approach there is no need to cut the GPIO27 trace.
only 2 wires need to be soldered for the 5V to the PIR sensor, and two wires externally (connected to S1 en S2) to the optocouplers ‘output’ pins. (I used a 817C)
the optocoupler is then turned ON/OFF with use of the 3.3V comming from the PIR sensor (through a 1K resistor).
Caution! on the Sonoff GND is the same as L_IN, so be careful when tinkering with the internals of the Sonoff and the PIR circuit when powered up!
I then changed the yaml file so the Sonoff will still work in combination with the PIR sensor in case the connection to HA is lost.
when HA is connected, I use an automation to control the light because there are other triggers for this light (opening garage doors, etc…)