Intruder Alarm With Text Message Notification


Introduction: Intruder Alarm With Text Message Notification

About: My name is Matthew and I attend the University of Pittsburgh. Currently I am a senior, going for a bachelors in Information Science with a minor in CS. Current interests include augmented reality, virtual re...

This is very easy to do and requires no soldering or advanced skills.

Heres how it works:

Range sensor detects interruption in pings --->

Calls to Temboo via WIFI --->

Tells Twilio API to send text!

This tutorial shows you how to create an intruder alarm that sends you text message alerts when motion is detected. This may sound complicated but I am pretty confident any beginner with electronics should be able to do this just fine. The range sensor senses motion and tells your Arduino board to send the text . So you can leave the intruder detector at home, connected to your network, and still receive the SMS alerts, no matter where you are, as long as you have cell phone service.

This is a pretty quick and easy project, it takes maybe 45 minutes to complete. Parts can be had on Amazon for about $80-$90, or about $50 if you don't mind waiting from The main cost is an Arduino board with WIFI capabilities, however once you have that it can be used in tons of other projects and much more fun can be had...

Parts you will NEED:

-HC-SRO4 Range sensor

-Arduino Yun board or Leonardo with a WIFI shield

-4 jumper wires

-A mini breadboard (if you want)

-A 9V battery

-A 9V battery box with barrel plug and on/off switch

Links to parts and code can be found here:

Parts Links and Code

Step 1: Make These Connections and Test!

Connect your range sensor to your board as shown in the diagram here.

First we are going to test our range sensor and make sure its working.

Go to the first block of code here

and copy/paste it into the Arduino IDE.

Plug in your board and upload the sketch.

Pull up the serial monitor and make sure it is on 9600 BAUD.

You will see a string of numbers being printed

(this is the distance the closest object is away from the sensor in inches)

Anytime a large enough difference in pings is detected by the sensor it will print out "Intruder Detected" to the serial monitor.

Step 2: Get Your Board Connected to Your Wifi Network.

If you are using an Arduino Yun follow the instructions here:

If you are using a Leonardo with an Iduino wifi shield follow the instructions here:

To test a make sure it is connected to the same network as your computer you can use the terminal and do a quick LAN scan of your network or download a free program that will do it for you.

I use a Mac so I downloaded LanScan from the Mac store.

Step 3: Adding the Text Message Functionality.

Open the Arduino IDE and create a new sketch.

Copy and paste the second code block from here into the Arduino IDE:

Click the down arrow on the right side and hit create new tab.

Call it TembooAccount.h

Go back to the website above and copy and paste the last code block (the header file) into there.

Save it.

Now you need to create an Account on Temboo and on Twilio so you can add your information into the code.

Step 4: Add Your Twilio and Temboo Credentials to the Sketch.

Navigate to account settings in your Twilio account to find your Account SID and Auth Token (click the lock button to display it)

Add these to the main sketch inside the quotes where appropriate "***********"

Go back to the Twilio homepage and hit Account again. Hit phone numbers and this will give you your "Sent From" phone numer, add this to the code.

Finally, add the phone number that you want to receive the text, and customize the message if you want.

(Keep the phone numbers in this format or it won't work "+1*******" )

Now go to the header file and add your Temboo account information. Login to your Temboo account and hit Applications to get all this information.

Save it and hit upload.

Power your board with the 9V battery pack (hit the on switch) and pull up the serial monitor to make sure its working!!!

It may take 20 seconds or so to connect.

Step 5: And....YOUR DONE!

If your having problems where its not working correctly. Change the range of numbers in this highlighted statement in the picture here.

This statement means you will send the message if the distance to the closest object is less than 20 or greater than 500. Depending on where its located in your house and what the closest object is, those values will need to be played with in order to make it work properly.

This is best done in the testing stage where the code does not actually send the text message (the first code block on the website), because you only get a limited number of free calls to Temboo and the Twilio API, so don't waste them! Don't worry though the code actually prevents you from sending more than 10 calls before the board has to be unplugged and restarted.

Hit me up with any questions I would be glad to help!

Raspberry Pi Contest 2016

Runner Up in the
Raspberry Pi Contest 2016



    • Creative Misuse Contest

      Creative Misuse Contest
    • Water Contest

      Water Contest
    • Oil Contest

      Oil Contest

    15 Discussions

    sir what language program you used?

    What if using the Arduino uno but we add the nfc


    2 years ago

    what language did you used in this program sir?

    hey .. how i do this with arduino Uno

    why is this in the raspberry pi competition


    2 years ago

    nice instructable... i actually wanted to build something similar to this but involve a camera so i can view actually whats happening when it alarms me.. any idea on how to go about it using info from this instructable?

    1 reply

    I have no idea, I have not got to play with cameras yet, although I do want to soon.

    Parts cost 60-70$? oO I think you made a mistake there :)

    Nice guide!
    Thanks for the info

    5 replies

    Thanks for pointing that out! I meant to say from, it ends up being like $48 shipped to the states (it just doesn't include the 9V battery and takes like 3 weeks to arrive from China).

    Oh that's unfortunate...i live in Europe and usually we get free shipping from aliexpress. Thats why i was so surprised when i saw the price..I've done something similar using a Pro Micro ATmega32U4 ($3.85), of course the SR04($1.50) and an RGB Led and an old PC speaker. I'll use the ESP8266( for the wifi part($2.34).

    The first part is done. You can check my code here if you want:

    I've done it so that you can place it wherever you want and it will calibrate for the first 10 seconds checking the furthest object in view. Then it will use 'that' distance to do its 'intruder calculations' . For example if there is a -+10cm change in distance the alarm will go off using a nice Tone library that actually sounds like a siren, and the RGB light will flash with variety of colors.

    I am really glad you mentioned that ESP8266, it's supposed to be the Arduino killer, I need to get with the times and try that out.

    Actually, I am ordering one right now...

    while loops are awesome :P and so are the ESPs. Already bought 3. I use one on the balcony to get the temperature, and i'll use the other 2 with the intr. alarm. One with the SR04 to send triggers on a IoT page and the other one with a speaker to make a wifi portable speaker to sound the alarm :P
    I think in the end i'll make a laser triggered alarm though, using these:

    cause for some reason i dont really trust the SR04s. A continuous beam sounds more 'robust' than fluctuating waves.

    I was planning on making a smart trash can thing this weekend with the same range sensor and this is genius:

    while (x < 100); //Equalize values for 5 seconds

    I never thought to do that.

    Will it give alarm only if object of the size humans intrude? I mean, will it give alarm even if cat or rat intrudes?

    1 reply

    It will alarm if anything gets in front of the sensor, so it just depends on where you have it aimed.