Introduction: AUTOMATION

Hello guys, this is Chandan

This video is for all those who are lazy to go and switch on lights, fan, charger, etc..

Because now you can achieve all of these using your phone,sitting in one place.

Step 1: Things You Will Need

  • Arduino
  • Relay module(4 channel)
  • HC 05 Bluetooth module
  • Servo motor
  • Sonoff smart switch
  • 5V Relay(1 channel)
  • 5V Relay(2 channel)
  • Breadboard
  • Leaf switches
  • Geared dc motor
  • Diodes
  • Lock (12V)
  • Wheel
  • Extension box
  • Ice cream sticks
  • Hot glue gun
  • Wires

Step 2: Let's Start

  • connect the relay module to your Arduino (to pin 2,3,4,5) as shown in the circuit
  • modify your extension box and connect (SONOFF) smart switch as shown in the circuit and picture
  • modify the wiring of your room light as shown in the circuit
  • connect the light and extension box to relay module as shown in the circuit
  • connect the servo to the fan regulator as shown in the picture
  • connect the servo to Arduino (to pin 6) and if needed (put a relay in between the circuit of the servo), I have put the relay because my servo vibrates whenever it's powered so I thought because of continuous vibration there may be an issue with the servo
  • connect the relay of the servo to Arduino (to pin 7)
  • the circuit which is in the bottom right corner is of automating the window the two switches are the leaf switch and (L) is the lock and (M) is the motor
  • first get all the things fixed to the window
  • you can use sandpaper to increase friction between the motor wheel and window
  • you can make a structure with ice cream sticks to place the motor as shown in the picture
  • and also place the lock so that it can lock the window from one side
  • connect the relay as shown in the picture
  • use a 12V adapter to power the motor and lock
  • connect the relay to Arduino (to pin 8)
  • I have connected mosquito repellent, 12V adapter(for window) and laptop charger to pin 4,3 and 2 in extension box respectively

Step 3: Programing the Arduino

<p>#include   //Load the servo Library</p>Servo myPointer;
int relay[]={2,3,4,5};
int Relay[]={7};
int RElay[]={8,9};
int servoPin=6;
int w=5000;
int tt=0;
int t=2000;
int ch=4;
int i=0;
int j=1; 
int k=2;
int l=3;
int m=0;
int n=0;
int o=1;
int zero=10;
int first=32;
int second=58;
int third=86;
int fourth=114;
int fifth=138;<p>void setup() 
{ 
  Serial.begin(9600);
  myPointer.attach(servoPin);
  pinMode(relay[i],OUTPUT);
  digitalWrite(relay[i],HIGH);
  pinMode(relay[j],OUTPUT);
  digitalWrite(relay[j],HIGH);
  pinMode(relay[k],OUTPUT);
  digitalWrite(relay[k],HIGH);
  pinMode(relay[l],OUTPUT);
  digitalWrite(relay[l],HIGH);
  pinMode(Relay[m],OUTPUT);
  digitalWrite(Relay[m],HIGH);
  pinMode(RElay[n],OUTPUT);
  digitalWrite(RElay[n],HIGH);
  pinMode(RElay[o],OUTPUT);
  digitalWrite(RElay[o],HIGH);
} 
 
 
void loop() {
 if(Serial.available())
 {
   String value = Serial.readStringUntil('\n');
   Serial.println(value);
   if(value == "0")
   {
     digitalWrite(Relay[m],LOW);
     delay(tt);
     myPointer.write(zero);
     delay(t);
     digitalWrite(Relay[m],HIGH);
   }
   if(value == "1")
   {
     digitalWrite(Relay[m],LOW);
     delay(tt);
     myPointer.write(first);
     delay(t);
     digitalWrite(Relay[m],HIGH);
   }
   if(value == "2")
   {
     digitalWrite(Relay[m],LOW);
     delay(tt);
     myPointer.write(second);
     delay(t);
     digitalWrite(Relay[m],HIGH);
   }
   if(value == "3")
   {
     digitalWrite(Relay[m],LOW);
     delay(tt);
     myPointer.write(third);
     delay(t);
     digitalWrite(Relay[m],HIGH);
   }
   if(value == "4")
   {
     digitalWrite(Relay[m],LOW);
     delay(tt);
     myPointer.write(fourth);
     delay(t);
     digitalWrite(Relay[m],HIGH);
   }
   if(value == "5")
   {
     digitalWrite(Relay[m],LOW);
     delay(tt);
     myPointer.write(fifth);
     delay(t);
     digitalWrite(Relay[m],HIGH);
   }
    if(value == "switch on mosquito repellent")
   {
     digitalWrite(relay[i],LOW);
   }
   if(value == "switch off mosquito repellent")
   {
     digitalWrite(relay[i],HIGH);
   }
    if(value == "start charging laptop")
   {
     digitalWrite(relay[k],LOW);
   }
   if(value == "stop charging laptop")
   {
     digitalWrite(relay[k],HIGH);
   }
    if(value == "lights on")
   {
     digitalWrite(relay[l],LOW);
   }
   if(value == "lights off")
   {
     digitalWrite(relay[l],HIGH);
   }
   if(value == "open")
   {
    digitalWrite(relay[j],LOW); 
    digitalWrite(RElay[n],LOW);
    digitalWrite(RElay[o],LOW);
    delay(w);
    digitalWrite(RElay[n],HIGH);
    digitalWrite(RElay[o],HIGH);
    digitalWrite(relay[j],HIGH);
   }
   if(value == "close")
   {
    digitalWrite(relay[j],LOW); 
    digitalWrite(RElay[n],HIGH);
    digitalWrite(RElay[o],HIGH);
    delay(w);
    digitalWrite(relay[j],HIGH);
   }
   if(value == "switch on everything")
   {
     digitalWrite(relay[i],LOW);
     digitalWrite(relay[k],LOW);
     digitalWrite(relay[l],LOW);
   }
   if(value == "switch off everything")
   {
     digitalWrite(relay[i],HIGH);
     digitalWrite(relay[k],HIGH);
     digitalWrite(relay[l],HIGH);
   }
   if(value == "good night")
   {
     digitalWrite(relay[k],HIGH);
     digitalWrite(relay[i],LOW);
     digitalWrite(relay[l],HIGH);
     digitalWrite(relay[j],LOW); 
     digitalWrite(RElay[n],HIGH);
     digitalWrite(RElay[o],HIGH);
     delay(w);
     digitalWrite(relay[j],HIGH);
   }
 }
}</p>

This is the code for Arduino

  • upload the code to Arduino
  • connect the (HC-05) Bluetooth module to Arduino (RX to pin 1 and TX to pin 0) let the pin STATE and EN be empty
  • always upload the program by unplugging TX and RX pins of Bluetooth module

Step 4: Let's See How Does It Work

  • Take your smartphone open play store
  • download the eWeLink app to control Sonoff switch
  • download Bluetooth Terminal (by Juan Sebastian Ochoa Zambrano)
  • open ewelink use a wifi router or any wifi source to pair the smart switch
  • switch on the Arduino
  • open the Bluetooth settings and pair with your Bluetooth module password will be 1234 or 0000
  • now to switch on lights type lights on
  • to switch off lights type lights off
  • to switch on mosquito repellent type switch on mosquito repellent
  • to switch off mosquito repellent type switch off mosquito repellent
  • to switch on laptop charger type start charging laptop
  • to switch off laptop charger type stop charging laptop
  • to adjust the speed of fan type 0(off), 1, 2, 3, 4 or 5
  • to open and close the window type open and close respectively
  • you can have a look at the video so that it will be cleared
  • if u have any better ideas you can put it in the comments

THANK YOU