Introduction: Wireless RFID Home Alarm System Using an Arduino
This is a home alarm system that is not just a fun toy, but is actually usable and useful in everyday life. I built it because I realized that I already had most of the necessary components for it, and because I wanted to see whether I could make it work. This means it is not the cheapest or the simplest solution, so while describing the system and how to build it, I will also mention possible ways to simplify or customize it to your needs.
The system consists of 2 units, both of them inside your home. The main one (sender) detects when the door is open, and the secondary one (receiver) sounds a siren that is loud enough to attract attention. When you leave your home, you touch an RFID card/tag to the reader next to the door to activate the system. When you come home (or someone else opens the door) a wireless signal is sent instantly. The secondary unit receives that signal, and a countdown is started, giving you some time to enter your home and disable the alarm without disturbing the neighbors. When you touch your RFID card/tag to the reader, a second wireless signal is sent that stops the countdown and turns the alarm off. If the second signal is not received (because the person entering your home does not have the correct RFID tag) the siren kicks in and makes a loud noise for about a minute.
A few things worth mentioning before we go into the details: this system covers 1 entrance only, so if you have more than one doors or windows where someone can break in, you will need to modify the setup and the code for that. The siren will only scare burglars away if there are people in the area whose attention it might grab. Therefore this specific setup is best suited for an apartment in the city and not so much for a house in the suburbs or in the middle of the forest.
Step 1: What You Will Need
- 2x arduino boards: I used 2 Adafruit Pro Trinket 5V boards with the ATmega328p chip, but any arduino board should work as long as it has enough pins to control everything else.
- Some source of electricity for both arduinos. For me a USB to wall plug cable is good enough because power failures don’t happen often here. You can add a battery either as a primary or secondary power source if needed (depending on the arduino boards you have).
- RFID reader (arduino compatible): in my case it’s the Adafruit PN532 NFC/RFID Shield. This is to identify authorized people, so you can replace it with a fingerprint reader, a keypad to enter a numeric code, or anything else you can dream up.
- A couple of RFID cards/tags that are compatible with the RFID reader (typically 13.56 MHz). In the code I have 2 valid tags: one for me and one for a guest. You can add more for your spouse/flatmate/housemaid, or if you’d like to hide one at home just in case you lose yours.
- Wireless communication (at least 1 sender and 1 receiver): I used the XBee Module - Series 1 – 1mW (with USB adapter) because I already had those, but you can probably make it cheaper by getting something else doing wireless point-to-point communication. If you want to extend the network, the XBEE module is capable of handling more than 2 endpoints, but the arduino library I used doesn’t support that, so you will need one that does.
- A display to tell you whether the system is on or off, and to indicate how much time you have before the siren starts making noise. This piece is completely optional, or can be replaced by an LED. But keep in mind the psychological effect when someone opens your door and the first thing they see is a red and black screen saying “alarm in 10…9…8…”. I used a 2.8" TFT Touch Shield for Arduino from Adafruit, because I already had it. It also functions as a touch screen so you could use it to turn the system on, or to enter a PIN code to turn the alarm off. (I decided to use the RFID reader for that.) If you want to use a screen, the simplest one should do the trick, just make sure it’s arduino compatible.
- Some sensor that will create a signal when the door is open. I used a reed switch (normally open) and a magnet, but it could be a motion or proximity sensor. If you decide to put something on the door and/or the frame, you can use double-sided tape.
- A piezo buzzer or something to make enough noise. The one I have produces around 95dB which should be enough to scare the crap out of someone from a few meters away, and to start annoying the neighbors after more than just a couple of seconds.
- You’ll also need a decent amount of wire, and you may or may not need to do some soldering (beginner level) or a breadboard depending on the components you choose.
Step 2: Download the Software
Download the software from here. And if you're designing your own security system, here's a guide I wrote about the things you should consider.
Step 3: Wire It All Up
Once you have all the hardware, wire everything together based on the circuit drawings. You may or may not need to do some soldering depending on what components you’ve got.
Step 4: Upload the Code
Update the details in the code of the main unit so that the system knows the unique ID numbers of your RFID tags. (Right in the beginning of the code, you’ll see “IMPORTANT!!!” on line 15.) At this point you can add more tags for the system to recognize.
Once you’re done updating the code, upload it to both units respectively using the Arduino IDE.
Step 5: Testing and Troubleshooting
Test the system to see if you need to calibrate. Use a magnet with the reed switch to see what distance it travels before the alarm is triggered. Place your hand in front of the proximity sensor or jump around for the motion sensor if you’d like to.
If the switch is triggered but the secondary unit is silent, check the wiring on both units and troubleshoot the components one by one. Watch the red LED on the xbee module on the receiving end, that’s the one that will light up when it’s getting the incoming signal.
Step 6: Installation
Install the system. Put the main unit with the sensor next to the entrance, and hide the secondary unit somewhere nearby. The idea is to keep the receiving end out of sight and out of reach, as that’s the one making noise so that’s the one a burglar would have to disable.
Step 7: Trial Run
Do a trial run before setting the system live. I did a month-long test run turning the system on when I was home and turning it off when I left the apartment, just to be on the safe side. I didn’t want to annoy the neighbors with false alarms, which turned out to be a good call as I had a couple of those before updating the software to the final version, and putting more double-sided tape on the frame to hold the reed switch in place. During this period I triggered the alarm from time to time just to see if it was still working properly. I also noticed at this point that plugging or unplugging another electric appliance into the same extension cord as the main unit has the potential to mess up the system and trigger a false alarm. I don’t know if that’s just for me, or if it would happen under different circumstances too.
Step 8: Enjoy
Once you’re convinced that the system is working reliably, set it free and enjoy the warm and fuzzy feeling of being a little bit more secure than before. Try not to lose your RFID tag, or if you do, update the code for the main unit with a new one.
Let me highlight here that carrying your RFID tag on your keychain might not be the best solution. Instead, I would recommend keeping it on a separate chain (as a necklace or a wristband) or wearing an RFID ring on your finger. If you have an RFID chip implanted, you can use that too.