DIY Smart Home Automation Control Your Home with Bluetooth using Android Phone and Arduino
Hi guys, In this tutorial we are going to control home appliances with voice command. You have to just press the google mic button and give command to turn ON or OFF Light. So let’s get started.
For making this project, You will need
- Arduino uno,
- Bluetooth module (HC-05),
- 2 channel Relay module, (You can use 8 channel relay depends on your project),
- Jumper Wire,
- Breadboard.
Do connection as shown in diagram.
Why we are using voltage divider for Rx pin of Bluetooth module?
Sending data from Tx pin of Bluetooth module required 3.3V, which is accurately given by Bluetooth module.

But main problem is with Rx pin, it require 3.3V and we know arduino Tx pin is running on 5V. So we have to use voltage divider in order to reduce voltage to 3.3v. This is the reason I am using two resistor. You can use any combination of resistor for example 1k and 2k ohms resistor, as I am using in this tutorial or you can use 10k and 20k ohms resistor but make sure it should give 3.3V to Rx pin.
Android voice application download
#include <SoftwareSerial.h>
#define BT_RX 0 // Bluetooth module RX pin
#define BT_TX 1 // Bluetooth module TX pin
SoftwareSerial BTSerial(BT_RX, BT_TX); // Create a software serial object for Bluetooth communication
#define RELAY1_PIN 8 // Relay module 1 control pin
#define RELAY2_PIN 9 // Relay module 2 control pin
void setup() {
pinMode(RELAY1_PIN, OUTPUT); // Set relay 1 pin as output
pinMode(RELAY2_PIN, OUTPUT); // Set relay 2 pin as output
digitalWrite(RELAY1_PIN, HIGH); // Turn off relay 1
digitalWrite(RELAY2_PIN, HIGH); // Turn off relay 2
Serial.begin(9600); // Start serial communication for debugging
BTSerial.begin(9600); // Start Bluetooth communication
}
void loop() {
if (BTSerial.available()) { // Check if there is data available from Bluetooth module
String command = BTSerial.readString(); // Read the command as a string
Serial.println(command); // Print the command for debugging
if (command == "*bulb on#") { // Turn on bulb one
digitalWrite(RELAY1_PIN, LOW);
BTSerial.println("Bulb is now on.");
} else if (command == "*bulb of#") { // Turn off bulb one
digitalWrite(RELAY1_PIN, HIGH);
BTSerial.println("Bulb is now off.");
} else if (command == "*light on#") { // Turn on bulb two
digitalWrite(RELAY2_PIN, LOW);
BTSerial.println("light is now on.");
} else if (command == "*light of#") { // Turn off bulb two
digitalWrite(RELAY2_PIN, HIGH);
BTSerial.println("light is now off.");
} else { // Invalid command
BTSerial.println("Invalid command.");
}
}
}

Comments
Post a Comment