Dummy Security Camera With Spark.io

by FunWithBots in Circuits > Gadgets

2013 Views, 12 Favorites, 0 Comments

Dummy Security Camera With Spark.io

final 01.jpg

Security Cameras can get very expensive. I took an old bullet camera housing, added a spark.io Core with a Sparkbutton and a PIR (Passive infrared) sensor to make it respond to detected motion. When the PIR alerts, the LED ring on the Sparkbutton starts pulsing red. In standby mode, a slow chasing algorithm loops blue. Lets build it!

BOM

spark bom 1.jpg

1 Spark Core

1 Spark Button

1 Analog PIR sensor

1 battery pack (or other power source for the USB cable)

1 camera housing and mounting bracket

3 M/F jumper wires

Binding the Spark Core

Spark Screenshot.jpg

It's a bit of trick getting your Core up and running. You need to be sure you have a solid wifi connection when you try to bind it to your account. Here's a summary of the steps.

  1. Create a free account at http://spark.io
  2. Install the app on your android or iphone
  3. Bind the Core to your account using the app. You'll need the SSID and passcode for your hotspot.

Once you have the heartbeat LED signal, you're good to go. A more detailed installation guide and troubleshooting help are at http://docs.spark.io/start/.

Wire Up the Circuit

spark.jpg
pir.jpg

Connect the power, ground and signal leads to the PIR sensor

  • Red - Vcc to 3V3 filtered
  • Black - Gnd to Ground
  • Blue - Out to pin D7

The PIR outputs a high (3V) signal until it detects motion. Upon detection, it drives the digital input low triggering the sketch to execute alert mode.

Load the Sketch

spark upload.jpg

You can find the latest revision of the code here.

/*<br>Created to read either button 2 or a PIR sensor to trigger an alert mode on the SparkButton.
Copyright 2015, Bill Shaw. 
This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. To view a copy of this license, visit <a href="http://creativecommons.org/licenses/by-sa/4.0/." rel="nofollow"> http://creativecommons.org/licenses/by-sa/4.0/.</a>
Rev 0.1 01/05/2015 BS Initial release
*/
#include "SparkButton/SparkButton.h"
#include "math.h"    
SparkButton b = SparkButton();
int ledPos = 0;
int PIR = D7;
void setup() {
    // Tell b to get everything ready to go
    b.begin();
    pinMode(PIR, INPUT);
}
void loop(){
    
    if (b.buttonOn(2) || !digitalRead(PIR)) {  //alert mode on button press or PIR activation
//        for(int i=1; i<13; i++) {
//            b.ledOn(i, 127,0,0);
//            delay(10);
        b.allLedsOn(127,0,0);
//        }
//        for(int i=1; i<13; i++) {
//            b.ledOff(i);
//            delay(10);
//        }
        delay(80);
        b.allLedsOff();
        delay(80);
    }
    else { //standby mode
        ledPos += 1;
        ledPos %= 12;  //modulo
           b.ledOn(ledPos, 0, 20, 20); 
        // Now turn that LED on
        
        
        // Wait a mo'
        delay(160);
        
        // Turn the LEDs off
        b.ledOff(ledPos);
    
    }

}

Build It!

PIR Assembly 2.jpg
PIR Assembly.jpg
PIR on spark.jpg
20150114_000759.jpg

You'll need to mount the PIR in front of the SparkButton so it is facing through the glass in the front of the camera enclosure. Double sided foam tape works well. Mount this assembly inside of the enclosure and power it up.

I 3D printed a mount for the PIR sensor and to keep the entire assembly flush on the glass. You can download the STL files your self from https://github.com/funwithbots/Projects/tree/maste...

It will take the PIR sensor about 10 seconds to stabilize. Once it does, you should get a slow, chasing cyan light around the PIR. When the PIR detects motion, you'll see the ring start flashing all LEDs rapidly in red.

I powered the entire setup using the 6W Voltaic battery and solar panel.

Seal the enclosure and mount it somewhere where observers can clearly know they're being watched.