Maker Pro
Arduino

Device Control using Smart Phone’s Bluetooth

June 07, 2022 by AFZAL REHMANI
Share
banner

In this tutorial, we are going to make Device Control using Smart Phone’s Bluetooth

Introduction

We are living in the smart era, where we, humans want everything at our fingertips. Sometimes we don’t want to waste our time on small matters like turning ON/OFF the device switches. And, for this reason, the concept of smart home automation is rising, where a human only needs his/her phone to switch ON/OFF his home, or office devices. Thus, making this wasn’t a cup of tea. Your devices must have a Bluetooth module on them. The circuit also requires coding behind it. So, are you ready to make that circuit with us? Because in this tutorial, we are going to make a device control using smart phone’s Bluetooth and Attiny85. Along with Attiny85, the circuit is also using the HC-05 Bluetooth module to turn ON/OFF the relay. So, before making the circuit, let us briefly discuss this Bluetooth module.

PCBWay commits to meeting the needs of its customers from different industries in terms of quality, delivery, cost-effectiveness, and any other demanding requests. As one of the most experienced PCB manufacturers in China. They pride themselves to be your best business partners as well as good friends in every aspect of your PCB needs.

IMG_20220329_122458_619-1536x1152.jpg
#include<SoftwareSerial.h>
#define relay_pin 3
SoftwareSerial BT_serial(2,4);// TX,RX of HC-05
char ch;
void setup() 
{
  pinMode(4,OUTPUT);
  pinMode(2,INPUT);
  pinMode(3,OUTPUT);
  BT_serial.begin(9600); 
  delay(2000);
  BT_serial.println("Bluetooth connected");
  delay(1000);
  BT_serial.println("send 1/0 to turn ON/OFF device");
}
void loop() 
{   
  while(BT_serial.available())
    {       
       if(BT_serial.available()>0)
        {   
          ch = BT_serial.read();
          if(ch == '1') 
{
  digitalWrite(relay_pin,HIGH);
  BT_serial.print("Device is ON");
}
          if(ch == '0') 
   {
  digitalWrite(relay_pin,LOW);
  BT_serial.print("Device is OFF");
} 
        }             
    }   
}
attiny85-bluetooth-hc-05-device-control-smart-phone-circuit.jpg

Related Content

Comments


You May Also Like