This is very easy to do and requires no soldering or advanced skills.
Here's 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 AliExpress.com. 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:
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 http://wirebeings.com/arduino-intruder-alarm.html
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:
https://www.arduino.cc/en/Main/ArduinoBoardYun
If you are using a Leonardo with an Iduino wifi shield follow the instructions here:
http://www.geeetech.com/wiki/index.php/Iduino_Yun_Shield
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:
http://wirebeings.com/arduino-intruder-alarm.html
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 number, 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....YOU'RE 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!
Comments