Project tutorial
Smart Home Automation And Security System Using 1Sheeld

Smart Home Automation And Security System Using 1Sheeld © GPL3+

We built a smart home automation and security system using our lovely 1Sheeld board and some sensors and some cool stuff.

  • 8,661 views
  • 6 comments
  • 31 respects

Components and supplies

Necessary tools and machines

Lasercutter
Laser cutter (generic)

About this project

Hey Overview

The story begins from here.

We Decided To Make This Project Because It Was A Great Move To Build Such This All Things Together, This Project Will Help You Understanding A lot Of Concepts And You Will Gain A Good Experience So Let's Start Learning How To Build This Cool Stuff :)

How Our Project Works :

This Project Makes You Able To Control All Your House Lights With Your Voice Commands Or With An SMS :) , Not This Only It Also Was A Security System , When Any Stranger Enters Your Home While You Are Sleeping Or Out Your Home It Sends An Email To You Says That There Is A Stranger Entered Your Home And An Alarm System ( Buzzer ) Will Work At Your Home , Also When You Send An SMS To Turn On Or Off The Lights It Sends To You An Email To Told You That The Order Was Executed , Also If The Tmp Sensor Senses That The Temp. Is More Than 35 An Alarm ( Buzzer ) Will Work At Yor Home And The System Will Send To You An Email Says That The Temp. Was Higher Than 35 .

NOTE : Don't Forget To Say Jarvis Before Any Command You Want To Give :) To Make The System Able To Hear Your Command .

NOTE : After Any Command You Give To The System Jarvis Will Respond To You :) Like You Are Talking With Your Real Assistant .

NOTE : To Turn ON The Security System Give Your Smartphone A Voice Command ( security on ) , To Turn OFF The Security System Say ( security off )

let's know more about 1sheeld:

1Sheeld turns your smartphone into 40 different Arduino shields. So we don't have to buy shields for Arduino as we have them in our smartphone.

This Is The Reason Behind Why We Use The 1Sheeld Board you don’t need to buy any sensors because you already have them in your smartphone.

If You Want More About How To getting Started With 1Sheeld Click Here

First Thing You need To Take The CAD File Which We Have Uploaded And Cut It With The Laser Cutting Machine .

  • Then You Need Place The Magnetic Door Switch Sensor On Your Door Like This
  • It Was A Digital Sensor So It Will Return A Digital Valuo 0 OR 1
  • You Need To Calibrate Your Sensor Before Using It To Know What Is The Reading When It Was Open And When It Was Close .

The AC Lamps

  • Then You Need To Cut On The Walls To Put The Lamps In Their Specific Places .
  • Connect All The Lamps Wires In Parallel .

The Temperature Sensor

  • Iam Using LM35DZ Which Has 3 Legs
  • +V Is Connected To 5V On The Arduino
  • GND To The Ground On The Arduino
  • OUTPUT To the Pin A0 On The Arduino Which Will Give Us The Reading

How to use 1sheeld?

1- Stack 1Sheeld on top of your Arduino board, and write the code using 1Sheeld library.

2 - Upload The Code On The Arduino Using Arduino IDE ( You Can Download Arduino IDE From Here )

3 - Note: Make sure that the UART switch is on the Uploading mode.

4 - After Finishing Uploading The Code Bring The Switch Back To The Operating Mode

Note : Don’t forget! If you don’t switch the UART Switch back to the operating mode your project will not work properly as you will have no communication between 1Sheeld and the Arduino board.

The 1Sheeld Application :

  • Open Your 1Sheeld Application You Can Download It From here
  • Then Open Your Application And Connect With Your Board you will be required to enter the pairing code (the default pairing code is 1234) and connect to 1Sheeld via bluetooth.
  • Then Choose The Shields Which We Will Use ( SMS , Voice Recognition , Text To Speech , Clock , Email ) .
  • Now Try Your Work :)

NOTE : We Made Our Own Female Jarvis :D

Make Your Own Jarvis .

Code

Smart Home Automation & Security SystemArduino
/*
 * Smart Home Automation And Security System Team SADEE
 * EMAIL : ahmedebrahemua@yahoo.com
 * For More Projects Like Our FB Page :  https://www.facebook.com/Scientific-%D9%90Association-of-the-Department-of-Electrical-Engineering-At-ACU-260274217766395/
 */


#define CUSTOM_SETTINGS                  //Used To Define A Specific Shields That We Will Work With To Save The Arduino memory
#define INCLUDE_VOICE_RECOGNIZER_SHIELD   //Help Us To Communicate With The 1 Sheeld Board With Voice Commands
#define INCLUDE_TEXT_TO_SPEECH_SHIELD      
#define INCLUDE_CLOCK_SHIELD
#define INCLUDE_SMS_SHIELD
#define INCLUDE_EMAIL_SHIELD        

#include <LiquidCrystal.h>
#include <OneSheeld.h>

int minutes,hours;                 //Variables That Will Save The Hour And Minutes In It 
String strh;                        //Will Use This Line To Convert The Int Value That The Clock reads To String
String strm;
char h[4];
char m[4];
LiquidCrystal lcd(2,3,4,5,6,7);

#define receptionLamp A1    // This IS The Reception Relay 
#define bedRoomLamp A2          // This Is The BedRoom 
#define pathRoomLamp A3        // This IS The Bathroom 
#define balaconyLamp A4        // This IS The Kitchen 

const char timeCommand[] = "what time is it";       //The Commands Which We Will Say To The 1Sheeld To Perform Its Task
const char receptionCommandOn[] = "reception on";    
const char receptionCommandOff[] = "reception of";
const char whatsUp[] = "good morning";
const char pathRoomCommandOn[] = "bathroom on";
const char pathRoomCommandOff[] = "bathroom off";
const char balaconyCommandOn[] = "kitchen on";
const char balaconyCommandOff[] = "kitchen off";
const char bedRoomCommandOn[] = "bedroom on";
const char bedRoomCommandOff[] = "bedroom off";
const char lightsOn[] = "on";       //This IS For SMS Shield When We Send An SMS Contains (Lights on) The Lights Will Turn On
const char lightsOff[] = "off";     //This IS For SMS Shield When We Send An SMS Contains (Lights ooff) The Lights Will Turn off
//********************************************************************************************************
const char securityModeOn[] = "security on";    //This Is For The Security System When We Say (Security on) Then We triggered The Security System Anyone Will Break The System The Alarm Will Work
const char securityModeOff[] ="security off";    // Turning Off The Security System Anyone Breaks The Security System The Alarm Will Not Work
//********************************************************************************************************
const char mainCommand[] = "jarvis";               //We Say jarvis Before Any Voice Command To Make The System Hearing me 
String noon;
//#define tmp A0                 //For The TMP Sensor We Use LM35DZ
//int voltage,degree;             //The Variables Which Will Contain The Different Voltages During The Changing Of Temperatures , And The Degree In Celisus After A Simple Mathematical EQ. 

byte smile[] = {                     //Making A Smile Symbol On The Liquid crystal Screen
  B00000,
  B01001,
  B01001,
  B00000,
  B00000,
  B10001,
  B01110,
  B00000,
};

#define magneticReception 8          //The MAgnetic Switch For The Reception
#define magneticBalacony 9           //The MAgnetic Switch For The Balacony
int buzzer2 = 10;     // This Buzzer iS for temperature sensor
      //D11 Was Free;
int buzzer1 = A5;     //This Buzzer Is For The Magnetic Switches If Someone Breaks The Security System This Will Buzzer Will Work
int magneticReceptionState;       //Variable Will Contain The Reading Of The MAgnetic Switch If It Was 1 Or 0
int magneticBalaconyState;
int state =0;                        // This For Jarvis
bool security;                        // This For the Security System 

void setup() {


noTone(buzzer1);
noTone(buzzer2);

//analogReference(INTERNAL);          //Reference For The TMP Sensor To Be Accurate 1.1 Voltage

digitalWrite(receptionLamp,HIGH);
digitalWrite(bedRoomLamp,HIGH);
digitalWrite(pathRoomLamp,HIGH);
digitalWrite(balaconyLamp,HIGH);


//passState = false;

lcd.begin(16,2);          //Begin The LCD 
OneSheeld.begin();             //Begin the OneSheeld Board

pinMode(receptionLamp,OUTPUT);           
pinMode(bedRoomLamp,OUTPUT);
pinMode(balaconyLamp,OUTPUT);
pinMode(pathRoomLamp,OUTPUT);
pinMode(buzzer1,OUTPUT);       //for magnetic switch
pinMode(magneticReception,INPUT_PULLUP);        //We Use The PULLUP Resistor Which Builtin In The Board
pinMode(magneticBalacony,INPUT_PULLUP);
//pinMode(tmp,INPUT);
pinMode(buzzer2,OUTPUT);  //for temperature sensor
lcd.createChar(0,smile);

lcd.clear();
lcd.setCursor(0,0);
lcd.print("Welcome To The ");
delay(4000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Smart Home");
lcd.setCursor(0,1);
lcd.print("Automation And ");
delay(4000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Security System");
delay(4000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("CALIBRATING....");
delay(10000);
if(!VoiceRecognition.isNewCommandReceived())           //If there IS No Voice Commands Print This WOrds
{
    lcd.clear();
    lcd.setCursor(1,0);
    lcd.print("We Are Here To");
    lcd.setCursor(4,1);
    lcd.print("HELP You");
    
}
security =false;

}

void loop() {


Clock.queryDateAndTime();             //This Function for Quering The Date And Time USing The Clock Shield On The OneSheeld Board
SMS.setOnSmsReceive(&MyFunction);             //This Function For The SMS 

minutes = Clock.getMinutes();
hours = Clock.getHours();

if(hours>12)                  //We Doing This To Change The Time from 24 Hours System to 12 Hours System And To know Is It AM Or PM
{
  hours-=12;
  noon="P M";
}
else
{
 noon="A M";  
}

strh = String(hours);
strm = String(minutes);
strh.toCharArray(h,4);                          //Converting The Hours Which We Convert To String To be A Char Array
strm.toCharArray(m,4);


VoiceRecognition.start();                  //Start The Voice Recognition Shield
OneSheeld.delay(8000);                       //Delay To make The orders Then Start Agaim
if(VoiceRecognition.isNewCommandReceived())
{
  if(!strcmp(mainCommand,VoiceRecognition.getLastCommand()))                  //Compare The Last Voice Command With The Main Command Which is "Alexa" 
  {
    TextToSpeech.say("yes sir");                    //This Function Is To Order The Text To Speech Shield To Perform Its Task 
    lcd.clear();
    lcd.setCursor(8,0);
    lcd.write(byte(0));
    state = 1;
  }

  
  if(!strcmp(receptionCommandOn,VoiceRecognition.getLastCommand())&&state==1)        //Compare The Two Strings The Last Command Received And The String That I made Before
  {
    TextToSpeech.say("ok sir lamp in the reception is on");              
    OneSheeld.delay(2500);
    digitalWrite(receptionLamp,LOW);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("The Hall Lamp Is");
    lcd.setCursor(8,1);
    lcd.print("ON");
    state =0;
  
  }
  else if (!strcmp(receptionCommandOff,VoiceRecognition.getLastCommand())&&state==1)
  {    
    TextToSpeech.say("ok sir lamp in the reception is off");
    OneSheeld.delay(2500);
    digitalWrite(receptionLamp,HIGH);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("The Hall Lamp Is");
    lcd.setCursor(7,1);
    lcd.print("OFF");
    state =0;
  }
  else if (!strcmp(bedRoomCommandOn,VoiceRecognition.getLastCommand())&&state==1)
  {
    TextToSpeech.say("ok sir lamp in the bedRoom is on");
    OneSheeld.delay(2500);
    digitalWrite(bedRoomLamp,LOW);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("The BedRoom");
    lcd.setCursor(0,1);
    lcd.print("lamp Is: ON");
    state =0;
  }

  else if (!strcmp(bedRoomCommandOff,VoiceRecognition.getLastCommand())&&state==1)
  {
    TextToSpeech.say("ok sir lamp in the bedroom is off");
    OneSheeld.delay(2500);
    digitalWrite(bedRoomLamp,HIGH);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("The Bedroom");
    lcd.setCursor(0,1);
    lcd.print("lamp Is: OFF");
    state=0;
  }
  else if (!strcmp(pathRoomCommandOn,VoiceRecognition.getLastCommand())&&state==1)
  {
    TextToSpeech.say("ok sir lamp in the bathroom is on");
    OneSheeld.delay(2500);
    digitalWrite(pathRoomLamp,LOW);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("The Bathroom");
    lcd.setCursor(0,1);
    lcd.print("lamp Is: ON");
    state=0;
  }

  else if (!strcmp(pathRoomCommandOff,VoiceRecognition.getLastCommand())&&state==1)
  {
    TextToSpeech.say("ok sir lamp in the bathroom is off");
    OneSheeld.delay(2500);
    digitalWrite(pathRoomLamp,HIGH);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("The Bathroom");
    lcd.setCursor(0,1);
    lcd.print("lamp Is: OFF");
  }

  else if (!strcmp(balaconyCommandOn,VoiceRecognition.getLastCommand())&&state==1)
  {
    TextToSpeech.say("ok sir lamp in the kitchen is on");
    OneSheeld.delay(2500);
    digitalWrite(balaconyLamp,LOW);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("The Kitchen");
    lcd.setCursor(0,1);
    lcd.print("Lamp Is: ON");
    state=0;
  }

  else if (!strcmp(balaconyCommandOff,VoiceRecognition.getLastCommand())&&state==1)
  {
    TextToSpeech.say("ok sir lamp in the kitchen is off");
    OneSheeld.delay(2500);
    digitalWrite(balaconyLamp,HIGH);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("The Kitchen");
    lcd.setCursor(0,1);
    lcd.print("Lamp Is: OFF");
    state=0;
  }
  else if(!strcmp(whatsUp,VoiceRecognition.getLastCommand())&&state==1)
  {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Good Morning :)");
    lcd.setCursor(0,1);
    lcd.print("Its A Good Day"); 
    TextToSpeech.say("good morning sir");
    OneSheeld.delay(1500);
    TextToSpeech.say("time in cairo is");
    OneSheeld.delay(1500);
    TextToSpeech.say(h);
    OneSheeld.delay(1000);
    TextToSpeech.say(m);
    OneSheeld.delay(1000);
    TextToSpeech.say(noon);
    state=0;
  }
  else if(!strcmp(timeCommand,VoiceRecognition.getLastCommand())&&state==1)
  {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Time In Cairo Is");
    lcd.setCursor(0,1);
    lcd.print(h);
    lcd.print(":");
    lcd.print(m);
    lcd.print(" ");
    lcd.print(noon);
    TextToSpeech.say("time in cairo is");
    OneSheeld.delay(1500);
    TextToSpeech.say(h);
    OneSheeld.delay(1000);
    TextToSpeech.say(m);
    OneSheeld.delay(1000);
    TextToSpeech.say(noon);
    state=0;
    
  }

  //************************************************************************************************


 else if (!strcmp(securityModeOn,VoiceRecognition.getLastCommand())&&state==1)
  {
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.write("Ok,Sir Feel Safe");
  lcd.setCursor(0,1);
  lcd.write("Security Mode");
  delay(200);
  TextToSpeech.say("security system was triggered");
  security=true;
  state=0;
  }

else if (!strcmp(securityModeOff,VoiceRecognition.getLastCommand())&&state==1)
  {
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.write("Ok,Sir Security");
  lcd.setCursor(0,1);
  lcd.write("is OFF");
  delay(200);
  TextToSpeech.say("security system was turned off");
  security=false;
  state=0;
  }  
 }


//**********************************************************Security System ***********************************************************


  

magneticReceptionState = digitalRead(magneticReception);
magneticBalaconyState = digitalRead(magneticBalacony);



if(security == true)
{
  if(magneticReceptionState == HIGH || magneticBalaconyState == HIGH)    //If Someone Opens The Door While The Security System Was Working It Will Alarm
  {
    tone(buzzer1 ,1500);
    Email.send("ahmedebrahemua@yahoo.com","Home Security System","Someone Entered Your Home , Be Carefull");
    OneSheeld.delay(3500);
  }
  else if (magneticReceptionState == LOW || magneticBalaconyState == LOW)
  {
    noTone(buzzer1);
  }

}

else if (security == false)
{
  noTone(buzzer1);
}
/*voltage = analogRead(tmp);
  voltage = voltage * 1100 / 1024;
  degree = voltage / 10;

  if(degree >= 35)
  {
    tone(buzzer2,1500);
    Email.send("ahmedebrahemua@yahoo.com","Home Security System","The Temperature In The Kitchen IS Higher Than 45 , Be Carefull");
    OneSheeld.delay(5000);
  }
  else if (degree<25)
  {
    noTone(buzzer2);
  }*/
}

//*******************************************************************************************************************************

void MyFunction(char* phoneNumber , char* messageBody)            // SMS Function ()
{
if(!strcmp(lightsOn,messageBody))                //If We Send "lights on" As SMS All the Lights Will Turn On
{
  digitalWrite(receptionLamp,LOW);
  delay(500);
  digitalWrite(pathRoomLamp,LOW);
  delay(500);
  digitalWrite(bedRoomLamp,LOW);
  delay(500);
  digitalWrite(balaconyLamp,LOW);
  delay(500); 
  TextToSpeech.say("all lights was turned on");
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("All Lights is ON");
  delay(300);
  Email.send("ahmedebrahemua@yahoo.com","Home Security System"," all Lights Were Turned ON");
  OneSheeld.delay(3500);

}
else if(!strcmp(lightsOff,messageBody))                    //If We Send "lights off" As SMS All the Lights Will Turn Off
{
  digitalWrite(receptionLamp,HIGH);
  delay(500);
  digitalWrite(pathRoomLamp,HIGH);
  delay(500);
  digitalWrite(bedRoomLamp,HIGH);
  delay(500);
  digitalWrite(balaconyLamp,HIGH);
  delay(500);
  TextToSpeech.say("all lights was turned off");
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("All Lights Is OFF");
  delay(300);
  Email.send("ahmedebrahemua@yahoo.com","Home Security System"," all Were Turned OFF ");
  OneSheeld.delay(3500);
}
}

Custom parts and enclosures

Lasser Cutting Drawwing1
drawing_lasser_cutting_lvvsN9X9Xg.dwg

Schematics

Relay And AC Lamps Connections
Relay connections zs3g2nkdyk
the rest of the components
Components 2 af7jfzvato

Comments

Similar projects you might like

Android App-Based Home Automation System Using IOT

Project tutorial by Team Autoshack

  • 43,264 views
  • 21 comments
  • 122 respects

Octopod: Smart IoT Home/Industry Automation Project

Project tutorial by Saksham Bhutani

  • 11,784 views
  • 9 comments
  • 39 respects

Security System With 1Sheeld

Project showcase by nada abdelnaby mady

  • 2,048 views
  • 0 comments
  • 2 respects

Home Monitoring System and Smart Home Solution

Project showcase by Akash Kumar

  • 9,105 views
  • 0 comments
  • 26 respects

Home Security Automation Using 1Sheeld

Project showcase by Hussien Mohamed and Ahmed Ismail

  • 4,299 views
  • 0 comments
  • 6 respects

Control your Light System Using Smart Phone

Project tutorial by Ahmed Yassin

  • 43,586 views
  • 5 comments
  • 63 respects
Add projectSign up / Login