Ashu Mhr Technical
Published

Smart Extension Board

Arduino based Smart Bluetooth Controlled Extension Board

IntermediateFull instructions provided2 hours942
Smart Extension Board

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×4
Resistor 220 ohm
Resistor 220 ohm
×4
Female Header 8 Position 1 Row (0.1")
Female Header 8 Position 1 Row (0.1")
×2
General Purpose Transistor NPN
General Purpose Transistor NPN
bc547
×1
JLCPCB's Customized PCB
×1

Software apps and online services

Arduino IDE
Arduino IDE
Arduino Bluetooth Controller

Story

Read more

Schematics

PCB Gerber File

Code

Untitled file

Arduino
/*
 * Connections of Arduino and Bluetooth Module HC-05 for this Code:
 *      Arduino  |  Bluetooth Module (HC-05)
 *            1  |  RX
 *            0  |  TX
 *           3V  |  3V
 *          GND  |  GND
 */
//Ashu MHR Technical
// https://www.youtube.com/watch?v=Txb-9gg6uLo
// https://www.youtube.com/c/ashumhrtechnical
//Home Automation
/* Code starts from here */
String voice;
#define relay1 2    //Connect relay1 to pin 2
#define relay2 3    //Connect relay2 to pin 3
#define relay3 4   //Connect relay1 to pin 2
#define relay4 5    //Connect relay2 to pin 3
void setup()
{
  Serial.begin(9600);            //Set rate for communicating with phone
  pinMode(relay1, OUTPUT);       //Set relay1 as an output
  pinMode(relay2, OUTPUT);
  pinMode(relay3, OUTPUT);      //Set relay2 as an output
  pinMode(relay4, OUTPUT);
  digitalWrite(relay1, LOW);     //Switch relay1 off
  digitalWrite(relay2, LOW);     //Swtich relay2 off
  digitalWrite(relay3, LOW);     //Switch relay1 off
  digitalWrite(relay4, LOW);     //Swtich relay2 off
}
void loop()
{
  while(Serial.available())    //Check if there are available bytes to read
  {
    delay(10);                 //Delay to make it stable
    char c = Serial.read();    //Conduct a serial read
    if (c == '#'){
      break;                   //Stop the loop once # is detected after a word
    }
    voice += c;                //Means voice = voice + c
  }
    if (voice.length() >0)
    {
      Serial.println(voice);
      if(voice == "*switch on"){
        switchon();
      }               
      else if(voice == "*switch off"){
        switchoff();
      }             
      else if(voice == "bulb off"){   
        digitalWrite(relay1, LOW);
      }
      else if(voice == "bulb on"){
        digitalWrite(relay1, HIGH);
      }
       else if(voice == "bulb2 off"){   
        digitalWrite(relay2, LOW);
      }
      else if(voice == "bulb2 on"){
        digitalWrite(relay2, HIGH);
      }
       else if(voice == "fan off"){   
        digitalWrite(relay3, LOW);
      }
      else if(voice == "fan on"){
        digitalWrite(relay3, HIGH);
      }
      else if(voice == "fan2 off"){
        digitalWrite(relay4, LOW);
      }
      else if(voice == "fan2 on"){
        digitalWrite(relay4, HIGH);
      }
      voice="";
    }
}
void switchon()               //Function for turning on relays
{
  digitalWrite(relay1, LOW);
  digitalWrite(relay2, LOW);
  digitalWrite(relay3, LOW);
  digitalWrite(relay4, LOW);
}
void switchoff()              //Function for turning on relays
{
  digitalWrite(relay1, HIGH);
  digitalWrite(relay2, HIGH);
  digitalWrite(relay3, HIGH);
  digitalWrite(relay4, HIGH);
}

Credits

Ashu Mhr Technical

Ashu Mhr Technical

13 projects • 2 followers

Comments