Home Guarduino - IoT Connected Security System




Introduction: Home Guarduino - IoT Connected Security System

PROBLEM: We moved into a new house a couple of years ago, and it already had a security system installed. Problem was that nobody knew the password! The previous owners never used it, and the manufacturer had gone out of business. Despite extensive internet searches, and even consulting a security expert, the system remained a 'brick on the wall'.

SOLUTION: A perfect opportunity for DIY.

I wanted to use the use the already installed wired PIR motion sensors and smoke detectors, I wanted the Main Panel and Keypad to be 'drop in replacements' for the existing units, and I also wanted to add some extra features like card access and internet connectivity.

Final Specs:

- 8 programmable tamper-proof zones (fire or burglar)
- RFID card or tag arming/disarming
- Internet connection via home wifi which logs all activity to the web
- Secondary wifi connection to a permanent cellphone hotspot
- Sends notifications (eg phone call and email) when alarm is tripped or fire detected
- Battery backup if AC power cut
- 5 programmable digital zones (for addition of wireless sensors at a later stage)

Step 1: Overview

My aim was to produce a security system as near to professional quality as possible - so I had to research best practices for home security systems. This involved understanding of tamper-proof zones, debouncing to reduce false alarms, and backup battery charge circuits, among other things. I am not a security expert, so please let me know if I got any of this stuff wrong.


The Keypad Unit is based around a Arduino Nano, interfaced to a 16x2 LCD display (via a shift register to minimize the number of digital pins used), an RFID module and a 4x4 keypad, with a bi-colour LED and piezo buzzer for feedback. The Keypad communicates via serial link to the Main Panel.


The Main Panel is also based around an Arduino Nano. Linked via serial comunicatiion with the Keypad Unit and also (via soft serial) to a EPS8266 wifi connection. Analogue inputs are used for the tamper proof zones. Two relays are employed - one for the siren and one to cut the power to wired sensors on reset (some sensor types require this).

A bridge rectifier and series of regulators provide 12v, 5v and 3.3v power and a trickle charge to the backup battery.


Events are logged via wifi (ESP8266) to a ThingSpeak IoT channel (thinkspeak.com). This channel records changes in status (eg alarm armed, alarm triggered etc), changes in wifi and ac power availability, and also which zones have triggered an alarm.

ThinkSpeak can be configured so that various tasks occur for specific events. My system will email me (via PushingBox) and call me on my cell phone with a predefined message (via Twilio) if the burglar or fire alarms are activated. But you could do many other things - like send a txt or a tweet.

Step 2: Keypad Unit

The PCB for the Keypad is single sided 72mmx70mm and was made using the 'iron on' laser printed technique, (details of which can easily be found elsewhere) and drilled with a highly sophisticated drilling apparatus (www.instructables.com/id/Cheap-PCB-Drillpress-for-Dremel) of my own design.

The fit into the case is a tight one, and I moved the LED and buzzer off-board. Note that I left the protective plastic on the buzzer because it was too loud if I removed it! The case was also modified so that it could be opened and closed using two screws placed at the bottom. The screws screw into nuts that are mounted on the outside cover with two pieces of plastic and glue. They screw up into two aluminium brackets to hold the case closed.

The RFID module fits nicely into the smaller case and is stuck to the wall with padded two sided tape.

The artwork was colour laser printed onto clear labels and attached to the cases.


1 x 5mm bi-colour LED
1x 4x4 16 button keypad http://www.ebay.com/itm/Data-Keypad-Switch-4-x-4-White-Key-Security-Pad-16-Momentary-Door-Entry-Button
1x 16x2 LCD Display http://www.ebay.com/itm/1602-16x2-Character-LCD-Display-Module-HD44780-Controller-Blue-Blacklight
1x MRFC522 RFID board http://www.ebay.com/itm/MF522-AN-module-RC522-RFID-Radiofrequency-IC-Card-with-Sensor-Reader-Arduino

1x Active Buzzer Alarm Module (not passive as per schematic) http://www.ebay.com/itm/Active-Buzzer-Alarm-Module-Sensor-Beep-for-arduino-smart-car-new

1x PN100 or equivalent transistor

1x 10K trimpot
1x 1K resistor
2x 220R resistors
1x 74HC595N
1x Arduino Nano V3.0 ATmega328 5V

2x each 3pin, 6pin & 8pin headers
2x 2-way screw terminals
1x small case (18x45x70mm) http://www.ebay.com/itm/2pcs-NEW-White-Plastic-Electronic-Project-Box-Enclosure-case-DIY-18x45x70mm
1x large case (25x90x135mm) http://www.ebay.com/itm/RF20070-ABS-Plastic-Enclosure-for-Electronics-Connection-Box-Project-Case-Shell

Step 3: Main Panel

The Main panel PCB is single sided 180mmx120mm and was made the same was as the Keypad PCB.

Note the two 3-pin headers with 2-pin movable jumpers, one is for master reset, and the other is to allow updating of the firmware on the ESP8266 (but this function not implemented in the Main Panel firmware yet).

The ATTINY85 and RF Reciever can be left off, as these are for yet-to-be-implemented wireless sensors.

Five digital inputs (zones 8 to 12) are also available on the expansion header - if you have a use for these. When programming the panel, NO means normally logic 0, and NC means normally logic 1 for the digital zones. Note that these are not tamper-proof, and so should only be attached to modules (a wireless-sensor receiver, for example) contained within the Main Panel housing.


1x 7805 regulator
1x LM3940IT3.3 regulator
1x LM317 regulator

4x 0.1uf capacitors
1x 2200uF
1x 1uF

1x Green LED
1x Red LED

4x 100R resistors
8x 10K resistors
1x 1K
8x 1K2
9x 220R
1x 470R
1x 4K7
1x 500R trimpot
1x 220R 5W wirewound

2x 2N7000 mosfet
1x PN100 or equiv transistor

1x 500mA PTC fuse

3x 1N4004

8x 1N4733 5.1v zener
2x 1N5314
7x 1N5404

14x 2-way screw terminals

1x Arduino Nano V3.0 ATmega328 5V

1x ESP8266 Serial Esp-01 WIFI Module http://www.ebay.com/itm/ESP8266-Serial-Esp-01-WIFI-Wireless-Transceiver-Module-Send-Receive-LWIP-AP-STA

2x 5V One 1 Channel Relay Module Board Shield http://www.ebay.com/itm/310566336050

ADDITONAL PARTS (for wireless sensor connection - not required as not yet implemented)

1x 433Mhz RF Reciever Module http://www.ebay.com/itm/433Mhz-RF-Transmitter-Module-and-Receiver-Link-Kit-for-Arduino-ARM-MCU-WL

1x 2 DIP switch

ADDITIONAL PARTS (not required if replacing an existing unit as I did)

1x SA12-7 Sealed Lead Acid Battery 12V7.0AH/20HR
2x In-line fuse holders with 1A quick blow fuses
15VAC Power supply or transformer
1x Lockable Metal Wall-Mounted Case 230x260x80mm
1x 12V Exterior Siren & Strobe Light
1x Interior Siren
2x Insulated heatsink mountings for regulators
PIR sensors (12 volt) and Smoke detectors(12 volt) as required

Step 4: IoT Connectivity (ThingSpeak, PushingBox, Twilio)


You need to create a ThingSpeak channel before you upload the firmware to the Main Panel. This is because your ThingSpeak key will be hard-coded into the firmware.

Go to thingspeak.com and create an account (it is free). Then click on the channels tab and then the new channel button. Set up the channel (ALARM_MONITOR) with four fields in the same order as shown:
Field 1 - Status
Field 2 - AC
Field 3 - Wifi
Field 4 - Zone

One you have created the channel, select the API Keys tab and take a copy of your 16 character API Key - this will be entered into the firmware later.

Alarm status will be logged to the ThingSpeak channel every hour, and any time that there is a change in status. The values logged into Field 1 are:

STATUS_READY 0 (ready / not ready)
STATUS_ALARM 9 (burglar alarm)
STATUS_FIRE 10 (fire alarm)

This is all you need to do to simply have a log of events, but typically you will want to be contacted if an alarm trips. I will show you how to set up ThingSpeak reacts that will send an email (via pushing box) and a phone call (via Twilio). I will show you two examples: email when burglar alarm activated and phone call when fire alarm activated.


You will need a google account. Go to pushingbox.com and login with your google account.

Select My Services and press the Add a Service button. Select Email and enter your email address and give your service a name.

Select My Scenerios and add a new scenerio. Press Add an Action, and then select your email service. Type the contents of the email notification that you want sent. Note the DeviceID for your scenerio - you will use this in ThingSpeak. (I have two scenerios - one that sends a burglar alarm notification and one for the fire alarm).

Back in ThingSpeak, select Apps, then ThingHTTP, then New ThingHTTP.

Setup your ThingHTTP like this (some entries are blank):

Name:Send email ALARM

HTTP Auth Username:
HTTP Auth Password:
Content Type:application/x-www-form-urlencoded
HTTP Version:1.1
Body:devid=XXXXXXXXXXX [XXXXXXXXX= PushingBox Scenerio DeviceID]
Parse String:

You can test this by pasting the url generated on the right hand side of the page into a browser (leave off the 'GET' at the beginning). You should receive your email notification.

In ThingSpeak select Apps, then React, then New React.

Now you set up a React so that your Send email ALARM ThingHTTP is activated when the Status field becomes equal to 9, which is STATUS_ALARM (ie burglar alarm). See the picture for exact details.


You will need to sign up for a Twilio account at www.twilio.com. It is free to signup, but costs to purchase phone numbers and to make calls. On your account dashboard there will be anAccount SID and an Auth Token that you will need later.

Click on the # (phone numbers) icon on the left. Here you will need to purchase a phone number using the Buy a Number option, and you will also have to verify your cellphone number using the Verified Caller ID's option.

Back in ThingSpeak, select Apps, then ThingHTTP, then New ThingHTTP.

Setup your ThingHTTP like this (some entries are blank):

Name:Phone call FIRE
Content Type:application/x-www-form-urlencoded
HTTP Version:1.1
Parse String:

Replace XXXXXXXXXX with your Twilio Account SID
and YYYYYYYYYY with your Twilio Auth Token
and +ZZZZZZZZZZ with your verified cellphone number
You also need to provide a url to a text file that contains the content of your phone call (via text to speach).
Mine are http://cr8software.net/fire.txt and http://cr8software.net/alarm.txt. You can use these links, but I cannot guarantee that they will always be available. Best to upload your own text files somewhere.

You can test that the call works by pasting the url generated on the right hand side of the page into a browser (leave off the 'GET' at the beginning). You should receive a phone call notification.

Now in ThingSpeak select Apps, then React, then New React.

Now you set up a React so that your Send phone FIRE ThingHTTP is activated when the Status field becomes equal to 10, which is STATUS_FIRE. See the picture for exact details.


An alternative to setting up ThingSpeak Reacts (with email and phone notifications), is to use a phone app which monitors your ThingSpeak Channel. There are several available. eg ThingView Free or IoT ThingSpeak Monitor Widget, which are available from the Play Store.

Step 5: Firmware

Before attaching the Keypad to the Main Panel, upload the firmware.


The Keypad firmware requires the following libraries:


Once you have uploaded, you can connect to it with the serial monitor to check that it is working properly.

Type some characters on the Keypad, when you press one of the alpha keys (A, B, C or D), a string of characters should be sent to the serial monitor.

Try typing some commands in the serial monitor to check that the Keypad responds:
>READY (will show "ready" on the display)
!BEEP1 (will make a sound)

If all is working, then move on to the Main Panel.


The Main Panel firmware requires these libraries:


Before uploading you will also have to enter some information into the sketch (around line 121):

#define SSID1 "XXXXXXXXXX" //Primary WIFI network name
#define PASS1 "XXXXXXXXXX" //Primary WIFI network password
#define SSID2 "XXXXXXXXXX" //Secondary WIFI network name
#define PASS2 "XXXXXXXXXX" //Secondary WIFI network password

String GET = "GET /update?key=XXXXXXXXXXXXXXXX";
//Replace XXXXXXXXXXXXXXXX with your ThingSpeak "Write API Key" for your Alarm Channel

Once you have uploaded again you can test with serial monitor. Enter ? into the serial monitor, and the Main Panel should respond with >READY.

Step 6: Installation


Hopefully the diagrams are self-explanatory for connecting things up.

The Keypad and sensors are connected to the Main Panel with 4 core alarm cable (black, red, white, blue).

I am not sure of the maximum advisable distance for the connection between the panel and keypad (mine is just through the wall), but the sensor cables should be able to handle wiring all around the house. Powered sensors (like PIR sensors and smoke detectors) should take their power via the Aux Reset relay, as some sensors need to be powered down to reset (the Aux Reset relay will open for 5 seconds when the panel resets).

Before connecting the battery adjust the trimpot to get a suitable charge voltage at the battery terminals. My battery states 13.6 - 13.8 volts as an acceptable range, and I have set my trickle charge voltage at 13.65 volts. Make sure you set the voltage to match your battery and seal the trimpot with a glue gun.

The 12v and 5v regulators need to a heatsink as they will get warm even with the heatsink attached to the metal cabinet. Make sure the heatsink is insulated from the regulators with bushes.

The zones are 'supervised' (ie tamper proof), and require single End Of Line Resistors of value 1K2 as shown in the diagram. This is a standard type alarm configuration with three states (open, closed, and 1k2 resistance). 1K2 resistance across the zone terminal is the untriggered state. Open and closed circuits will either mean the alarm has been triggered, or the cable has been shorted or cut. You can have one or more sensors per zone.

I recommend having a button that will trip when the Main Panel cabinet is opened. You can see this in the upper right of the picture. This is connected to a zone that has a 0 second trigger delay, and set to cause a 'not-ready' status if open. The cabinet should also be lockable. This is so the alarm will trigger and send a notification before anyone has time to disable it.


When powering up for the first time, put the reset jumper (middle top of panel) in the upper position. The display should read MASTER RESET. Enter #0200D into the Keypad, this will save all the defaults to the EPROM. Put the jumper back in the lower position and do a manual reset using the button on the Main Panel Arduino.

The alarm is now ready to program.

Step 7: Operating Instructions

There are two four digit passwords:

USER password (default 0123, denoted UUUU below) - everyone who needs to arm and disarm the alarm will have this

MASTER password (default 9999 - denoted MMMM below) - used to program the system, generally only one person will know this


Enter MMMMB (will be 9999B initially, after reseting to defaults) into the keypad to enter programming mode. The display will say PROGRAM.


To program global attributes enter #99B (ie zone 99). Then to list the current values enter *B

To change an attribute enter n*mmB , where n=attribute and mm=value. eg to change the master password to 7890, enter 0*7890B

0 - Master passcode (4 digits) [9999]
1 - User passcode (4 digits) [0123]
2 - Exit time (seconds, 0-255) [30]
3 - Log Wifi 0=no 1=yes [1]
4 - Action when fault/tamper occurs on a zone 0= no action 1=error 2=alarm [2]
5 - Debug level [0]
6 - Siren duration (minutes, 1-255) [5]

Notes: Values in [ ] are defaults. Exit time is the number of seconds you have to leave the house once the alarm is armed.


Enter#90B (zone 90) to program cards. Swipe a card to add it to the list of accepted cards (maximum of 5). Swipe a card, then press D to delete a card


Enter #xB to program Zone x attributes (0-12 allowed, zones 8-12 are digital zones on the expansion header). Enter *B to list the current atttributes for that zone.

0 - NO/NC 0=NO 1=NC [0]
1 - Mode 0=Not Used 1=Alarm 2=Fire(24hrs) 3=Silent 99=disabled [0]
2 - Debounce count (cycles 250ms) [3]
3 - Trigger Delay (seconds) [15]
4 - Cause NOT READY mode if triggered? 0=no 1=yes [0]

Notes: Mode 1 (Alarm) can trigger only when alarm is armed. Mode 2 (Fire) can trigger at any time.
Debounce count is the number of 250ms cycles that the sensor has to be activated for before alarm will trigger.
Trigger delay is the countdown to siren after sensor is triggered.
If attribute 4 is set to 1, then the alarm cannot be armed if the sensor is currently triggered.
After a master reset, Zone 0 will be configured for NC, other Zones will be configured 'Not Used'.
Zone 'Disabled' means that the zone is disabled only until the next reset. Use 'Not Used' for any unused zones.


101*B - display the real-time status of all zones. Press C to exit this mode. 0=normal, 1=triggered, 2=fault
102*B - display the wifi and ac status (after a short delay)
199*B - reset (same as ####D)
200*B - test siren for 1 second
*#*#D - Main Panel offline (turns off the Main Panels serial port). Do this when updating Keypad firmware. You will need to do a manual reset (press button on main panel Arduino) afterwards.
*#*#B - Keypad offline (turns off the Keypad serial port). Do this when updating Main Panel firmware. Enter ####D to reset afterwards


*D - Save any changes to EPROM and exit programming mode
#D - Cancel any changes and exit programming mode


TO ARM: enter user password and press 'A' eg UUUUA
OR swipe a programmed RFID card then press 'A'

Note that the Keypad must display READY before you can arm.

TO DISARM: enter user password and press 'D' eg UUUUD
OR just swipe a programmed RFID card

If the alarm siren has been activated then entering UUUUD will disarm the alarm and deactivate the siren. NOTE: If the siren was triggered by a Fire(24hrs) zone, then that zone will now be disabled to prevent re-triggering. Do a system reset to re-enable all zones (# # # # D see below).

* * * A - will manually activate the fire alarm (can enter at any time)
# # # # D - will do a system reset (ready/not ready or programming mode only)

Step 8: Maintenance

Check that your alarm is functioning properly maybe once a month or so.

Use a smoke detector test spray (eg CRC Smoke Test) to test that the smoke detectors are functioning (don't use an open-flame to test!) , and that the siren activates.

Check that the PIR sensors trip the alarm and that you receive the correct notifications.

Make sure you have credit in your Twilio account.

Most importantly, make sure you warn other family members (especially wife) before you test the siren!

IoT Builders Contest

First Prize in the
IoT Builders Contest

Be the First to Share


    • One Board Contest

      One Board Contest
    • New Year, New Skill Student Design Challenge

      New Year, New Skill Student Design Challenge
    • Jewelry Challenge

      Jewelry Challenge



    Question 1 year ago


    I am creating my own system and I wanted to know if it is possible to replace the standard 16x2 LCD with an I2C LCD with a SPI backpack?


    3 years ago

    nice project! please i need to connect magnetic switch rf 433
    please how to connected & how to programming attiny 85


    Question 3 years ago

    Is there a way to add addition analog zones to the system or would one need to adapt the code for a Arduino Mega?


    Question 3 years ago

    I made one for me followed your tips. And i want it display and run with tft touchscreen lcd. How i do it ??? Thanks


    Question 3 years ago on Introduction

    Is it possible to be able to bypass zones, for instance if you want to arm the alarm at night but want to be able to walk through certain areas of the house?


    5 years ago

    is it possible to link two keypad units with one main panel?


    Reply 5 years ago

    Not without modification - you wouldn't be able to simply connect two panels to the same serial port.

    You could probably add an extra soft serial port to the main panel on a couple of the spare pins, though. You would also have to update main panel firmware to listen to the new port.


    5 years ago

    If your internet connection is down then it won't be able to connect to thingspeak. Does that mean it will not work/make outgoing phone calls?


    Reply 5 years ago

    There system also has a secondary wifi-connection. The idea is to setup an old cellphone as a wi-fi hotspot plugged into the wall so that if your main broadband is down (or has been disabled by a burglar cutting your optical fibre etc) then it will contact ThingSpeak using the alternate connection.


    5 years ago

    This looks gr8 except for 1 small issue that I noticed, that being the zone sensors should use normally closed contacts where possible.

    This provides a fail safe feature i.e. if your signal cable breaks, the monitor fails or some one goes snip snip on the cables (none of which will create in any event if you are using normally open contacts).

    Just a passing thought


    Reply 5 years ago

    It has been speculated that a system like that was part of the sinking of Estonia. The


    Reply 5 years ago

    The bow visor was rigged with an alarm that would light up a light when it was unlatched. As the breaking of the visor tore off the alarm sensor also it was quite impossible for the light to light up. So it is recommended to use a sensor which gives an signal also when it fails.


    Reply 5 years ago

    I am not sure we are looking at this the same way, if in a normally open circuit as described in the ible and the sensor was broken away, you would still have no alarm as the circuit would still be open circuit, If it is a normally closed circuit and the sensor is ripped away, you then have an open circuit and the alarm is them raised.

    From a logic perspective a closed circuit gives you a logic 1 and all is good, break the circuit and you get a logic level of zero which equates to an alarm.


    Reply 5 years ago

    It's all in the way that it's wired. I though it was quite a clever system when I read about it.

    Even though the sensor is normally open, because there is a resistor across it (at the end of the line), the alarm sees the resistance when the sensor is in the normally open state.

    If the alarm sees closed (ie sensor closed or wire shorted) or open state (wire cut) then the alarm sounds.


    Reply 5 years ago

    Fair enough point however what happens if the sensor fails? you will still have your quiescent current and as such that sensor may as well not be there.

    You are relying on a relay to close if there is a fault, much safer to wire them normally closed in series as your second circuit shows, then if your sensor fails the sensor relay contact will open circuit.....

    As I said your system should be designed as "fail safe".


    Reply 5 years ago

    Yes, my system allows for wiring with either NC or NO contacts, and you program the zone correspondingly.

    I think that the type of fail-safe you talking about might be built into the sensor in some cases (ie the motion sensor is designed to trip if it's power supply is cut etc). The PIR sensors (and smoke detector) sensors that I have can be wired as either NC or NO. You would probably have to read the documentation of the particular sensors that you have to establish whether it is best to use NC or NO.


    Reply 5 years ago

    Hi Allan,

    As I said to start with, this a good and commendable system however the N/O inclusion is a potential flaw.

    I spent 6 years as a signals & communications technician with our local railway system some time ago and EVERY possible point of failure was covered by a N/C contact, and as you could appreciate the failure of fault detection could result in the deaths / sever injuries of a 1000+ commuters at a time.

    This was to the level that too much dust on or deteriation of a particular contact point would bring that part of the track sections / trains to a screaming halt, as designed (along with a lengthy report as to the cause of the fault).

    Some may think I am a n a l in this regards but it is a philosophy that I have maintained for decades since then.

    During track maintenace 1 late evening, some "bright spark" (pun intended) physically lifted a track relay (forcing the closure of contacts) of a section of track which allowed the train driver to proceed through the unsafe section, fortunately it was in a low speed zone and at that point in time, the possibility of a collision with a freight train coming from the opposite direction existed, this did not happen however as it turned out the train was still lucky to survive as there was a train in front of it that was stopped at a station which the driver became aware of and stopped in time.

    Is this an extreme example, Yes. It may however somewhat emphasize my point regarding a failsafe system.

    I stand by these principles to this day and my primary concern was to make others aware of possibly previously unconsidered issues.

    Kind regards


    Reply 5 years ago

    Thanks for the insight, and based on that I would also advise to use the N/C option. I included both because from what I could gather, many alarm systems (I read technical manuals of some when making this project) and sensors appear to offer both options.

    At the end of the day, though, real life experience is always more valuable than tech manuals - cheers!


    Reply 5 years ago

    The irony of a smoke alarm catching fire is not lost on me.
    Yes it did set itself off.


    Reply 5 years ago

    The zones are what are called 'supervised zones', with 'end-of-line-resistors' (see diagram in installation section) which means that the alarm will sound in any of these 3 scenerios:

    1. Sensor is triggered
    2. Sensor wires are cut (ie fault or tampering)
    3. Sensor wires are shorted together (ie fault or tampering)

    There are other methods, but I wanted to be able to simply connect the existing sensors without having to rewire. My old alarm used the above method (I think it is quite common).

    The analogue inputs of the Arduino are used so that it can detect the three states.

    This method will work with normally open or normally closed contacts, but the placing of the resistors is slightly different in each case to achieve this.