I want to add a third switch to a room with two existing switches. This third switch will be simulated by a 4 relays and a raspberry pi.

enter image description here

enter image description here

Image source: wikipedia, Multiway_switching

So 1 have one relay which connects the LT(left top) wire with the RT(right top) wire.
1 relay which connects LB(left bottom) with RB(right bottom).
1 relay which connects LT with RB.
1 relay which connects LB with RT.

If I receive an internet command to turn on the light, I'll switch the fist two relays from on to off or reverse. And change the last two relays from off to on or reverse.

This way I believe I can switch the light status, but I'll never know if it was on or off before switching the status.

Is their a way to check if current if flowing in a 220v connection and output the result to a raspberry pi?


Because you are talking about a 220V Alternating Current power source, you can use any electronic component that measures induction (changes in electrical field) to make this check. You could fabricate a coil around the wire and size it appropriately to get a 3V3 current in that coil which you can then measure with a GPIO pin (just make sure to put a large resistor in the circuit to prevent frying your pi).

BTW, your idea sounds good on paper but since this is done with software, and since the state of GPIO pins upon startup might not be something you can control, there is the risk that the setup ends up in one of the non-allowed states (i.e. more than 2 relays "on" at the same time) which could lead to short-circuits with damaging results (house fires?). Unless you find a way to physically prevent such a scenario from happening, I would advise AGAINST building this setup.

EDIT: Also, any bug in your program could set the relays to an invalid state and cause an electrical fire .... be very careful.

  • @KevinRutan: Note that I am not suggesting you measure the voltage level itself, just the mere presence of a voltage. – Phil B. Jun 30 '16 at 15:56
  • 1
    Instead of four regular relays, one could use two SPDT or changeover relays, or one DPDT relay, of break-before-make type. That would make forbidden states impossible. – hobbs Jun 30 '16 at 16:20
  • @PhilB. Thank you for your suggestion. Do you think it's really possible to cause an electrical fire? or even short-cirtcuits? If all 4 relays are off, won't the light be just always on? – UnstoppableN Jul 4 '16 at 15:50
  • You should never have a cross path and a straight path active at the same time. That's a short circuit right there. – Phil B. Jul 4 '16 at 16:12

Not without a third party device. The cheapest would be to get a pi-zero plugged into the circuit set to ping the device trying to monitor. But at minimum you will need some other device to at least see that voltage is there.

One option would be to get a transformer that matches the control voltage of a relay. hook the transformer between the switchleg and relay control pins. Then, take the +3 from the Rasberry PI, run it through the Normally Open contacts and return to an unused GPIO. Set that GPIO as an input, and monitor it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.