Amr Saleh
Published

Motion triggered security camera

This connected camera runs on 1Sheeld, IFTTT, and Dropbox

Full instructions provided2,671
Motion triggered security camera

Things used in this project

Hardware components

Android device
Android device
×1
1Sheeld
1Sheeld
×1
Ultrasonic distance sensor
×1

Story

Read more

Code

Code

Plain text
/* 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");
  }
}

Credits

Tarumiji

Posted by Amr Saleh

Comments