DIY Home Security + Automation Using a Raspberry Pi

This instructable should help you set up a DIY home security + automation system that uses 433Mhz door/window sensors, 433 MHz PIR motion sensors and webcams to monitor your home and 433MHz outlets to control lights etc.

The original project was completed in phases and published on my personal blog at This instructable is aimed at putting all that information together in one place.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Hardware Component List

The total hardware cost was approximately $85 (minus the Raspberry Pi)

Step 2: Hardware Setup

1. To increase the range of the transmitter and receiver, solder a 17cm single core wire to the ANT (antenna) connection on the transmitter and receiver.

2. Connect the DATA output of the transmitter to GPIO 17 of the Raspberry Pi (rev B in my case)Connect the DATA output of the transmitter to GPIO 17 of the Raspberry Pi (rev B in my case)

3. The 433MHz receiver output is 5V so use a simple voltage divider circuit (220 ohm/440 ohm) to drop the voltage down to 3.3V. Connect the output of the voltage divider to GPIO 21

4. Connect the VCC/GND pins of the 433MHz Rx/Tx to the Raspberry Pi 5V/GND lines

5. The 4x3 membrane keypad is connected as follows:

• Pin 7 on the keypad is ROW 0- GPIO 18
• Pin 6 on the keypad is ROW 1- GPIO 23
• Pin 5 on the keypad is ROW 2- GPIO 24
• Pin 4 on the keypad is ROW 3- GPIO 25
• Pin 3 on the keypad is COL 0 - GPIO 4
• Pin 2 on the keypad is COL 1 - GPIO 22
• Pin 1 on the keypad is COL 2 - GPIO 10

Step 3: Install Prerequisite Software + Source Code

1. Install WebIOPi from here:
2. Install motion for webcam motion detection: sudo apt-get install motion

• For details on how to setup motion, take a look at my post here:

3. I found this article on using 433MHz Tx-Rx modules with the raspberry pi. Follow the instructions here to install the 433Utils package.

• Run RFSniffer and trigger all the 433MHz door/window/PIR motion sensors that you want to use and note down the received code. This will be used to trigger the alarm in your system.

4. Clone my git repo for the source code from here: to any directory

5. Go back to the directory where you installed the code from the ninjablocks website in step #3

  • Modify RFSniffer.cpp to write to trigger.txt in the cloned repo, if the code matches your specific transmitters:

if (value == 0) { printf("Unknown encoding"); } else { printf("Received %i\n", mySwitch.getReceivedValue() ); if (mySwitch.getReceivedValue() == enter your transmitter code here ) { system("sudo echo -n 1 > path_to_git_code/trigger.txt"); } }

• Modify send.cpp line 24 to change the pulse length to 207. The wireless outlet controls had a different pulse length vs the default one. • Run a "make" in the RPi_utils directory to create an updated executable.

6. Modify the following in the directory cloned from git in step #4 -
• Modify the root directory where you have cloned the git repo above based on the variable config['home_alarm_git_dir']
• Modify the directory where you have cloned the 433MHz code from te ninjablocks website mentioned in #3 above based on the variable config['rf433_dir']
• Modify the passcode to arm/disarm the system from the keypad. Default is 123
• Modify the RF outlet codes to switch the outlets on/off. I used 3 switches in this project
• Modify the RF siren enable/disable code
• If you want to use a webcam for motion enable set the variable config['webcam_motion_enable'] = 1 - Modify your destination email via the dest variable . You can also customize your email subject/message in this script. I am using smttp for sending the email. See this post for instructions on how to set it up

Step 4: Code Flow

The diagrams show the flow of the 2 main scripts used here:

• - High level control script. Checks for the system arm/disarm based on user triggered actions on the webserver or the keypad
• - Main script that waits for the system to be armed and triggers the 433 MHz RF Sniffer script. This script waits for transmissions from the door/window sensors or PIR motion sensors and triggers the siren if any of the sensors are triggered.

Step 5: Launch the Script and Test Out the System

  1. Launch the script - webserver_port here is the port of your choice defined in where the web based user interface pictured above will run.
    • sudo python -m webiopi -d webserver_port

  2. Go to the webpage - RaspberryPi_IP_Address:webserver_port
  3. Click on the switch 1/2/3 to verify that the outlets turn on/off
  4. Click on the System Arm switch and wait a minute till the system is fully armed
    • To test out the RF siren and only trigger the flashing lights (without triggering the sound) disconnect the piezo siren using the connector labelled in the image of the siren above.
    • Open/close the doors/windows where you have attached the RF door/window sensors - Verify that the alarm is triggered and you get an email. Disarm the system using the webpage switch or the keypad code.
    • Move in front of the RF PIR sensors and repeat the above experiment.

If everything above checks out, you are good to go!

Home Automation

Participated in the
Home Automation

Be the First to Share


    • Instrument Contest

      Instrument Contest
    • Make it Glow Contest

      Make it Glow Contest
    • STEM Contest

      STEM Contest

    13 Discussions


    2 years ago

    Hi, Thx for sharing your project! I giving it a try. Have a question...Is there support for my ever changing outside IP address? or is it ok for me to go ahead and use like duckdns and if I do this do I have to incorporate this at all into yours or Webiopi code or can I just run it on the pi by itself? Hope the question was clear. I need to be able to use a domain cause my outside ip is always changing.

    any help would be appreciated



    Reply 3 years ago

    You are right - you may blow out the pins @5V -> the voltage from the receiver needs to be brought down to 3.3V. See below for the schematic for doing so with a breadboard.


    Reply 3 years ago

    Here is the image directly:


    Reply 3 years ago

    Yes you are right. I somehow missed including that. I had it in my original blog post here:

    1. The outputs of the receiver are 5V TTL and I wasn't so pleased connecting them directly to 3.3 V tolerant Pi inputs.So I used a simple voltage divider circuit (220 ohm/440 ohm) to drop the voltage to something around 3.3 V.

    I will fix the instructable. Thanks for pointing it out.


    Reply 4 years ago

    These specific ones only send out a code when contact is lost, so only on door/window open action.


    4 years ago

    What is the effective transmit range of 433MhZ connection you used please?

    3 replies

    Reply 4 years ago on Introduction

    With a 17cm single core wire antenna attached to the transmitter, I can control outlets that are a 100-200 ft away (through walls). I haven't tested how far they go because it covered the area I wanted. The specs for the hardware say that it should be able to cover ~600ft (probably without any obstructions).


    Reply 4 years ago on Introduction

    100-200 ft? What sort of walls were they? Even our interior walls are ceiling to floor shiplap on both sides.


    Reply 4 years ago

    That's right. The walls here are drywall on wood frames so they are not solid through. I have it going through at least 1-2 walls.