Keep your escape artist pets safe in your yard with this DIY reed switch gate alarm!
Dogs are man's best friend, and my life would be nothing without them. However, trying to make sure that gates and doors are shut is essential to stop them from escaping! In this project, we will create a gate alarm that will sound an alarm when the gate is left open after a few seconds.
How the Reed Switch Gate Alarm Works
Most projects I design include some kind of program or microcontroller, but this one is entirely discrete. This circuit is comprised of three main areas:
- A reed switch and RC circuit
- A beeper circuit
- An oscillator
The magnet is mounted to the gate so that when the gate is closed the magnet closes the reed switch SW1. When the reed switch is closed, the capacitor C1 is charged through R1, and this results in a voltage of approximately VCC across C1. When the gate is opened, and the magnet is moved away from the reed switch, then C1 discharges thanks to R2, and the time taken to discharge C1 is approximately 2.2 seconds (using the RC formula). The voltage across C1 is fed into a unity gain buffer (U1A), and the output of this buffer is fed into a comparator (U1B).
The second circuit is a 4017 IC that provides the beeping pattern. While a buzzer could directly be connected to the output of the comparator, it is not as professional as a beeped pattern. This pattern is done by connecting specific outputs of the 4017 together through diodes, and this single output is sent to the buzzer through a transistor driver.
The 4017 has a reset pin which is connected to the output of the comparator so that when the reed switch is closed (i.e., the gate is closed), the comparator output is high, which holds the 4017 in reset and therefore turns the buzzer off. When the gate is opened (and the reed switch is opened), after 2.2 seconds the comparatorâs output turns off and the 4017 starts its beeping pattern. An oscillator circuit is made using a 555 timer in astable mode that produces an output square wave of approximately 6Hz. This oscillator clocks the 4017 IC and is used to provide timing for the beeps.
One small sub-circuit included in this project is a battery/solar panel selector. This circuit is comprised of two diodes connecting to VCC, which provides power switching for a battery and solar cell. During the day the solar panel should be producing a voltage output greater than the battery, and this results in the battery diode (D2) being reverse biased, which prevents the battery from being used. When the output of the solar panel falls below that of the battery, the solar diode (D1) becomes reversed biased and the battery provides power to the circuit.
This project can be built using most circuit construction techniques including stripboard, breadboard, matrix board, and custom PCB. For this project, I designed a custom PCB, since this project needs to be permanent and reliable. The PCB also has a solder mask to help prevent corrosion, and all pads are tin plated to improve solderability.
Since this project is used outside, I designed a weatherproof box using Google SketchUp, which is then exported to STL and printed on a Da Vinci Jr. 3D printer.
The box is mounted onto the gate, the reed switch installed, and then a solar panel mounted to the top of the box angled toward the north at a steep incline. The gate will never be left open and my dogs will never get the opportunity cause havoc!