In my circuit I have a relay that will turn on some light bulbs this is my circuit:

Circuit The switch over the 5V is in fact my Arduino. A HIGH will turn on the relay and a LOW will turn it off.

This is working fine, but because of security measures I need to add a mechanical switch to be able to turn on and off whenever needed. This is the circuit I'm using for this configuration:


This circuit also works fine, the lamp is turned on and off by changing either switches but the Arduino loses track of the status of the lamp. The only thing it knows is if the relay is on or off.

Is there a simple way to tell when the lamp is on?

  • 1
    Maybe you should replace your ON/OFF switch with a three way switch: ON/OFF/AUTO, where AUTO means Arduino-controlled. Commented May 25, 2018 at 20:44
  • @EdgarBonet I’m sorry, how? I’m mixing AC and DC and I’m not seeing how can I do that Commented May 25, 2018 at 20:56
  • Slap a current transformer over the AC line?
    – Majenko
    Commented May 25, 2018 at 21:29
  • Is it enough to add an input to the arduino to override the programming? Or does it really need to be an electrical override? Commented May 25, 2018 at 21:29
  • @ratchetfreak what do you mean by "override the programming"? I just want a safe way to check if the lamp is on. I'm open to any suggestion that will keep the arduino and the switch working together Commented May 25, 2018 at 21:43

2 Answers 2


If you add an optical sensor appropriate for the lamp (UV, IR, visible light?) and add a test line to your code, the Arduino would "know" if the light is on. Your second circuit could remain as presented, while the sensor would provide a status of the light.

If the light failed for an unknown reason, the code for your Arduino would not know the difference between that and a manually opened override switch.

  • This should work. But I’m not inclined to use this solution. I’m placing one Arduino (esp8266) per room. Meaning each board will have at least: 1 temperature sensor, 1 humidity sensor and 1 output for the relay. Adding another component to the board would be a little difficult. I would prefer a logic circuit over this solution. Commented May 25, 2018 at 22:25

I got the terminology wrong in my comment. My suggestion is not to use what is commonly called a “three way switch”, but instead a single pole triple throw switch. This is not available in the schematic editor, so I had to improvise. Imagine that the switch labeled “SP3T” below has three contacts on its left side:


simulate this circuit – Schematic created using CircuitLab

  • The top contact connects to nothing: this is the OFF position
  • the middle contact connects the controlled circuit with the relay: this is the AUTO position where the Arduino is in charge
  • the bottom contact closes the controlled circuit: this is the ON position

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.