Advertisement

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, mice, 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.

Ok let's do this project step by step.

Step 1

First, let us identify these components.

Arduino UNO board


Bluetooth module


LED bulb


180-ohm resistor


Breadboard


Jumper wires

Step 2

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


Step 3

Now let's create the required program for this. You can see this program below.

/*Bluetooth module with arduino uno.
  created by SriTu Tech team.
  Read the code below and use it for any of your creation.
*/
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"
  }

}

Here we first create a Char type variable to put the values received through serial communication. It is named as Value.

char value;

Next, the code in the Void setup converts the pin that connects the LED bulb as the output pin.

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

}

We then check the value received through the sequential communication of the Void loop and insert it into the previous variable.

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

Finally, if the value received via the Bluetooth module is "1"LED is turns on,if the value is "0" turns off the LED bulb.

  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 and upload this code. After, reconnect the RX and TX jumper wire.




Step 5

Let's set up the required mobile phone application for this. Follow the steps below. First, download and install the following application 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 we can turn the LED Bulb On and Off by clicking Button A and Button B under Button & Slider. The full video guide is given below. We will meet in the next article. bye-bye


Post a Comment

0 Comments