Project tutorial
Personal Home Assistant

Personal Home Assistant © GPL3+

It is the I2C protocol based Home Automation System. Which can be controlled by voice, Android Phone and even from your laptop.

  • 4,247 views
  • 0 comments
  • 29 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)
PCB Milling Machine

Apps and online services

About this project

I am very keen about science and technology. So, I wanted to apply engineering in reality that how can technology help us. At that time, I was in the last year of my curriculum, I visited Ahmedabad Blind People Association. And I had seen lot's of handicap people together. Immediately, I planned a design in my mind that it is feasible to build a device for them. With the help of that device they will become independent and no need to become dependent on others for daily work.

1. Demo

2. Sources from we got help

https://www.techprobex.com/2013/06/turn-your-computer-into-jarvis-from.html/

www.arduino.cc

www.raspberrypi.org

https://msdn.microsoft.com

https://blogs.msdn.microsoft.com/speech/

The 8051 Microcontroller and Embedded Systems: Using Assembly and CBook by Janice Gillispie Mazidi, Muhammad Ali Mazidi, and Rolin D. McKinlay

The AVR Microcontroller and Embedded Systems: Using Assembly and CBook by Muhammad Ali Mazidi, Sarmad Naimi, and Sepher Naimi

3. Working

There are two parts of this work.

>>> Home Automation Based On Voice

>>>IoT enabled by Raspberry Pi

Home Automation Based On Voice

In this part, We are using I2C protocol.

For using this protocol we need masters and slaves. So, here, we used Arduino UNO and Raspberry Pi as master. And we made three slaves based on ATmega328 IC. The slave's schematics is available in below section. Where readily available PCB board is also in that section. That was made by me.

we are also using 8 channel relay module.

where we are using 3 relays for Hall, 3 relays for bed room and 2 relays for kitchen.

Three relays of hall with 1st slave on digital pin number 2, 3 and 4. And other 3 relays of bedroom is connected with 2nd slave and other 2 relays of kitchen is connected with 3rd slave. So, we will get structure like below.

Now, Our Arduino UNO is connected with PC. Form where you have to upload the master code Which is given in code section. Then for slave 1, slave 2 and slave 3, you have to upload slave program. Here, each component is connected with I2C protocol. Means Slaves and Masters are connected with SDA and SCL line.

Code

Master CodeC/C++
This is master arduino code.
int state;
#include <Wire.h>
#include <Password.h> 
#include <Keypad.h>

Password password = Password( "1234" );

const byte ROWS = 4; // Four rows
const byte COLS = 4; // columns
// Define the Keymap
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 2, 3, 4, 5 };// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 6, 7, 8, 9 };


// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );


void setup() {
 Serial.begin(9600);
 delay(200);
 pinMode(13, OUTPUT);  
 keypad.addEventListener(keypadEvent);
 Wire.begin(); // join i2c bus (address optional for master)
}


void loop() 
{

keypad.getKey();
state = Serial.read();
switch(state)
{
  
  // Drawing room controlling, device id 1
  
  case '1':                   //Drawing Room Fan On
  Wire.beginTransmission(1);
  Wire.write("1");
  Wire.endTransmission();
  delay(500);
  break;

  case '2':                  //Drawing room Light on
  Wire.beginTransmission(1);
  Wire.write("2");
  Wire.endTransmission();
  delay(500);
  break;

  case '3':                  //Drawing room Curtain open
  Wire.beginTransmission(1);
  Wire.write("3");
  Wire.endTransmission();
  delay(500);
  break;
  
  case '4':                  //Drawing room Fan off
  Wire.beginTransmission(1);
  Wire.write("4");
  Wire.endTransmission();
  delay(500);
  break;

  case '5':                  // Drwaing room light off
  Wire.beginTransmission(1);
  Wire.write("5");
  Wire.endTransmission();
  delay(500);
  break;

  case '6':                  //Drawing room curtain off
  Wire.beginTransmission(1);
  Wire.write("6");
  Wire.endTransmission();
  delay(500);
  break;

  // Bed room controlling , device id 2
  
  case '7':                   //Bed Room Fan On
  Wire.beginTransmission(2);
  Wire.write("1");
  Wire.endTransmission();
  delay(500);
  break;

  case '8':                  //Bed room Light on
  Wire.beginTransmission(2);
  Wire.write("2");
  Wire.endTransmission();
  delay(500);
  break;

  case '9':                  //Bed room Curtain open
  Wire.beginTransmission(2);
  Wire.write("3");
  Wire.endTransmission();
  delay(500);
  break;
  
  case 'A':                  //Bed room Fan off
  Wire.beginTransmission(2);
  Wire.write("4");
  Wire.endTransmission();
  delay(500);
  break;

  case 'B':                  // Bed room light off
  Wire.beginTransmission(2);
  Wire.write("5");
  Wire.endTransmission();
  delay(500);
  break;

  case 'C':                  //Bed room curtain off
  Wire.beginTransmission(2);
  Wire.write("6");
  Wire.endTransmission();
  delay(500);
  break;


  // Kitchen controlling
  
  case 'D':                   //Kitchen Fan On
  Wire.beginTransmission(3);
  Wire.write("1");
  Wire.endTransmission();
  delay(500);
  break;

  case 'E':                  //KitchenLight on
  Wire.beginTransmission(3);
  Wire.write("2");
  Wire.endTransmission();
  delay(500);
  break;

  case 'F':                  //Kitchen Curtain open
  Wire.beginTransmission(3);
  Wire.write("3");
  Wire.endTransmission();
  delay(500);
  break;
  
  case 'G':                  //Kitchen Fan off
  Wire.beginTransmission(3);
  Wire.write("4");
  Wire.endTransmission();
  delay(500);
  break;

  case 'H':                  // Kitchen light off
  Wire.beginTransmission(3);
  Wire.write("5");
  Wire.endTransmission();
  delay(500);
  break;

  case 'I':                  //Kitchen curtain off
  Wire.beginTransmission(3);
  Wire.write("6");
  Wire.endTransmission();
  delay(500);
  break;

  
}
}

void keypadEvent(KeypadEvent eKey){
  switch (keypad.getState()){
  case PRESSED:
  
  Serial.print("Enter:");
  Serial.println(eKey);
  delay(10);
  
 
  
  switch (eKey){
    case '*': checkPassword(); delay(1); break;
    
    case '#': password.reset(); delay(1); break;
    
     default: password.append(eKey); delay(1);
}
}
}

void checkPassword(){
  
if (password.evaluate()){  //if password is right open
    
    Serial.println("Accepted");
    delay(10);
    //Add code to run if it works
    digitalWrite(13, LOW);//turn on
    
    
}else{
    Serial.println("Denied"); //if passwords wrong keep locked
  delay(10);
    //add code to run if it did not work
    digitalWrite(13, HIGH); //turn on
    
}
}
Second slave codeC/C++
We are using total three slaves. ut I am just uploading only first slave's code, because other slaves have just same code except NODE_ADDRESS.
#include <Wire.h>

#define NODE_ADDRESS 2  // For 1st slave, it is 1 and for third slave it is 3 
#define PAYLOAD_SIZE 2 

byte nodePayload[PAYLOAD_SIZE];
int t;
void setup()
{

  Serial.begin(9600);
  Serial.println("System made by K.V.J");
  Serial.print("Node address: ");
  Serial.println(NODE_ADDRESS);
  Serial.print("Payload size: ");
  Serial.println(PAYLOAD_SIZE);
  Serial.println("***********************");
  pinMode(2,OUTPUT);
  pinMode(3,OUTPUT);
  pinMode(4,OUTPUT);
  Wire.begin(NODE_ADDRESS);  
  Wire.onReceive(receiveEvent); 
}

void loop()
{
  delay(100);
}


void receiveEvent(int howMany)
{
  t = Wire.read();    
  Serial.println(t);

  if (t == 49)
  {
    digitalWrite(2, HIGH);
  }

  else if (t == 50)
  {
    digitalWrite(3, HIGH);
  }



  else if (t == 51)
  {
    digitalWrite(4, HIGH);
  }


  else if (t == 52)
  {
    digitalWrite(2, LOW);
  }

  else if (t == 53)
  {
    digitalWrite(3, LOW);
  }



  else if (t == 54)
  {
    digitalWrite(4, LOW);
  }




}

Schematics

ATmega328 based slaves
This is a schematic file. Which is supported in eagle or other PCB designing softwares.
Slave%20Chips.sch
ATmega 328 based PCB board
This is PCB board, which may be supported in Eagle or other PCB designing software.
Slave%20Board.brd

Comments

Similar projects you might like

GPS Datalogger, Spatial Analysis, and Azure IoT Hub.

Project tutorial by Shawn Cruise

  • 18,283 views
  • 4 comments
  • 70 respects

TIA Weak Artificial Intelligence IoT Assistant

Project tutorial by Adam Milton-Barker

  • 3,900 views
  • 0 comments
  • 20 respects

Candy Dispenser with Google Assistant

Project tutorial by Arduino “having11” Guy

  • 15,482 views
  • 1 comment
  • 51 respects

Azure Stream Analytics saving lives!

Project tutorial by Asad Zia

  • 6,665 views
  • 3 comments
  • 28 respects

Sandro: Your Personal GPS Assistant

Project tutorial by Mohamed Fadiga

  • 4,182 views
  • 2 comments
  • 11 respects

ATmega Alien Themed Slot Machine

Project tutorial by Dan Murphy

  • 1,079 views
  • 5 comments
  • 14 respects
Add projectSign up / Login