I’m new to arduino and I want to build myself smart switch that can be turned of both manualy and via wifi, is there any way to change position of relay based on if another wire is live or not? Im from europe so we have 230V outlets.

Thanks for the answer.

This is "diagram" of my design

  • " change position of relay based on if another wire is live or not?" - What does that mean?
    – chrisl
    Mar 11, 2021 at 19:48
  • If pysical switch is on then the wire passing thru is live, and id like to make decisions in arduino based on that, for example physical switch is on, then arduino switches relay conected to itself off and vice versa
    – krystof18
    Mar 11, 2021 at 20:04
  • It may make more sense with a concrete example of how this thing you're building is can be used.
    – timemage
    Mar 11, 2021 at 20:12
  • Well, i want to use wifi controled smart switch and also be able to use my normal physical switch even if i turned my lights off with smart switch and also to be able to turn on lights with smart switch even when its truned off by physical switch. So my idea was to split live wire into 3 - one to arduino controled relay, one to normal swich and one to smart switch, and id like to be able to check if wire after normal switch and also after smart is still live so i can base some logics and determine if light should be on or off. I hope i made it clearer.
    – krystof18
    Mar 11, 2021 at 20:19
  • If I turn your description into a diagram, it might be clearer. But then, it makes more sense for you to make the diagram and include that in your question along with the description.
    – timemage
    Mar 11, 2021 at 20:36

1 Answer 1


Maybe a wire coil wound around the wire could pick up the frequency. Though I won't write about this, since I don't know much about how you would measure this, and because I think, that you are looking the wrong way.

You want to switch one device with multiple switches (how these switches are operates is not important for now). You can look at how this is normally done in eletrical installations. Here the switches are all connected to your breaker box. And there is one component, that waits for trigger signals from the switches and will switch the target device (the light in this case) accordingly. So in the end there is only one place, where the light is switched: in the breaker box. The switches in the room are only triggers. The current for the light does not flow through them. Also they don't necessarily need to carry mains voltage (triggers could also be low voltage) (though it seems they are in fact just using mains voltage, for which I don't know the reason. Maybe to avoid additional voltage conversion).

So I propose the following solution: The mains wires (230V) are only connected to the light and a (suitable) relay board. The relay board is connected to the Arduino, which can act as a Smart Switch (switching via WiFi, time based or whatever). For manual switching you can connect a switch or button to the Arduino and program the Arduino to read it and control the relay accordingly.

This solution is way easier, than trying to sense the live voltage on the lines, and this will most likely make it more reliable . It comes down to controlling an relay board and reading a button/switch, both things with tons of tutorials on the web

Note: Since mains voltage is always really dangerous, you should be really really caution. Don't use mains voltage, when developing your device. A simple LED with current limiting resistir connected to the power line of the Arduino through the relay is sufficient to check the complete functionality. Only connect mains voltage, if you are really really sure, that you did everything correct

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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