Simple Home Automation Using Bluetooth, Android and Arduino
Take control of your home in your smart-phone with the simplest ever home automation device.
String voice;
#define relay1 2 //Connect relay1 to pin 2
#define relay2 3 //Connect relay2 to pin 3
#define relay3 7 //Connect relay1 to pin 2
#define relay4 8 //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 == "*bulb1 on"){
digitalWrite(relay1, LOW);
}
else if(voice == "*bulb1 off"){
digitalWrite(relay1, HIGH);
}
else if(voice == "*bulb2 on"){
digitalWrite(relay2, LOW);
}
else if(voice == "*bulb2 off"){
digitalWrite(relay2, HIGH);
}
else if(voice == "*fan1 on"){
digitalWrite(relay3, LOW);
}
else if(voice == "*fan1 off"){
digitalWrite(relay3, HIGH);
}
else if(voice == "*fan2 on"){
digitalWrite(relay4, LOW);
}
else if(voice == "*fan2 off"){
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);
}
MOBILE APP:-
If you don't know how to make android application then click the link below.
https://www.youtube.com/watch?v=dWKam0eekhU&t=1s
thanks sir g
ReplyDeleteSir can u plz tell me kae apnae arduino pae jo.supply di wo daigrm mae nae han q
ReplyDeleteUsb Usb connect with charger of 5v to Jack
DeleteIt just shows the error message like,
ReplyDeleteVoice port is unidentified.
SAME PROBLEM I'M ALSO HAVING
Deleteyou miss first line of code which is "String voice;"
DeleteSir I want this code
DeleteSir mujhe iss app ka aia file mil sakta hai please de dijiye sir
ReplyDeleteSir mobile app kesy install ho gy
ReplyDeleteSir mujhe this bluetooth device and Esp82.66 both use kare hoy coding milsakte hy plz
ReplyDeleteEsp82.66 wifi
ReplyDeleteIt gives error during uploading how can I remove this please guide me
ReplyDeleteUnplug the connection and install code to arduino
Deletethere is an error related to voice
ReplyDeleteSir please send me code by email
ReplyDeleteSend an mail at
Deletewaimchoudhary@gmail.com
I will send you
Can u sed the mobile.app
ReplyDeletedont work your cod
ReplyDeleteCode
ReplyDeleteString voice;
Delete#define relay1 2 //Connect relay1 to pin 2
#define relay2 3 //Connect relay2 to pin 3
#define relay3 7 //Connect relay1 to pin 2
#define relay4 8 //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 == "*bulb1 on"){
digitalWrite(relay1, LOW);
}
else if(voice == "*bulb1 off"){
digitalWrite(relay1, HIGH);
}
else if(voice == "*bulb2 on"){
digitalWrite(relay2, LOW);
}
else if(voice == "*bulb2 off"){
digitalWrite(relay2, HIGH);
}
else if(voice == "*fan1 on"){
digitalWrite(relay3, LOW);
}
else if(voice == "*fan1 off"){
digitalWrite(relay3, HIGH);
}
else if(voice == "*fan2 on"){
digitalWrite(relay4, LOW);
}
else if(voice == "*fan2 off"){
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);
}
Code me relay 3 pin 7 se kiyu define kiya hai . Circuit me to relay 3 pin 4 se and relay 4 pin 5 se connect kiya hai . Ye thora bta do please. Confuse ho gya hu
Delete7 miss printing 4 hi aayega
DeleteBro please send arduino code in Bluetooth home automation...
ReplyDelete#define relay1 2 //Connect relay1 to pin 2
Delete#define relay2 3 //Connect relay2 to pin 3
#define relay3 7 //Connect relay1 to pin 2
#define relay4 8 //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 == "*bulb1 on"){
digitalWrite(relay1, LOW);
}
else if(voice == "*bulb1 off"){
digitalWrite(relay1, HIGH);
}
else if(voice == "*bulb2 on"){
digitalWrite(relay2, LOW);
}
else if(voice == "*bulb2 off"){
digitalWrite(relay2, HIGH);
}
else if(voice == "*fan1 on"){
digitalWrite(relay3, LOW);
}
else if(voice == "*fan1 off"){
digitalWrite(relay3, HIGH);
}
else if(voice == "*fan2 on"){
digitalWrite(relay4, LOW);
}
else if(voice == "*fan2 off"){
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);
}
Bro please send arduino code in Bluetooth home automation...
ReplyDeleteSir can you send please 8 Kelay module codeing
ReplyDeletesir is ko kasy download karyn or arduino ma kasy copy karyn
ReplyDeleteKeep it up 👏
ReplyDeletesuper sir....but do a video with your voice sir...
ReplyDeleteIf i want to add more output then what changes i should done in program?
ReplyDeleteOne another Q is
ReplyDeletedefine relay1 2 //Connect relay1 to pin 2
#define relay2 3 //Connect relay2 to pin 3
#define relay3 7 //Connect relay1 to pin 2
In 3rd row,
Why "relay3 7"?
Its "relay3 4"
Is it correct or not please explain.
In 3 row comment,
Why "relay3 7" connect relay1 to pin 2
Its "relay3 7" connect relay3 to pin 7
Is it correct or not please explain
Thank you.
do anyone knows how to do the proteus simulation using the apps?
ReplyDeletesend me codining
ReplyDeleteeg43h35h5h
ReplyDeleteCode send kro samja nhi
ReplyDeletebro the code ran successfully and i connected the BT in the ApK file you have attached. the problem am facing is, that on clicking the button "ALL ON ,ALL OFF ,etc" or on any other button my relays are not getting off
ReplyDeleteplease guide me.. am python programmer myself and i checked your code but there is no line of code related to HC-05 module. please guide me how can i overcome the issue i've told you.
kind regards,
These project is workful
ReplyDeleteBut first me sare switch on ho jate he plz sir iska solution batye ki first me switch off rhe
problem with the coppied code.
ReplyDelete"an error occurs while uploading the sketch"
plz help
Please could you send me proteus simulation for this project
ReplyDeleteSend me the code please
ReplyDeleteSir Maine ye project kiya bt ye without mobile app k command se hi jal rahaa hai command dene se pahile hi port ka Sara pin high hai
ReplyDeleteAn impressive share, I just now given this onto a colleague who had previously been doing little analysis about this. Anf the husband the fact is bought me breakfast simply because I stumbled upon it for him.. smile. So permit me to reword that: Thnx for your treat! But yeah Thnkx for spending some time to debate this, I find myself strongly over it and enjoy reading more about this topic. If possible, as you become expertise, might you mind updating your site with more details? It truly is highly of great help for me. Huge thumb up because of this text! buy wallpaper
ReplyDelete