So, back to the beginning: I have Sonoff device. PIR switched-live wired into “S1” input. No bulb wired in parallel…
I am very sure of N and L for two reasons: (a) on my desk L & N come directly from an ordinary 3-pin plug that I have inspected wiring of (b) in the ceiling location the wiring is correctly colour coded (L=brown, N=blue in the UK) and in that area of my house various other devices function just fine off the same circuit. And the behaviour of the Sonoff device is identically bad in both locations. If you believe this is inadequate to be 100% sure, please do tell me what I should do to validate further?
Here is the basic state:
a) PIR-on, then Sonoff S1 input detects it as “on”, and if I wire up a bulb to the Sonoff relay output (L out 1) and configure ESPhome appropriately, the relay & bulb turns on.
b) PIR-goes-off, then Sonoff input flickers between “on” and “off” multiple times per second, and similarly triggers its output multiple times/second.
One other data point/measurement:
a) With PIR fully detached from Sonoff, I measure 0V between Live and S1 input. But I measure 240V between Neutral and S1 input.
This last point seems weird to me.
I’d appreciate any advice on how to make progress with this?
AC powered devices rarely care about that.
I renovated a house where L and N had been inverted totally starting from meter for more than twenty years.
You can measure voltage across PE wire and L or use “screwdriver tester” if you want to be sure.
You could disconnect everything else except L and N from Sonoff and measure voltage between N and S1 while using code for basic setup: Sonoff Dual R3 & Lite | devices.esphome.io (input_pullup).
Trying to make sense of things with my limited knowledge of electronics. The PIR relay switched-live output is different to a physical on-off switch in some way I don’t understand.
And the Sonoff SW1 input is not fully isolated either - (given the 240V between SW1 and N, and 0V between SW1 and L).
I’m always keen to improve my learning, but at a bit of a dead end right now… Found this thread which contains a (deduced) schematic for the Sonoff inputs, but again my electronics knowledge is inadequate to deduce what I should do with that info…
If you measure the voltage between N and OUT (without any load) of your PIR when it’s triggered, is the voltage reading rock solid steady 240V?
It’s not isolated anyhow.
The thing that I don’t understand from your testing is that when your code set’s INPUT_PULLUP, S1 shouldn’t be at L potential (240V) since it’s supposed to be triggered by L (240V).
By the way you didn’t confirm you use the yaml for basic setup on the link above.