Introduction: Home Automation and Security Using 1Sheeld
This is a home automation and security system using 1Sheeld, The project works as the following :
when the user reaches his home door a pir sensor will sense him so a led will be turned on and then he has to say a specific password to can access his home if the password is right the entrance led and the music player will be turned on and if the password is wrong a buzzer will be turned on and the camera will capture a photo of him and tweeted it on twitter and for the kitchen their are a water and a gas sensor if they passed a certain threshold then for sure there is a problem so the 1 sheeld will send you a message on your mobile phone telling you that and if the problem is in the gas ratio the fan will be turned on to push that gas outside your home.
Step 1: Components and Tools Needed
In This project we are going to need :
- Smart phone with 1sheeld apllication
- 1Sheeld
- Arduino Uno/mega
- Water sensor
- Gas sensor
- Leds
- Lamp
- Fan
- Buzzer
- Relay module
- PIR sensor
Step 2: Code :
*this is a Home security project using Arduino UNO board and the ammazing 1sheild*/
@author Ahmed ismail , hussien mohamed @email mido-ahlawy-92@hotmail.com ,hussien.G750@gmail.com @ide Arduino IDE
* Include 1Sheeld library. */ #include <onesheeld.h></onesheeld.h>
#define CUSTOM_SETTINGS #define INCLUDE_VOICE_RECOGNIZER_SHIELD #define INCLUDE_LCD_SHIELD #define INCLUDE_MUSIC_PLAYER_SHIELD #define INCLUDE_TERMINAL_SHIELD #define INCLUDE_CAMERA_SHIELD #define INCLUDE_TWITTER_SHIELD #define INCLUDE_SMS_SHIELD
#define pir A0 #define gas A1 #define water A2 #define led1 11 #define led2 12 #define led3 10 #define lamp 13 #define fan 5 #define buzzer 9
/* Define some variables. */ int pirv = 0; int gasv = 0; int waterv = 0; boolean isMessageSent = false;
/* Voice command set by the user. */ const char openCommand[] = "open";
void setup() { /* Start communication. */ OneSheeld.begin(); /* Error Commands handiling. */ VoiceRecognition.setOnError(error);
VoiceRecognition.start();
pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(lamp, OUTPUT); pinMode(fan, OUTPUT); }
void loop() {
LCD.begin(); pirv = digitalRead(pir); gasv = digitalRead(gas); waterv = analogRead(water);
if (pirv == 1) { digitalWrite(led2, HIGH); LCD.print("say password"); delay(5000);
if (VoiceRecognition.isNewCommandReceived()) { /* Compare the open command. */ if (!strcmp(openCommand, VoiceRecognition.getLastCommand())) { digitalWrite(led2, LOW); digitalWrite(led1, HIGH); LCD.print("welcome home "); MusicPlayer.play(); delay(5000); digitalWrite(led1, LOW); }
else { digitalWrite(buzzer, HIGH); Camera.setFlash(ON); /* Take the picture. */ Camera.rearCapture(); /* Wait for 10 seconds. */ OneSheeld.delay(10000); /* Post the picture on Twitter. */ Twitter.tweetLastPicture("unauthinticated person"); } } }
if (waterv > 300 || gasv > 200) {
if (!isMessageSent) { /* Send the SMS. */ SMS.send("01094537336", "kitchen ALERT"); /* Set the flag. */ isMessageSent = true; } while (gasv > 200) { digitalWrite(fan, HIGH); } } }
/* Error checking function. */ void error(byte errorData) { /* Switch on error and print it on the terminal. */ switch (errorData) { case NETWORK_TIMEOUT_ERROR: Terminal.println("Network timeout"); break; case NETWORK_ERROR: Terminal.println("Network Error"); break; case AUDIO_ERROR: Terminal.println("Audio error"); break; case SERVER_ERROR: Terminal.println("No Server"); break; case SPEECH_TIMEOUT_ERROR: Terminal.println("Speech timeout"); break; case NO_MATCH_ERROR: Terminal.println("No match"); break; case RECOGNIZER_BUSY_ERROR: Terminal.println("Busy"); break; } }

Participated in the
Raspberry Pi Contest 2016
4 Comments
7 years ago
Great!
Reply 7 years ago
Thanks much ^^
Reply 7 years ago
Can you please post the diagram and the connections to the fan ?
Reply 7 years ago
well me and my team mate used here a dc fan so it won't be a problem but with a fan you use a Relay module exactly like lamp ... I will try to post the connection lately ..Thank you :)