📡 How to connect to Arduino bluetooth module

📡 How to connect to Arduino bluetooth module

Daniil Zhuk
Connect the wireless Bluetooth module to the Arduino and learn how to receive data from it and transfer data from it to your computer.

You will need
  • Arduino Nano board or similar;
  • Bluetooth module HC-06 or any other (for example, such);
  • a set of connecting wires (like this);
  • debug board for mounting without soldering.

Instructions for connecting the Bluetooth module to the Arduino

Description of the Bluetooth module HC-06

There are a large number of implementations of Bluetooth modules. Each has its own characteristics, but in general, they are all very similar. Consider the representative of the Bluetooth module of the family HC-06, which can be purchased at a great price on this site.

This module operates at a frequency of 2.40 GHz to 2.48 GHz and supports the Bluetooth version 2.1 + EDR specification: reduced power consumption, increased data protection and easy connection of Bluetooth devices. A stable reception with the module is guaranteed within 10 meters.

 

The purpose of the conclusions of the Bluetooth module is:

Output Purpose
VCC & GND “Plus” and “minus” of the module power supply, supports voltages from 3.6 to 6 volts;
TX & RX transmitter and receiver module;
MCU-INT (Status, State) status output;
Clear (Reset) reset and restart of the module, in this case, is carried out by a low logic level.

The last two conclusions may not be involved; You can often find modules without any of these findings.

Connection scheme of the Bluetooth module to the Arduino

Connect the bluetooth module to the Arduino according to the above scheme.
Note that the transmitter (Tx) Arduino is connected to the receiver (Rx) of the module, and vice versa.

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

As a result, it should turn out approximately as in the photo.

Sketch for Arduino for work on Bluetooth


Let's write such a sketch and load it into the Arduino memory:

const int ledPin = 13; 
char incomingbyte; 

void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  if (Serial.available() > 0) { 
incomingbyte = Serial.read(); switch(incomingbyte) { case '1': digitalWrite(ledPin, HIGH); break; case '0': digitalWrite(ledPin, LOW); break; } } }

We include assembled circuit with Arduino and Bluetooth module connected to it. A properly connected module immediately enters the connection standby mode, which will be indicated by a rhythmically flashing status LED.

Pairing with a Bluetooth device

Now you need to add a Bluetooth device to the list of trusted devices. Turn on Bluetooth on your computer, go to the Bluetooth Device Settings.

If the Bluetooth icon appears on the computer in the notification area when you turn on Bluetooth, you can right-click on it and select the Add Bluetooth device item:

Make sure 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 you add successfully, the device will appear in the list labeled Paired.

The default password for a specific module may differ from "1234". This information must be provided by the manufacturer (seller) of the module.

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

Connect to the bluetooth module via Bluetooth from computer

To connect to the Bluetooth module, you can use various programs that can connect 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 the program TeraTerm is that it automatically displays a list of COM ports that are assigned to the Bluetooth module of your computer. Run the program, select the Serial connection, select the appropriate Bluetooth COM port from the list, click OK.

The PuTTY program also asks for the port number (COM4, you will have your own), connection speed (9600), connection type (Serial). Then click the Connect button.

In case of an error during the connection, the program will display an appropriate notification. If your computer is connected to the Bluetooth module successfully, then you will see a terminal field in front of you.
Enter from the keyboard in this field the number 1 - and the LED on the 13 pin of the Arduino will light up, enter 0 - will go out.

Connecting from a smartphone using Bluetooth Terminal

Similarly, you can connect to the Bluetooth module from your smartphone. Download the application to work with Bluetooth on the terminal, for example, Bluetooth Terminal. Connect to the module and enter commands 0 or 1.

Thus, we have learned to connect via Bluetooth to the Arduino and transmit data to it.

Add a comment

* Comments must be approved before being displayed.