DIY Bluetooth Home Automation Hub: Arduino Nano Edition

by msnikhilslm in Circuits > Arduino

81 Views, 2 Favorites, 0 Comments

DIY Bluetooth Home Automation Hub: Arduino Nano Edition

iiot.png

This guide will walk you through building a versatile home automation controller. This project is perfect for those who want to combine electrical switching (lights/fans) with mechanical movement (locking mechanisms or blind controls) using a smartphone.The core of this build is an Arduino Nano communicating with a smartphone via the HC-05 Bluetooth module. We use a Relay to act as a smart switch for high-voltage appliances and two Servo Motors to handle physical tasks.

Supplies

images.jpg
servo.png
bluetooth1.png
nano.png

Microcontroller: Arduino Nano

Communication: HC-05 Bluetooth Module

Actuators: 2x SG90 (or MG995) Servo Motors

Switching: 1-Channel 5V Relay Module

Power: 5V 2A DC Power Supply (Servos draw more current than a USB port can provide)

Miscellaneous: Jumper wires, breadboard, and a smartphone with a Bluetooth Terminal app.

Wiring and Schematics

Schematics.png

HC-05

VCC - 5V

GND - GND

TX - TX

RX - RX

Relay

VCC - 5V

GND - GND

IN - D2

Servo 1

VCC - 5V(external)

GND - GND

SIGNAL - D3

Servo 2

VCC - 5V(External)

GND - GND

SIGNAL - D4

Tip: Connect the VCC and GND of both servos directly to your external 5V power supply. Ensure the GND of the external power supply is also connected to the GND of the Arduino (Common Ground).

Coding

images (1).jpg

Copy and paste this sketch into your Arduino IDE. It is set up to listen for specific character commands sent over Bluetooth.


#include <Servo.h>

Servo servoA;
Servo servoB;
const int relayPin = 2;

void setup() {
Serial.begin(9600); // HC-05 default baud rate
servoA.attach(3);
servoB.attach(4);
pinMode(relayPin, OUTPUT);
// Initialize state (Relay OFF, Servos at 0 degrees)
digitalWrite(relayPin, HIGH);
servoA.write(0);
servoB.write(0);
}

void loop() {
if (Serial.available() > 0) {
char data = Serial.read();

// Relay Controls
if (data == 'R') digitalWrite(relayPin, LOW); // Relay ON
if (data == 'r') digitalWrite(relayPin, HIGH); // Relay OFF

// Servo 1 Controls
if (data == '1') servoA.write(90);
if (data == '0') servoA.write(0);

// Servo 2 Controls
if (data == '2') servoB.write(90);
if (data == 'x') servoB.write(0);
}
}

Configuration

bluetooth.png

Download a Bluetooth Terminal app on your phone

Pair your phone with the HC-05 in your phone’s Bluetooth settings (Code: 1234).

Open the app, connect to the HC-05, and set up buttons to send the following characters:

  1. Button 1: R (Light ON)
  2. Button 2: r (Light OFF)
  3. Button 3: 1 (Servo 1 Open)
  4. Button 4: 0 (Servo 1 Close)


Conclusion

You now have a functional "Command Center" for your room or workshop. The relay can be safely wired to a lamp (ensure you follow proper AC safety protocols!), while the servos can be 3D-printed into custom housings for mechanical automation.