Security / Automation Sensors
Security system sensors such as motion detectors, reed switches, pressure mats, glass-break detectors, infra-red beams, and conductive film can be very handy for all sorts of things including home automation systems, interactive art installations - and sometimes even security systems! Almost all security system sensors provide a simple switched output that changes state based on whether the sensor has been tripped or not, which means that when connected up in a circuit they behave just like a switch that is activated automatically. That makes them extremely easy to connect to an Arduino to read their status.
However, things are not quite as simple as they may first appear.
Most security sensors provide a "normally-closed" output: that is, when they have not been tripped their output is a closed circuit, and when it has been tripped it goes open-circuit. This is the exact opposite behaviour of something like a simple push-button switch, which is normally open-circuit and then goes closed-circuit when you press it.
The reasoning behind closed-circuit outputs is that it allows an alarm panel to verify the integrity of the connection to the sensor. If an intruder cuts the wire going to a motion detector the central alarm panel will see that as the same thing as the detector being triggered, and will sound the alarm even though the detector itself has been totally removed from the circuit and can't send back a signal to the panel.
That inverted logic is easily handled in software. If you want to use a security sensor for a non-security application such as triggering a kinetic sculpture when people walk up to it then you can treat a sensor as a simple switch and connect it to a digital input. Just remember that it will behave in the opposite way to a normal switch and you'll be all set.
However, any professional alarm installer will tell you that such a simple approach is totally inadequate for sensors that are security-critical. Having a sensor that will trigger the alarm if the wire is cut is a good start, but it doesn't go nearly far enough. What happens if an intruder climbs in through the roof, finds your motion detector wires inside the ceiling, strips back the insulation, and short-circuits them? It doesn't matter what the sensor does then because the alarm panel will think the sensor circuit is good. The intruder can walk around inside your house with the alarm fully activated and it won't even notice. Or what happens if someone gets underneath a motion detector without triggering it, such as by coming in through a doorway underneath it, and then removes its cover to mess with it? Or even more insidiously, what if someone was in your premises when the security system was disarmed (such as a customer in a store during regular opening hours) and took the opportunity to take the cover off a motion detector and bypass it so they could return later when the store is closed and the security system has been armed?
To guard against those sorts of attacks a security system needs to detect far more than a simple open or closed circuit. It needs to be able to detect if the wire to a sensor has been cut, or a wire short-circuited, or the sensor has been tripped. It also needs to detect if the sensor is being tampered with, even when the alarm system itself is in a "disarmed" state. Well-designed security systems treat all parts of the system as untrusted and can detect tampering in nearly any cable or sensor at any time, whether it is currently armed or disarmed.
In this project we'll use the flexibility of the Arduino's analog inputs to build sensor circuits that are as fully-featured as any professional system and will allow you to detect any of those possible failure, tamper, or trigger conditions automatically. You can then use your Arduino as a security system controller, or as part of a home automation system to turn lights on and off as you enter and leave rooms, or to control an art installation based on viewer activity.
|1||Arduino Duemilanove, Arduino Pro, Seeeduino, or equivalent|
|1||2-connection PCB-mount screw terminals (for 12V power)|
|8||2-connection PCB-mount screw terminals (2 per channel, total 4 channels)|
|1||Green or blue LED|
|4||Red LEDs (1 per channel)|
680R resistors (1 per channel)
1K resistors (1 per channel)
4K7 resistors (3 per channel)
|4||Passive infra-red (PIR) motion detectors with a simple switched output, not a "smart" PIR (1 per channel)|
|1||12V power supply rated to at least 500mA|
|20cm||Hook-up wire or ribbon cable|
|4-core security cable long enough to connect to sensors|
Note: Quantities specified are to build a 4-channel board supporting one sensor per channel. For a different number of channels, adjust the quantity of "per channel" parts as appropriate.
Security / Automation Sensors Schematic
Download as JPG: security-sensors-schematic.jpg
Download as PDF: security-sensors-schematic.pdf
Download as SCH: security-sensors-schematic.sch
Freetronics have ready-built and kit versions of this project: Freetronics Security Sensor Shield. It implements the same circuit as documented in the book, so it is a great way to get started quickly and easily.
Found a problem? Please let us know.
The resistor ladder schematic on page 100 does not allow detection of multiple simultaneous button presses, but does work perfectly for detecting individual presses. The schematic also does not match the description in the circuit: each resistor should be a different value as described in the text. Replacing the resistors with the values described in the text and moving them to place them in series with their associated button will allow multiple presses to be detected.
Have you built this project or something inspired by it? Please let us know and we'll put a picture of it here!