dnbakshi07
Published © GPL3+

Smartplug with Arduino UNO and HC-05 Bluetooth module

Fun and useful project for enthusiastic makers

IntermediateFull instructions provided5,630
Smartplug with Arduino UNO and HC-05 Bluetooth module

Things used in this project

Hardware components

UTSOURCE Electronic Parts
UTSOURCE Electronic Parts
×1
Arduino UNO R3
×1
HC-05 Bluetooth Module
×1
5V Relay Module
×1
12V dc Adapter
×1
AC Wall Socket and Plug
×1
M-M Jumper wires
×1
M-F Jumper Wires
×1

Software apps and online services

MIT App Inventor
MIT App Inventor

Story

Read more

Custom parts and enclosures

SMARTPLUG APP

Schematics

CIRCUIT DIAGRAM

Code

The Sketch

C/C++
int relay = 12;//variable for assigning the relay module
int state = 0;//variable for assigning the value communicated by bluetooth module
int flag = 0; //variable for assigning flag to for a desirable operation
void setup()
{
  pinMode(relay, OUTPUT);//setting relay as output
  digitalWrite(relay, LOW);// initializing the output as off
  Serial.begin(9600); // default connection rate for the BT module
}
void loop()
{
  if (Serial.available() > 0) //checking if connection available with bluetooth module
  {
    state = Serial.read();//assigning the value communicated by bluetooth module
    flag = 0;//initial value set for flag
  } 
  if (state == '0') // LOW value communicated by bluetooth module
  {
    digitalWrite(relay , LOW);//relay is switched OFF
    if (flag == 0) //initial flag
    {
      Serial.println("POWER: Off");//display on the smartphone app
      flag = 1;//flag toggled
    }
  } 
  else if (state == '1') //HIGH value communicated by bluetooth module
  {
    digitalWrite(relay, HIGH);// relay is turned ON
    if (flag == 0)//initial flag
    {
      Serial.println("POWER: On");//display on the smartphone app
      flag = 1;//flag toggled
    }
  }
}

Credits

dnbakshi07

dnbakshi07

0 projects • 10 followers

Comments