Tamas Imets
Published © CERN-OHL

Voice Controlled Home Automation and Security System

This LinkIt One based device is able to recieve voice commands and sends a SMS if detects motion or fire when you're not at home.

IntermediateFull instructions provided4,417
Voice Controlled Home Automation and Security System

Things used in this project

Hardware components

Relay (generic)
×1
Flame Sensor
×1
Android device
Android device
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
SIM Card
×1

Software apps and online services

BT Voice Control for Arduino
Download this app to communicate and control the LinkIt One board

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
Soldering iron (generic)
Soldering iron (generic)
Not neccesary, only if you want to make selfmade modules like me.

Story

Read more

Schematics

Circuit Diagram

This is the main circuit, feel free to ask if you have questions.

Digital Pins

All sensor and the module are grounded to the GND pin of the board. The motion sensor is connected to the 3rd pin, the flame sensor to the 2nd pin, and the 3 chanell relay module's pins are connected to pins 7, 8 and 9. The other part of the project is sofware based.

Code

LinkIt_ONE_Voice_Controlled_Homa_Automation_and_Security_System.ino

Arduino
Copy this code in your Arduino IDE and upload on your LinkIt One board
//Created by Tamas Imets
//This code is made for my Home Automation project for the Hackster.io website.
//Feel free to edit, but don't forget to credit.


#include <LBT.h>
#include <LBTServer.h>
#include <LGSM.h>



String voice;

void setup() {
  Serial.begin(9600);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(3, INPUT);
  pinMode(2, INPUT);
  //set the pinMode for each pin, 7, 8, 9 are connected to the relay module
  //pin 2, 3 are the sensor pins
  if (!LBTServer.begin((uint8_t*)"Home Server")) { //Create a BT server
    Serial.println("Fail to start BT.");
    return; //try to restart the server
  }
  Serial.println("BT server is started."); //Start the server
  LBTServer.setTimeout(100000);
  while (!LBTServer.connected()) {
    if (LBTServer.connected()) {
      break;
    }
    else {
      LBTServer.accept(10); //allow pairing th BT server
    }
  }
  while (!LSMS.ready())
    delay(1000); //activate GSM connection

  Serial.println("SIM ready for work!"); //check if SIM works
}

void loop() {
  while (Serial.available()) {
    delay(10);
    char c = Serial.read(); //define c variable
    if (c == '#') {
      break;
    }
    voice += c; //define "voice" as variable "c"
  }
  if (voice.length() > 0) {
    Serial.println(voice);
    //check if data comes in serial port

    if (voice == "*TV on") {
      digitalWrite(7, HIGH); //set "on" command
    }
    else if (voice == "*light on") {
      digitalWrite(8, HIGH); //set "on" command
    }
    else if (voice == "*relay on") {
      digitalWrite(9, HIGH); //set "on" command
    }

    else if (voice == "*TV off") {
      digitalWrite(7, LOW); //set "off" command
    }
    else if (voice == "*light off") {
      digitalWrite(8, LOW); //set "off" command
    }
    else if (voice == "*relay off") {
      digitalWrite(9, LOW); //set "off" command
    }

    voice = "";
  }

  if (digitalRead(2) == HIGH) {
    LSMS.beginSMS("0123456789"); //write here your phone number
    LSMS.print("Fire Detected!"); //write here your message
    LSMS.endSMS();
  } else {}
  //set the alarm SMS
  if (digitalRead(3) == HIGH) {
    LSMS.beginSMS("0123456789"); //write here your phone number
    LSMS.print("Motion Detected!"); //write here your message
    LSMS.endSMS();
    delay(10000);
  } else {
    //do nothing
  }


}

Credits

Tamas Imets

Tamas Imets

5 projects • 71 followers
My name is Tamas and I am 20 years old guy who likes to build AI related projects.

Comments