Did You Know?

Conventional farmers use around 300 different pesticides to grow foods that are sold in supermarkets everyday.

You'll need this at these restaurants in Toronto.

Arduino Intrusion Detection System

Ever wondered if people have been snooping around your room/house while you were out? This Arduino intrusion detection system will detect people entering your space and log it to Twitter. The PIR motion sensor has a range of about 5 feet and is tripped by the presence of body heat.
Parts:

  • 1 Arduino micro-controller
  • 1 Arduino Ethernet shield
  • 1 PIR motion sensor
  • 1 solderless bread-board (for prototyping)
  • Jumper wires (for prototyping)
  • 1 10K resistor
  • 1 LED (optional)
  • 1 Resistor for LED (optional)
  • A Twitter account and the Arduino Twitter library, or write your own :)


The prototype - Arduino with the Ethernet shield and PIR sensor. LED blinks when motion is detected. Also sends out a tweet. The choice of colors for the wires on the PIR is a bit confusing. The brown wire actually goes to ground, the black wire is the alarm pin. When the PIR sensor is inactive (open), the analog pin registers a value of ~ 900 on the Arduino. When it detects motion, the value is ~ 17.

Code

#include <Ethernet.h>
#include <Twitter.h>

byte mac[] = {
 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {
 192,168 , 0, 10 };
byte gateway[] = {
 192, 168, 0, 1 };
byte subnet[] = {
 255, 255, 255, 0 };

Twitter twitter("username:password"); //your Twitter username/password

char msg[32] ="Intruder Alert! ID: ";
//maps to the lowercase letters in ASCII
int lowerMin = 97;
int lowerMax = 122;

//PIR
int alarmPin = 0;
int alarmValue = 0;

int ledPin = 7;
int timer = 500;

void setup()
{ 
 Ethernet.begin(mac, ip, gateway, subnet);
 randomSeed(millis());
 Serial.begin(9600);
 pinMode(ledPin, OUTPUT);
 pinMode(alarmPin, INPUT);

 digitalWrite(ledPin, LOW);
   
 delay(1000);   

 Serial.println("connecting ...");

}

void loop()
{
 //read PIR

 alarmValue = analogRead(alarmPin);
 Serial.println (alarmValue);

 if (alarmValue < 100){
   generateID();
   twitter.post(msg);
   Serial.println(msg);
   blink();

 } 
 delay(timer);
}

//generate some pseudo random ID
void generateID()
{
 for (i=20; i<=31; i++)
 {
   msg[i] = random(lowerMin, lowerMax);
 }
}

void blink() {
 for(int i=0; i<3; i++) {
   digitalWrite(ledPin,HIGH);
   delay(200);
   digitalWrite(ledPin,LOW);
   delay(200);
 }
}