Let's Make Robots!

use mains AC as a switch for arduino?

hey gang, does anyone know if it's possible to use mains AC as a switch for the 'duino?

A little background:

Calculon is working on a project that he hopes will take advantage of his doorbell's AC power. He wants the old-school analog doorbell switch to activate a function on his arduino instead of firing off a solenoid in the door chime. Is this possible with some sort of voltage divider? He doesn't need to measure the current, voltage, phase, or anything liek that, he just needs to sense on/off like a pushbutton. He assumes the initial doorbell voltage will be 120V.



UPDATE: The chime's transfomer puts it at 16v AC. Also, there is a spare 4-cables-in-1 red wire that is live and unused as well. 

UPDATE 2: Calculon knows to be careful, about disconnecting the power so he doesn't electrocute himself, and can live to a ripe old age and so forth. Thanks.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

The best soultion would be to completely remove the switch from the mains circuit.

It should be really easy to do that. Maybe you can show us a picture of your chime as it is installed or the fuse box or something like that...

If that fails you could also replace the chime with a light bulb and use a photoresistor on the arduino to sense when the light turns on. The advantage of this idea is that it's cheap and you probably already have all the necessary parts, and your arduino is completely isolated from the high voltage circuit. You will probably have to put the bulb in a box so use a low power bulb, like one from a nighlight.

the lightbulb idea should work well

just take an ac rated led and put it and a photosistor in a peice of shrink tube pointing eachother


sadly, calculon cannot remove the switch from the circuit. he is replacing a doorbell wih an arduino, not recycling parts. but he thanks you for your helps.

As I said, COMPLETELY disconnect the switch from the doorbell circuit.

If you don't want the doorbell chime, I recommend going with what Maxhirez said in the last part of his post.  Completely disconnect the switch from the doorbell circuit and use it as any other switch on the ARduino.

wont's the 16vac wreck the arduino?

It is quite possible.  I would recommend using an optoisolator with LED input and phototransistor output.  Connect the input LED in series with a resistor across the contacts of the switch.  You should also connect a diode across the LED the opposite direction to prevent exceeding the reverse voltage of the LED.  Connect a resistor from the collector of the output transistor to your +5V on the Arduino and the emitter to the GND of the Arduino.  The collector of the transistor can then be connected to the Arduino.  It will go low 60 times a second (assuming you have 60HZ power).  When the switch is pressed it will short out the LED causing the low going pulses to disappear.  The Arduino can watch for the disappearance of the pulses, or some more circuitry can be included to only go high or low when the pulses disappear.  The key is the optoisolator.  It can be done without it, but I HIGHLY recommend using it.

Here http://electroschematics.com/6285/doorbell-light-circuit/ is a schematic very similar to what I suggested.  It also includes the "extra circuitry" I mentioned.

That's a really good page, full of lots of good stuff. Sadly, that schematic looks like it's for an altogether different type of chime with a different voltage, and calculon just wants to remove the chime altogether and use the 16vac for an interrupt. Unfortunately, Calculon's electrical engineering skills are the weakest leg of the hobby roboticist's art-code-wiring triangle.