For this project you will need the followings:
- An old android smartphone with a camera ( I use my HTC Sensation which is not being use any more because of its cracked screen, but still works perfectly )
- 1Sheeld and Arduino ( Of Course !)
- An Ultrasonic sensor ( can find one easily from ebay, or in cytron.com.my or you can use any IR sensor )
- An IFTTT account ( www.ifttt.com )
- A Dropbox account ( www.dropbox.com )
This project was inspired from this site : https://learn.adafruit.com/wireless-security-camera-arduino-yun/introduction , however it uses the Arduino Yun and a bit more complicated compared to this project since you need to wrap your head around linux.
The following depicts the overview of this project. An ultrasonic sensor (or IR sensor ) will be used to detect the presence of people walking. Once triggered, our smartphone camera which is located/hidden somewhere, will capture the image of the person triggering the sensor. This is done via 1sheeld and CT-Uno. Once the image is captured , it is then sent to IFTTT service via email and the image will be stored in a dropbox account. If you have installed dropbox app in your other phone, or on a computer, you will receive notification on these devices , anywhere in the world.
IFTTT Recipe
In order for this to work, first we need to create a recipe in IFTTT . Open up your IFTTT account and create the following recipe (you will also need to activate your dropbox account in IFTTT) :
Make sure that the email address that is being used matches the email address that is set in your 1Sheeld android app. Next set up the recipe's action to be as the following:
That's it were done with IFTTT settings. What this recipe does is, it will receive any email with image attachment and upload it into our dropbox account.
1Sheeld app settings
Open up your 1Sheeld android app, connect to 1Sheeld and choose Camera shield, Time Shield (for time-stamping purposes) and Email shield. Make sure that you set your email shield to use the email address that were already set in IFTTT account.
Hardware setup
Wiring the ultrasonic sensor to Arduino is straightforward, such as shown here: https://code.google.com/p/arduino-new-ping/. Figure below shows the overall setup of my hardware. One cool thing of using CT-Uno is that it uses micro-usb instead of mini-usb, so you can directly connect your Arduino to any smartphone battery pack/power bank.
Noticed that my android phone is being held by a phone holder. I can easily mount it on any smooth vertical surfaces with this setup.
Source code
Below is the source code for this project, upload it to your Arduino any you are ready to go.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | /* Motion Triggered Sscurity Cam via 1sheeld and IFTTT */ /* By Tarmizi Izzuddin */ #include <OneSheeld.h> #include <NewPing.h> #define TRIGGER_PIN 12 #define ECHO_PIN 11 #define MAX_DISTANCE 200 NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); String mailSubject,hourString,minuteString,time; boolean isMailSent = false; int hour,minute,second,day,month,year; void setup() { //begin onesheeld OneSheeld.begin(); Clock.begin(); } void loop() { //get current date and time hour = Clock.getHours(); minute = Clock.getMinutes(); second = Clock.getSeconds(); day = Clock.getDay(); month = Clock.getMonth(); year = Clock.getYear(); int uS = sonar.ping(); //construct Mail's Subject in the form CamFeed: xx-xx-xxxx xxxxhours mailSubject = "CamFeed: "; mailSubject += String(day); mailSubject += String("-"); mailSubject += String(month); mailSubject += String("-"); mailSubject += String(year); mailSubject += String(" "); mailSubject += String(hour); mailSubject += String(minute); mailSubject += String("hours"); /* Ultrasonic Sensor detect less thn 20 CM */ if(uS / US_ROUNDTRIP_CM < 50){ //Camera.setFlash(ON); Camera.setQuality(MID_QUALITY); Camera.rearCapture(); delay(35000); //more than ample time for image to be written on SD card //create trigger to IFTTT service while sending image as attachment Email.attachLastPicture("trigger@recipe.ifttt.com",mailSubject,"none"); } } |