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.

The simplest way to do what you're talking about would be with a magnetic reed switch placed next to the solenoid in the existing doorbell and used as a simple push button with a pull down resistor. However, trying to run an AC current directly into your Arduino will result in failure, tears and the smell of burnt IC.

If you don't need the doorbell to function anymore, you can simply unwire the doorbell and use the doorbell's push button switch as a regular push button (there's really no difference between AC and DC switches.)

So calculon just wants to get the doorbell out of the picture, essentially using the doorbell as a pushbutton. but how to use the AC without frying the 'duino. He read this in a forum: 

Turn the AC into DC with a diode and capacitor, then reduce the voltage to 4V with a potential divider.

but he doesn't have any experience with voltage dividers...or know what type of diodes, caps, or resitors would get 16vAC to less than 5v DC