Controlling a Light Bulb Via Bluetooth HC-06 and Relay Module

by akramslab in Circuits > Arduino

174 Views, 0 Favorites, 0 Comments

Controlling a Light Bulb Via Bluetooth HC-06 and Relay Module

photo_5823674666819110081_y.jpg
Arduino with Relay and Bluetooth HC-06 #akramslab #arduino #projects

In this project, we'll explore how to control a light bulb using a Bluetooth module (HC-06) and a relay module. With the help of this setup, you'll be able to turn the light bulb on or off wirelessly using your smartphone. This project combines hardware and software components to create a simple yet effective home automation system.

Supplies

photo_5823674666819110076_y.jpg
photo_5823674666819110075_y.jpg
relay2.JPG
light bulb.JPG

Materials Required:

  • Arduino Uno or similar microcontroller board
  • Bluetooth HC-06 module
  • Relay module (capable of handling 220V AC and 10A)
  • Jumper wires
  • Light bulb
  • Lamp holder/socket
  • Smartphone with Bluetooth capability
  • Power source for the Arduino and relay module

Setup Arduino and Relay Module

photo_5823674666819110081_y.jpg
bluetooth1.jpg

Relay Module Pins:

  • VCC: Connect this pin to the 5V output of the Arduino or an external power source if required by the relay module.
  • GND: Connect this pin to the GND (ground) pin of the Arduino.
  • IN: This pin is used to control the relay. Connect it to one of the digital pins (in this experiment we have connected it to digital pin 7) on the Arduino.
  • COM, NC, NO: These pins are part of the relay switch. Connect COM (common) to the power source (live wire), NO (normally open) to the appliance (e.g., light bulb), and NC (normally closed) can be left unconnected in this project.

Wiring for 220V AC:

  • Take necessary precautions while working with high voltage.
  • Connect one terminal of the light bulb socket to the live wire of the power source.
  • Connect the other terminal of the light bulb socket to the NO (normally open) pin of the relay.
  • Connect the COM (common) pin of the relay to the live wire of the power source.

Safety Precaution:

  • Ensure that all connections are secure and insulated to prevent electric shocks or short circuits.


Connect Bluetooth Module

bluetooth1.jpg

HC-06 Bluetooth Module Pins:

  • VCC: Connect this pin to the 5V output of the Arduino.
  • GND: Connect this pin to the GND (ground) pin of the Arduino.
  • TX: Connect this pin to the RX (receive) pin of the Arduino.
  • RX: Connect this pin to the TX (transmit) pin of the Arduino.


Write the Arduino Sketch

Define Pins:

  • Define the pin used to control the relay

Setup Function:

  • Initialize the relay pin as an output.
  • start the Serial communication

Loop Function:

  • Listen for commands received over Bluetooth.
  • Based on the received commands, turn the relay on or off.
//akramslab - مختبر أكرم 
int relay=7;
void setup() {
Serial.begin(9600);
pinMode(relay,OUTPUT);
}

void loop() {
if(Serial.available()){
char data= Serial.read();
switch(data){
case '1': digitalWrite(relay,HIGH);
break;
case '2': digitalWrite(relay,LOW);
break;

}
}
}

Upload the Code

Disconnect RX and TX Wires: Physically remove the RX and TX wires connected to the Arduino from the HC-06 module to prevent interference during the upload process.

Upload Process: Upload the Arduino sketch to the board using the Arduino IDE.

Reconnect RX and TX Wires: After the upload is complete, reconnect the RX and TX wires to the appropriate pins on the Arduino.


Control the Light Bulb

Arduino with Relay and Bluetooth HC-06 #akramslab #arduino #projects

Pair Bluetooth with Smartphone:

  • Enable Bluetooth in the settings of your smartphone.
  • Search for available devices and pair with the HC-06 module when it appears in the list.

Bluetooth Terminal App:

  • Download and install a Bluetooth terminal app on your smartphone.
  • Open the app and connect to the paired HC-06 module.

Sending Commands: Send predefined commands (e.g., '1' for turning on the light bulb, '2' for turning it off) via the terminal app to control the relay and, consequently, the light bulb.


Note: Always follow safety guidelines and precautions when working with electricity. Ensure that all connections are secure and insulated, and be cautious when handling high-voltage components.