This circuit allows users to wirelessly control electrical devices, such as lights, fans, or other appliances, using a smartphone app. In this experiment we are going to use LEDs as the load.
Once the board connects to the Bluetooth module, the module blinks several times. You have to first pair it to the Bluetooth system from your smartphone. An LED on the Bluetooth module blinks to confirm that the module has connected with the smartphone.
Objective
The aim of this experiment is to help the user:
- To have the general knowledge about how to use a smartphone with Bluetooth technology to control various appliances. (In this experiment we are going to use LED as the load).
- To learn how to pair Bluetooth modules with that of the smartphone to make controls.
- To understand the application of the wireless (Bluetooth) controlled systems.
Component knowledge
What is a Bluetooth Module? A Bluetooth module is an electronic component that allows devices to communicate wirelessly over short distances using Bluetooth technology. It enables microcontrollers, computers, or other devices to exchange data or commands without physical connections. Developers commonly use Bluetooth modules in wireless communication projects, such as remote control devices, wireless data transfer, and smart home automation.
- Common Bluetooth Modules
One of the most popular Bluetooth modules used with microcontrollers is the HC-05 or HC-06. These modules allow for serial communication between a microcontroller (e.g., Arduino) and another Bluetooth-enabled device like a smartphone or computer.
Figure: Two sides of a bluetooth module
- Pin Identification of a Bluetooth Module
Most Bluetooth modules have the following pins:
- VCC: Power supply pin (usually 3.3V or 5V depending on the module).
- GND: Ground pin, connected to the ground of the circuit.
- TXD: Transmit data pin. This pin sends serial data to the microcontroller or other devices.
- RXD: Receive data pin. This pin receives serial data from the microcontroller or other devices.
- EN (Enable): You use this pin to enable or disable the module. In some modules, you need to pull this pin high to power on the module.
- State: Some modules have a state pin that shows the connection status (high if connected, low if not).
- How a Bluetooth Module Works
A Bluetooth module acts as a serial interface between devices. Once paired with another Bluetooth device (like a smartphone), it sends and receives data wirelessly, allowing for data transfer, remote commands, or controlling other devices. For instance, you can use a Bluetooth module to control an Arduino robot using your smartphone by sending commands over Bluetooth.
- Testing a Bluetooth Module
Testing with a Multimeter
To check the electrical connections:
- Use a multimeter to check whether the module receives the correct voltage through the VCC and GND pins.
- TXD and RXD: You can verify data transmission by checking voltage changes on the TXD and RXD pins while sending data.
A Bluetooth module is an essential component for wireless communication in electronics projects. It allows devices like microcontrollers to communicate with Bluetooth-enabled devices. The most common modules, such as the HC-05, include pins like VCC, GND, TXD, and RXD, which developers use to interface with other devices.You can test the Bluetooth module by pairing it with a smartphone or PC and verifying data transfer, or by using a microcontroller to send and receive serial data.
Materials to use
- Bluetooth module
- LED
- Smartphone (Used for controlling)
- Application (Arduino Bluetooth controller)
- Jumper wires
- Arduino microcontroller
- Breadboard
Circuit diagram
Figure: Schematic diagram for Bluetooth module and
LED connection to the arduino nano
Figure: Components used to make connection on the board
Arduino Codes
Code knowledge
This code uses software serial communication to interact with a Bluetooth module and controls an LED based on the received commands. Let’s break down the provided Arduino code in detail, explaining each component step by step.
This line initializes a SoftwareSerial object named bluetooth that uses SOFT_RX and SOFT_TX for communication with the Bluetooth module.
bluetooth.available() checks for incoming data from the Bluetooth module. bluetooth.readStringUntil('\n') reads the incoming command as a String until it encounters a newline character.
The if statements check if the received command matches “LED OFF” or “LED ON”:
If the command is “LED OFF”, the program sets LED_PIN to LOW using digitalWrite(), turns the LED off, and sends a response.
If the command is “LED ON”, the program sets LED_PIN to HIGH, turns the LED on, and sends a response.
Results
This project demonstrates Bluetooth communication to control a LED via a smartphone app.
Bluetooth Communication:
The Bluetooth module listens for commands (LED ON or LED OFF) sent from a smartphone app or a similar device.
Commands Handled:
Command: LED ON. It turns ON the LED connected to pin 12 and sends the message ‘LED is ON’ back to the sender.
Command: LED OFF. It turns OFF the LED connected to pin 12 and sends the message ‘LED is OFF’ back to the sender.