Connect Bluetooth module to Arduino and learn how to receive data from and send data from your computer.
You will need
- — Arduino;
- — the bluetooth module;
- — connecting wires.
1. There are many implementations of the Bluetooth modules. Each has its own characteristics, but in General they are very similar. Consider the representative of the bluetooth module of the family HC-06.
This module operates at a frequency from 2.40 GHz to 2.48 GHz and supports the bluetooth specification version 2.1+EDR (low energy consumption, an increased level of data protection and easy connection of Bluetooth-enabled devices). Reception module is guaranteed within 10 meters.
The pin assignment of the bluetooth module is:
— VCC and GND — «plus» and «minus» power module supports voltage from 3.6 to 6 volts;
— TX and RX — the transmitter and the receiver module;
— MCU-INT (Status) is a status display;
— Clear (Reset) — reset and restart the module, in this case a low logic level.
The last two conclusions may not be involved; you can often find modules without these findings.
2. Connect bluetooth module to Arduino as shown in the diagram. Please note that the transmitter (Tx) of the Arduino is connected to the receiver (Rx) module, and Vice versa.
On withdrawal Status , you receive a high level when the module is paired with another bluetooth device, and low when not paired. You can read its value by connecting to the Arduino pins, and assigning a mode pinMode(pinStatus, INPUT) and thus to know the state of the module. But not all modules status led is working correctly, so we’re not going to use it in this example.
3. The result should look approximately like in the picture.
4. Write the sketch and upload it to the Arduino memory. We will read the data coming from the bluetooth module, and process them. In this case, when you return from the module «1» will light the led, and in the parish of «0» — to extinguish.
Include the assembled circuit with the Arduino and connected a bluetooth module. Properly connected, the module immediately enters the connected standby, which will be shown by rhythmically flashing led status.
5. Now you need to add a bluetooth device to the list of trusted devices. Include Bluetooth on the computer, go into Settings -> Devices -> Bluetooth. Sure our bluetooth module is visible to the computer. Select it from the list and click Associate. In the dialog box, enter the default password 1234. If successful, the device will appear in the list, marked Connected.
If you want to connect to your bluetooth module from your smartphone, then the procedure is similar: turn on bluetooth on the smartphone to detect the module connected to Arduino, to pair with him.
6. To connect to a bluetooth module you can use different programs that can connect to a 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 that it automatically displays a list of COM ports that are assigned to the bluetooth module on your computer. Run the program, select connect Serialfrom the list, select the appropriate bluetooth COM port, click OK.
In case of an error during connection, the program displays a notification. If the connection between your computer and the bluetooth module was successful, you will see a black section of the terminal.
Using the keyboard, enter in this field the number 1 and the led 13 on the Arduino output will light up, enter 0 to turn off.
7. Similarly, you can connect to the bluetooth module from your smartphone. Download the app to work with bluetooth on the terminal, Bluetooth Terminal. Connect to the module and enter 0 or 1.
Thus, we learned how to connect bluetooth to Arduino and pass data.