Saturday, March 7, 2015

Reading a Doorbell Transformer with an Arduino (Part 1, circuit design).

Motivation: It would be nice to be able to get a notification such as a text message whenever someone rings the doorbell. In this tutorial I will demonstrate how I can use an Arduino to alert me electronically whenever someone is at the door.

My water heater closet has the 24 V AC transformer which is used to power my the doorbell. My particular doorbell circuit consists of a spring loaded solenoid in series with a button. When the button is pushed, the circuit is closed and current flows through the solenoid, causing it to move and strike a bell ("DING"). When the button is released, the spring pulls the solenoid hammer back in, and it overshoots, causing it to strike a second bell ("DONG"). Most mechanical doorbells are as simple as this.

Here is an illustration of the doorbell circuit, which I made using LTSpice.

LTSpice from Linear Technologies is a free circuit simulation software package. This part is for illustrative purposes but if you think it might be useful for you in the future, I encourage you to download and learn to use it.


The voltage source on the left represents household current (120V RMS = 170V P2P). The two inductors L1 and L2 represent the doorbell transformer. In order for SPICE to couple these in the EM, a SPICE directive is needed. The directive "K L1 L2 1" means that L1 and L2 are perfectly coupled (so we have a perfect transformer). The resistor R1 was needed for LTSpice to perform the simulation and produce simulated wave forms. In order to get a voltage drop in the right ball park (120 V down to 24 V), I chose values of 100uH and 5uH. Since we're not actually building this, but documenting what exists, it is not so important that we're entirely accurate. If you want to try this with LtSpice I found this video useful. The button is where the doorbell button exists in the circuit.

So how do we do this?

While the solenoid is turned on, the current flow causes a voltage drop of about 4.0 volts RMS at the transformer output. The Arduino will  need to detect this AC voltage drop.

I will use one the analog pins on the Arduino to read the voltage. Since it is a bad idea to put reverse voltage across an analog pin, and since it is also a bad idea to put 24V on a pic, I will design a half wave rectified, voltage divider circuit

Here is the voltage divider:

In this circuit, the 24 V AC source represents the output of the transformer when the solenoid is not engaged. The center tap of the voltage divider will go to the analog pin on the arduino. The green waveform represents the output of the voltage divider in the center tap.

We need to get rid of the negative voltages so we will add a diode to work as a half wave rectifier.

The green wave form will be what we read with the Arduino.  It varies between 0 and 1.5V when the doorbell is not depressed (solenoid off), and 0 and 1.1V when the doorbell is depressed (solenoid on).

Once we have this circuit built, the next part is to use software to determine using samples from the analog pin, whether or not the doorbell has been pushed within the last few seconds. Stay tuned for part 2.

No comments:

Post a Comment