Bluetooth module with Arduino UNO – How does work Bluetooth module

Bluetooth module with Arduino UNO - How does work Bluetooth module

Hello guys, Welcome back to my SriTu Hobby blog. Today we are going to talk about the Bluetooth module. First, let see what is the Bluetooth module. There is currently no one who does not know about Bluetooth. Because Bluetooth technology is included in the mobile phones, headsets, mics, and speakers we use. Through this, we can easily exchange data between two devices. But Data transfer is possible in the range of 10M to 100M via Bluetooth. Therefore, this can also be called a short-range wireless communication technology. UHF radio waves with short wavelengths are used to transmit data through this technology. It also uses a frequency of 2.45GHz for data transmission via Bluetooth. But today, Bluetooth technology is moving away from us little by little. However, we can easily do some work with this.

Well, now let’s take a look at the HC-5 Module that incorporates this Bluetooth technology. Here we can see Six main pins. Of these, we need only four pins. This is designed to incorporate the serial communication method to transmit data with the Arduino board. For that, we can use the RX and TX pins here. If you don’t know what serial communication is, study this article. Read me. Below you can see the PIN configuration here.

  • STATE –> The state pin is connected to the onboard LED, it can be used as feedback to check if Bluetooth is working properly.
  • RXD –> Receive Serial Data.
  • TXD –> Transmits Serial Data.
  • GND –> Cathode pin of the module.
  • VCC –> Anode pin of the module.
  • EN –> This pin is used to toggle between Data Mode (set low) and AT command mode (set high).

Now let’s see what kind of places this Bluetooth module can be used.

  • Robot cat.
  • Home automation.
  • Wireless communication between two microcontrollers.
  • Consumer applications.

Well, then we will see how to turn an LED bulb on/off using the Bluetooth module. Use the following components for this. These can be easily purchased using the links below.

Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.

Step 1

Firstly, identify these components.

Step 2

Next, connect these components. For that, use the circuit diagram below.

Bluetooth module with Arduino UNO - How does work Bluetooth module

Step 3

Now let’s create the required program for this.

  • The complete program of this project – Download
/*Bluetooth module with Arduino UNO.
  created by the SriTu Hobby team.
  Read the code below and use it for any of your creations.
*/
char value;
void setup() {
  Serial.begin(9600);//enable serial monitor
  pinMode(6, OUTPUT);//define led pin
}
 
void loop() {
  if (Serial.available() > 0) {
    value = Serial.read();//read serial value
  }
 
  if (value == '1') {//check value
    digitalWrite(6, HIGH);//led on
    Serial.println("LED on");//print serial monitor "LED on"
  } else if (value == '0') {
    digitalWrite(6, LOW);//led off
    Serial.println("LED off");//print serial monitor "LED on"
  }
}

Code explanation

First, create a Char Variable to put the values received via serial communication. It is called “Value”.

char value;

The Void setup converts the LED bulb to the output pin.

void setup() {
  Serial.begin(9600);//enable serial monitor
  pinMode(6, OUTPUT);//define led pin
}

Then the Void loop checks the value received through serial communication and inserts it into the Char variable.

 if (Serial.available() > 0) {
    value = Serial.read();//read serial value
  }

Finally, if the value received through the Bluetooth module is “1”, the LED bulb will turn on, if the value is “0”, the LED bulb will turn off.

  if (value == ‘1’) {//check value
    digitalWrite(6, HIGH);//led on
    Serial.println(“LED on”);//print serial monitor “LED on”
  } else if (value == ‘0’) {
    digitalWrite(6, LOW);//led off
    Serial.println(“LED off”);//print serial monitor “LED on”
  }

Step 4

Now, remove the RX and TX jumper wires. Then, select the correct board and port. After, click the upload button.

Then, reconnect the RX and TX jumper wires.

Step 5

Let’s set up the mobile phone app for this project. For that, follow the steps below.

  • First, download and install the following app from the Play Store or App Store.
  • Then open the Bluetooth setting and connect to the device as HC 5. Enter 1234 or 0000 for the password here.

Now run the downloaded application. From here we need two buttons. So let’s make the settings of the two buttons. For that, click on the Settings icon in the top right corner.

  • Next, click the Command button configuration under the Button and slider. Enter 1 for Button A and 0 for Button B.

Now you can turn on and off the LED bulb by clicking Button A and Button B. The full video guide is given below. We will meet in the next project. Have a good day.

Bluetooth module with Arduino UNO – How does work Bluetooth module

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *