Introduction: Arduino Wireless Alarm System Using Existing Sensors

This project can be built in about half an hour at a cost of about $20.00 if you have existing 433Mhz or 315Mhz wireless alarm sensors.

It can also be a complete new project with wireless alarm sensors, such as infrared motion detectors and reed switches, easily and cheaply available online. Just search for 433Mhz or 315Mhz sensors that use PT2262 or EV1527 coding.

I am sure there are many people like me who have purchased a GSM/2G alarm system with wireless sensors and were happy with it, however when the 2G/GSM network was turned off where I live, I was left with an alarm system I could no longer program or even set the time on it. One day while wondering what I could do to make my alarm functional again, it occurred to me to check if an Arduino could receive signals from the sensors. I stumbled across an instuctable and after some experimenting determined that I could receive the signals from my existing sensors. I began the process to build an alarm system that could replace my existing alarm and would also provide increased functionality. One of the issues with the old alarm was never actually knowing exactly which of the 25 sensors went off, by adding an LCD screen to my new alarm build I now get text on the LCD indicating exactly which sensor was activated. The new alarm can still be manually armed by my existing wireless keyfobs and has a real time clock to allow it to automatically arm and disarm at preset-able times of the day.


See additional notes at end to ensure you use the correct version of these parts.

Arduino Uno or similar

433 or 315 MHz receiver module for Arduino

DS3231 Real Time Clock module for Arduino

I2C 16x2 LDC module for Arduino

Wireless Alarm reed switches, motion sensors and remote key fobs as desired

Piezo buzzer

LED & 220 ohm resistor

Breadboard (optional but recommended)

Suitable power supply for Arduino

Jumper wires etc

PC with Arduino IDE installed

Basic knowledge of Arduino

Step 1: Supplies

Some images above of the supplies you will need for this project

Step 2: Wire Up the Ardunio and Modules As Shown in the Image

Piezo between pin 5 of the Arduino and earth

LED between pin 8 of the Arduino and to a 220ohm resistor then to earth

433 or 315 Mhz receiver, VCC to 5V, GND to ground and either one of the 2 data pins to pin2 of the Arduino

I2C 16X2 LCD Module VCC to 5V, GND to ground, SCL SDA pins to SCL SDA of the Arduino (pin A5 is SCL, pin A4 is SDA)

DS3231 RTC Module VCC to 5V, GND to ground, SCL SDA pins to SCL SDA of the Arduino (there is 2nd set located above the GND and AREF pins of most Arduino's)

I know some of you will not need anymore info than this and the sketch attached below but I will go into some more detail for anyone who would like a little further assistance.

Step 3: Add Necessary Libraries to the Arduino IDE

The Arduino Sketch to run the alarm uses some libraries that are not already installed on the Arduino IDE by default.

To add RCSwitch library to the Arduino IDE. Open the Arduino IDE in the top menu select "Sketch" then from the drop down select "Include library" and from the next drop down select "Manage libraries". Then in the "Filter your search" box type "RCSW", next click on install for "rc-switch by sui77"

Detailed instructions on adding libraries at

While we are at it we also need to add the libraries called Time, TimeAlarms, DS1307RTC and LiquidCrystal_I2C, same procedure as above but searching for the name of each new library and installing. See screen shots above if unsure which libraries to use.

The DS3231 real-time clock is compatible with and uses the DS1307RTC library.

Step 4: Next We Need to To Get the Codes for Your Sensors

I have provided the template of the Arduino code below but you will need to find the values for each of your sensors and paste them into the code.

There is extensive information on how to obtain these codes at both these sites;

However here is my abbreviated version;

To obtain the codes your sensors and remote key fobs are sending, attach the Arduino as assembled in step 1 to a PC via USB cable and open the Arduino IDE. Then in the Arduino IDE go to the "File" drop down, then go to "Examples" scroll down the list of example sketches until you find "RCSWITCH" then select the "ReceiveDemo_Advanced" sketch and upload it to the Arduino. Once the sketch successfully uploads open the serial monitor of the Arduino IDE with it still attached to your PC via USB. Now trigger the first of the sensors you want to get the code for, the output from RCSwitch will appear in the serial monitor window. For this project we are looking for the decimal codes as highlighted in screenshot 2. You will need to trigger the sensor multiple times looking for the decimal value that appears most often, sometimes there will be different values mixed in with true value, this is caused by interference from random radio waves or other devices operating on same frequency.

Note the decimal code of the sensor for use in the next step. Repeat for all the sensors and remote keyfobs you want to use in the project, keeping track of which code goes with which sensor. If using keyfobs to arm and disarm the alarm you will need note the different codes for the arm button and the disarm button of each remote.

Step 5: Arduino Code Template

Below is a copy of my Arduino code as a .ino file called Wireless_Alarm. You can click on it and it should open in the Arduino IDE. I am not a programmer my code is assembled in part from the examples found in the Arduino IDE, it is probably not particularly elegant but it does work and has been reliable over a long period of time.

Remember to re-save the sketch after you make the changes to include the codes from your own sensors.

Step 6: Paste the Codes You Obtained in Step 5 Into the Template Arduino Sketch.

Now the steps to customize the code for the sensors and remote keyfobs you are using.

If you open the Wireless_Alarm sketch in your IDE you will see at line 111.

if (mySwitch.getReceivedValue() == 115166236) //Fob arm button code

Where in the existing code it reads 115166236 you need replace that number with decimal code for the arm button of your remote keyfob which you recorded at Step 5.

For example if in step 5 you got a decimal 1154321 you would modify line 111 to now read;

if (mySwitch.getReceivedValue() == 1154321) //Fob arm button code

Follow the same procedure for line 125.

if (mySwitch.getReceivedValue() == 115166234)  //Fob disarm button code

Substitute 115166234 for the code of your remote keyfob disarm button which you recorded at Step 5.

If you want to use multiple remote fobs to arm and disarm, copy and paste lines 111 through to 136 as many times as required then change values to suit your other remote keyfobs, but best just to start with one remote until you are sure your modified sketch is working.

Now to coding the alarm sensors in the sketch at line 140

if(ledState == HIGH && mySwitch.getReceivedValue() == 1151640) //Action for signal sender office cupboard

Take out 1151640 and insert the decimal value of one of your alarm sensors.

Then at line 158.

lcd.print(F("Office cupboard")); //print message to lcd to know which sensor was activated (and go and find the burglar :)

Change Office cupboard to what ever you would like to be displayed on the LCD for that sensor. For example if you want it to read kitchendoor make the line look like this;

lcd.print(F("Kitchendoor")); //print message to lcd to know which sensor was activated (and go and find the burglar :)

Names should not exceed 16 characters.

Between line 165 and 187 is a template to copy and paste as many times as required to the lines directly below 187. Replace the number after mySwitch.getReceivedValue() == with the decimal of one of your other sensors that you recorded in step 5 and change name within the " " in lcd.print(F("sensornamehere")); to the name you want to give your sensor .

If you are not using remote keyfobs to arm and disarm your alarm you can just ignore lines 111-136 or put // at the start of each of the unwanted lines and the Arduino will not read them.

Remember to save the file after you have made your changes.

Step 7: Upload the Amended .ino to Your Arduino and Test.

With the Arduino still connected to your PC by USB upload the sketch to the Arduino Board. Once the upload is successfully completed the LCD should read "Alarm On Disarmed". Push the arm button on your remote and the LCD should read "Alarm On Armed" and the LED should be lit to let you know it is armed, now trigger a sensor while it is armed, LCD should read Alarm follow by a time stamp and the location of the sensor, the beeper should sound for 2 minutes unless you push the disarm button. If you are not getting this result recheck the codes you got in Step 5 and the changes you made to the code in the previous step, also recheck the wiring of all components. If the LCD is not reading at all, there is a contrast adjustment on the back of the LCD module. Once contrast is set correctly if the LCD is still not reading try changing the Address of the LCD from 0x3f to 0x27 at line 12 in the sketch. LCD troubleshooting here I2C LCD tutorial

Step 8: Setting the Time on RTC Module and Changing the Arm and Disarm Times

Hopefully your RTC was already set with the correct time but if not open the IDE, select 'File" and from the dropdown click on "Examples", scroll down to "DS1307RTC" and select the "SetTime" sketch, download the sketch to your Arduino and it will set the real time clock with the time from your PC. You will then need to reload the Wireless_Alarm sketch to your Arduino.

The Wireless_Alarm.ino I have provided will by default set the alarm to arm automatically at 10.15pm every night and disarm at 6.00am each morning. To change these times, modify the Sketch at lines 71 and 72. The time is in brackets after Alarm.alarmRepeat in the format HH,MM,SS. change this to whatever time suits you.

Alarm.alarmRepeat(6,00,0,MorningAlarm);  // DISARM time
Alarm.alarmRepeat(22,15,0,EveningAlarm);  // ARM time

So to change the disarm time to 9.15am and the arm time to 5.30pm the code would look like this

Alarm.alarmRepeat(9,15,0,MorningAlarm);  // DISARM time
Alarm.alarmRepeat(17,30,0,EveningAlarm);  // ARM time

If you do not want the alarm to arm and disarm automatically put // in front of the 2 lines and they wont be used.

//Alarm.alarmRepeat(6,00,0,MorningAlarm);  // DISARM time
//Alarm.alarmRepeat(22,15,0,EveningAlarm); //Arm time

The time the alarm beeper sounds for can be changed by modifying line 22

const long interval = 120000; //for millis delay for length of time alarm sounds

The interval is in milliseconds so 120000 = 120 seconds, changing 120000 to 30000 would make the alarm sound for 30 seconds.

A solenoid to run a siren, strobe light, high volume beeper etc can be also be wired to pin 7 or pin 9 and will run for the "interval" as set above. Bear in mind the maximum load for an Arduino pin should not exceed 40mA.

Step 9: Additional Notes

When selecting a 433 or 315 MHz receiver module for Arduino you should pick the frequency to match the alarm sensors you intend to use. I suggest buying a module that comes with a small spiral helical antennae for best performance, alternatively a 17.3mm long straight wire antennae also increases performance.

With the 16x2 LCD module you must use a 4 pin I2C LCD to use the instructions and code I provide here, it could be made with a 16 pin standard LCD but it will not work with the wiring or code here.

Wireless alarm reed switches, motion sensors and remote key fobs should be 433Mhz or 315Mhz to match with the receiver you intend to use and should use PT2262 or EV1527 coding.

The alarm is expandable and adaptable, I have already added an SD card to record when sensors are triggered, modified the LCD to only be lit when a button is held and added a 100dB siren, but have not included details here to keep the article as short and simple as possible. I hope sharing the work I have done on this alarm is of some use to others.

Happy to answer any questions.