Hi! Great job with ask an educator, just love it!
My question is, I want to read if a lamp in a 24 V alternating current circuit is on or off. I want to use an arduino, but I guess I have to do some kind of signal conditioning, any tips for breadbord testing?
Thank you! I am glad you like the posts!
Now, regarding the question. I have three methods you can employ to sense if your lamp is on or off, and each vary on how much hardware hacking you are looking to do. The first utilizes an opto-isolator to sense the presence of your AC voltage and convert it into a logic level (0 or 1) output that can be easily sensed by your Arduino. This is the most stable and easier to conceal method of the two. The second utilizes a relay, which activates when the lamp is turned on and is connected to the Arduino as you would a pushbutton. The third doesn’t actually interface with the lamp’s circuitry at all, rather relies on one of the Arduino’s ADCs and a photocell to sense a dramatic change in light intensity, indicating the lamp being turned on or off.
Sensing AC with an opto-isolator:
An opto-isolator or optocoupler is a electronic device that uses an LED and a phototransistor to electrically isolate two parts of a circuit. This comes in handy when interfacing microcontrollers with devices that produce a lot of electrical noise, or voltages that could be harmful. Digikey carries the HCPL-3700 which is, although a bit pricey, immediately capable of converting the presence of 5 – 240V AC/DC to a logic level output. In order to make a safe and stable circuit, I would recommend using series resistors for current protection on both the input and output as well as including the recommended 0.1uF filter. You can also complete the circuit using a cheaper isolator like the 4N25 and a few support components as the input is directly connected to the LED.
For more information, there is a nice overview and series of examples on W9XT’s HAM website.
There was a similar question to this on the Adafruit forums that might be of use as well.
Sensing AC with a relay:
A relay is an electro-mechanical device that physically switches its outputs based on the energized state of an electromagnetic coil. Relays typically have common(C), normally-closed (NC) and normally-open (NO) pins that refer to the state of connection relative to the state of the coil. If the relay is not powered, and your light is off, there will be an electrical connection between the C and NC pins. When the relay is powered, and your light is on, the electrical connection switches, connecting the C to the NO pin. These pins can then be connected to the Arduino in the same way you would connect a button. All you need to do is connect a pull-down resistor and an input to the C pin and connect the NO pin to VCC. When the power is supplied to the lamp, it will energize the relay’s coil and connect the NO pin to the C pin, thus changing the logic state from 0 to 1.
Sensing light with a photocell:
A photocell is a device that changes resistance in correlation to the quantity of light it is exposed to. As you are sensing the light from you lamp, I would recommend one used to sense frequencies in the visible light spectrum…..like these. The idea behind using a photocell for sensing the state of your lamp would be to continuously sense the ambient light level in the room. Then use software to implement a threshold that triggers when the light level jumps/drops. You should place the photocell as close to the lamp as possible in order to help eliminate false positives.
Adafruit happens to have a great tutorial and further explanation of the photocell on the adafruit learning system.
I hope these ideas have helped answer your question and good luck with your circuit!
Don’t forget, everyone is invited to ask a question!
“Ask an Educator” questions are answered by Adam Kemp, a high school teacher who has been teaching courses in Energy Systems, Systems Engineering, Robotics and Prototyping since 2005.
Have an amazing project to share? Join the SHOW-AND-TELL every Wednesday night at 7:30pm ET on Google+ Hangouts.
Join us every Wednesday night at 8pm ET for Ask an Engineer!
Learn resistor values with Mho’s Resistance or get the best electronics calculator for engineers “Circuit Playground” – Adafruit’s Apps!
Maker Business — Undercover in an iPhone Factory (video)
Wearables — Go with silicone
Electronics — Shift away from basic arithmetic
Biohacking — Bunnies Book “The Hardware Hacker” Applies to Biohackers
Sorry, the comment form is closed at this time.