Inspiration: Home security systems are very expensive and sometimes do not function as intended. Sometimes something simple may happen such as you forgetting the lights on at home or there may be something more drastic such as a large temperature change or even intruder. Our solution aims to be a cheap alert system that would detect three parameters and offer an alert to the user.

What it does: Our project detects light, temperature and sounds and sends the necessary message to the user. Light sensors would be use to tell the user if they forgot their lights on and hence send an alert to the user. Temperature detection would be use to send drastic changes in temperature or sound to the user as alert messages which may include extreme cold in winter or extreme heat in summer. Sound detection would be used as a security system as it is configured to send alerts to the user once a certain decibel level is reached. Therefore very loud sounds such as breaking glass, shouting or even a gunshot may be detected and an alert sent to the user. These messages are all sent to the user's phone. If anything is wrong, there is a circuit with a red LED light that lights up whenever there is a situation. If the LED is off, the user gets no messages and everything is okay at home. Our project also associates user friendly colors with conditions for example heat is red and cold would be blue.

How we built it: We used an Arduino as well as a Grove Kit in order to obtain sensors. These sensors were connected to the Arduino and we also attached a breadboard that would receive an input from the Arduino. We coded the entire project and uploaded it unto the chip. We then used an adapter to transfer the input from the Arduino to our phones and tested the output to ensure it worked.

Challenges we ran into: Unfortunately there was a lack of hardware at our disposal. We wanted to implement bluetooth technology to send data to our phones without wires and even tweet weather alerts. However there was no bluetooth hardware components so we were unable to achieve this. Instead we just used an adapter to connect the arduino to our phone and show a test output. Testing was also an issue since we were not able to generate extreme cold and warm weathers so we had to change our code to test these parameters.

Accomplishments that we're proud of: We had very little experience in using Grove Kits and were able to figure out a way to implement our project. Also we were able to change our original idea due to there being a limitation of bluetooth and WiFi shield components.

What we learned: We learned how to use and code the sensors in a Grove Kit. We also improved our knowledge of Arduino and building circuits.

What's next for Home Automation and Security: Future improvements and Modifications to improvements would be using bluetooth and WiFi to send twitter alerts to people on the user's contact list. In the future we may also include more components to the circuit for example installing a remote button that can contact the police in the case of there being an intruder. We may also install other types of sensors such as touch sensors that may be placed on a welcome mat or door handle during long periods away from home.

Code:

include

include "rgb_lcd.h"

include

rgb_lcd lcd;

float temperature; //stores temperature int lightValue; //stores light value int soundValue; //stores sound value bool errorTemp = false; bool errorLight = false; bool errorSound = false; bool errorTempCold = false; bool errorTempHot = false; int lights = 0; int cold = 0; int hot = 0; int intruder = 0;

const int B = 4275;
const int R0 = 100000;

const int pinTempSensor = A0;
const int pinLightSensor = A1; const int pinSoundSensor = A2; const int pinLEDRed = 9; const int pinLEDGreen = 8;

void setup() { lcd.begin(16, 2); Serial.begin(9600); }

void loop() { temperature = 0; temp(); //function that detects the temperature light(); //function that detects light sound(); //function that detects sounds lightMessages(); //function that checks conditions temperatureMessages(); //function that outputs everything to the user ok(); //function that ensures all parameters are correctly calculated and tested serialErrors(); //function that checks logic and sends data to output function }

void light() { lightValue = analogRead(pinLightSensor); }

void sound() { soundValue = analogRead(pinSoundSensor); //Serial.println(soundValue); if(soundValue > 500) { errorSound = true; } else { errorSound = false; } }

void temp() { int a = analogRead(pinTempSensor); float R = 1023.0/((float)a)-1.0; R = R0*R; temperature = 1.0/(log(R/R0)/B+1/298.15)-303.14; // convert to temperature via datasheet delay(100); }

void blinkLED() { analogWrite(pinLEDRed, HIGH); delay(500); analogWrite(pinLEDRed, LOW); delay(500); }

void greenLED() { analogWrite(pinLEDGreen, HIGH); }

void screenRed() { lcd.setRGB(255,0,0); }

void screenBlue() { lcd.setRGB(0,0,255); }

void screenNormal() { lcd.setRGB(0,50,50); }

void serialErrors() { if (errorSound == false) { if (errorLight == true) { cold = 0; hot = 0; intruder = 0; if(lights == 0) {
Serial.println("Important: Lights are on at home!"); lights++; } else { Serial.print(""); } } else if (errorTempCold == true) { lights = 0; hot = 0; intruder = 0; if(cold == 0) { Serial.println("Important: The temperature at home is low!"); cold++; } else { Serial.print(""); } } else if (errorTempHot == true) { lights = 0; cold = 0; intruder = 0; if(hot == 0){ Serial.println("Important: The temperature at home is high!"); hot++; } else { Serial.print(""); } } } else { lights = 0; cold = 0; hot = 0; if(intruder == 0) { Serial.println("IMPORTANT: There was a very loud sound at home! Possible intruder."); intruder++; } else { Serial.print(""); } } }

void ok() { if(errorSound == false) { if (errorTemp == false && errorLight == false) { lcd.clear(); analogWrite(pinLEDGreen, HIGH); lcd.setCursor(0, 0); lcd.print("Everything is ok"); lcd.setCursor(1,1); lcd.print("Temp = "); lcd.print(temperature); lcd.print("C"); screenNormal(); } } }

void lightMessages() { if(lightValue > 500) { lcd.clear(); lcd.setCursor(0, 0); lcd.print("Lights are on!"); screenRed(); blinkLED(); errorLight = true; } else { errorLight = false; } }

void temperatureMessages() { if (errorSound == false) { if (temperature < 20) { lcd.clear(); lcd.setCursor(0,1); lcd.print("Extreme Cold!"); screenBlue(); blinkLED(); errorTemp = true; errorTempCold = true; errorTempHot = false; } else if (temperature > 30) { lcd.clear();
lcd.setCursor(0,1); lcd.print("Extreme Heat!"); screenRed(); blinkLED(); errorTemp = true; errorTempHot = true; errorTempCold = false; } else { errorTemp = false; errorTempHot = false; errorTempCold = false; } } else { lcd.clear(); lcd.setCursor(0,0); lcd.print("LOUD SOUND"); lcd.setCursor(0,1); lcd.print("DETECTED!"); screenRed(); blinkLED(); delay(5000); if (soundValue < 500) { errorSound = false; } else { errorSound = true; } } }

Built With

Share this project:

Updates