Watchful Eye – Final

DSC_0033

For my final I designed a Watchful Eye. Taking inspiration from Evil Eyes that protect you from harm, this device is designed with the intent of helping friends and loved ones look-out for on another. It uses the Adafruit io and IFTTT platforms to active the device from your phone so that it can be looking for your safe return. Once you get home it will send a text to your friend that you have made it safely.

Please see my instructable below for more information:

https://www.instructables.com/id/Watchful-Eye/

IMG_0976IMG_0941IMG_0906Acrylic layout


#define LED_PIN 13
#define MOTION_PIN 23

//Including NeoPixel Library
#include

#define PIXELS_PIN 13
#define NUM_LEDS 16
#define BRIGHTNESS 50
#define PIXEL_TYPE NEO_GRB + NEO_KHZ800 // Type of the NeoPixels
Adafruit_NeoPixel strip = Adafruit_NeoPixel (NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);

//Including WIFI configuration
#define WIFI_SSID “Wifi name”
#define WIFI_PASS “Wifi_password”
#define IO_USERNAME “IO_username”
#define IO_KEY “IO_key”

#include “AdafruitIO_WiFi.h”
#include
#include

AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
#include
#include

// Variables for sensor, arming, feed
int current = 0;
int last = 0;
int armedSensor = 0;
int message = 0;

//Color variables
uint32_t low = strip.Color(0, 0, 0);
uint32_t high = strip.Color(41,196,204);
uint32_t armed = strip.Color(20,20,20);

// set up the ‘Watchful’ feed
AdafruitIO_Feed *Watchful = io.feed(“Watchful”);

//Wifi and IO set up code
void setup() {
//set up LEDs
strip.setBrightness(BRIGHTNESS);
for( int i = 0; i<NUM_LEDS; i++){
strip.setPixelColor(i, low);
}
strip.begin();
strip.show(); //Initialize all the pixels to “off”

//Set up sensor for reading
pinMode(MOTION_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);

// start the serial connection
Serial.begin(9600);

//connect to Wifi
WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED){
delay(500);
Serial.println(“Connecting to WiFi..”);
}

Serial.println(“Connected to the Wifi network”);
Serial.println(WiFi.localIP());
delay(500);
// connect to io.adafruit.com
Serial.print(“Connecting to Adafruit IO”);
io.connect();

// wait for a connection
while(io.status() < AIO_CONNECTED) { Serial.print(“.”); delay(500); } // we are connected Serial.println(); Serial.println(io.statusText()); } //Main functions void loop() { // io.run(); is required for all sketches. // it should always be present at the top of your loop // function. it keeps the client connected to // io.adafruit.com, and processes any incoming data. io.run(); // set up a message handler for the feed. // the handleMessage function (defined below) // will be called whenever a message is // received from adafruit io. Watchful->onMessage(handleMessage);

//Tells you device is on standby and pixels off
if(message == 0 && armedSensor == 0){
Serial.println(“Unarmed – Standby”);
for( int i = 0; i<NUM_LEDS; i++){
strip.setPixelColor(i, low);
//strip.show();
}
strip.show();
delay(10000);
}

//Arms sensor when widget button is pressed
if(message == 1 && armedSensor == 0){
Serial.println(“Arming sensor”);
for( int i = 0; i<NUM_LEDS; i++){
strip.setPixelColor(i, armed);
//strip.show();
}
strip.show();
armedSensor = 1;
delay(2000);
}

//If armed and senses motion, turn on LEDs
if(message == 1 && armedSensor == 1){
// grab the current state of the button.
if(digitalRead(MOTION_PIN) == HIGH){
current = 1;
Serial.println(“Motion detected!”);
for( int i = 0; i<NUM_LEDS; i++){
strip.setPixelColor(i, high);
//strip.show();
}
strip.show();
delay(5000);
Serial.println(“Disarming sensor”);
armedSensor = 0; //disarms
message = 0; //resets IO feed
for( int i = 0; i<NUM_LEDS; i++){ strip.setPixelColor(i, low); //strip.show(); } strip.show(); } delay(1000); armedSensor == 0; //Serial.println(“Unarmed”); } } // this function is called whenever a ‘Watchful’ message // is received from Adafruit IO. it was attached to // the Watchful feed in the setup() function above. void handleMessage(AdafruitIO_Data *data) { message = data->toInt();

//if (Watchful == 0){ //light up the LED
Serial.print(“received <- “);
Serial.println(message);
//}

}

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s