How To Connect Bluetooth Module To Arduino

Table of contents:

How To Connect Bluetooth Module To Arduino
How To Connect Bluetooth Module To Arduino

Video: How To Connect Bluetooth Module To Arduino

Video: How To Connect Bluetooth Module To Arduino
Video: Tutorial on Bluetooth sensor HC-05 with Arduino | Connections & Coding 2024, May
Anonim

Let's connect a wireless Bluetooth module to the Arduino and learn how to receive data from it and transfer data to it from a computer.

Bluetooth module
Bluetooth module

Necessary

  • - Arduino;
  • - bluetooth module;
  • - computer;
  • - connecting wires.

Instructions

Step 1

There are many implementations of Bluetooth modules. Each has its own characteristics, but in general they are all very similar. Consider a representative of the HC-06 bluetooth module.

This module operates at frequencies from 2.40 GHz to 2.48 GHz and supports the bluetooth specification version 2.1 + EDR (lower power consumption, increased data security and easy connection of Bluetooth devices). Stable reception with the module is guaranteed within 10 meters.

The purpose of the pins of the bluetooth module is as follows:

- VCC and GND - "plus" and "minus" of the module power supply, voltages from 3, 6 to 6 volts are supported;

- TX and RX - transmitter and receiver of the module;

- MCU-INT (Status) is a status output;

- Clear (Reset) - reset and restart of the module, in this case it is carried out by a low logic level.

The last two conclusions may not be involved; you can often find modules without these conclusions at all.

Purpose of bluetooth module pins
Purpose of bluetooth module pins

Step 2

Let's connect the bluetooth module to the Arduino according to the diagram below. Please note that the transmitter (Tx) of the Arduino is connected to the receiver (Rx) of the module, and vice versa.

The Status pin displays a high level when the module is paired with another bluetooth device, and low when it is not paired. You can read its value by connecting it to the Arduino pin and assigning it the pinMode (pinStatus, INPUT) operating mode and thus find out the state of the module. But the status indicator does not work correctly on all modules, so we will not use it in this example.

Diagram of connecting bluetooth module to Arduino
Diagram of connecting bluetooth module to Arduino

Step 3

The result should be something like the photo.

Bluetooth module connected to Arduino
Bluetooth module connected to Arduino

Step 4

Let's write such a sketch and load it into the Arduino memory. We will read the data coming from the bluetooth module and process it. In this case, when the "1" symbol comes from the module, we will light the LED, and when "0" arrives, turn it off.

We turn on the assembled circuit with the Arduino and the bluetooth module connected to it. A correctly connected module immediately enters the connection standby mode, which will be indicated by a rhythmically blinking status LED.

Sketch for Arduino with Bluetooth
Sketch for Arduino with Bluetooth

Step 5

Now you need to add the bluetooth device to the list of trusted devices. Turn on Bluetooth on your computer, go to Settings -> Devices -> Bluetooth. We make sure that our bluetooth module is visible to the computer. Select it from the list and click the Link button. In the dialog box, enter the default password 1234. If the addition is successful, the device will appear in the list with the Paired mark.

If you want to connect to your bluetooth module from your smartphone, then the procedure is the same: turn on bluetooth on your smartphone, detect the module connected to the Arduino, pair with it.

Pairing with a bluetooth device
Pairing with a bluetooth device

Step 6

To connect to the bluetooth module, you can use various programs that can be connected to the COM port. For example, such as HyperTerminal, PuTTY, Tera Term, Termite and others. They are all free and freely distributed on the Internet.

The convenience of TeraTerm is that it automatically lists the COM ports that are assigned to your computer's bluetooth module. Launch the program, select the Serial connection, select the corresponding bluetooth COM port from the list, click OK.

In case of an error during connection, the program will display a corresponding notification. If the connection of your computer with the bluetooth module was successful, then you will see a black terminal field in front of you.

Enter the number 1 from the keyboard in this field - and the LED on pin 13 of the Arduino will light up, enter 0 - it will go out.

Connect to the bluetooth module via bluetooth from a computer
Connect to the bluetooth module via bluetooth from a computer

Step 7

Similarly, you can connect to the bluetooth module from your smartphone. Download a bluetooth terminal application such as Bluetooth Terminal. Connect to the module and enter commands 0 or 1.

Thus, we learned how to connect via bluetooth to the Arduino and transfer data to it.

Recommended: