Arduino lessons: controlling devices from a smartphone for dummies. Arduino lessons: controlling devices from a smartphone for dummies Zs 040 bluetooth connecting Arduino

Bluetooth whistle for computer: http://ali.pub/2jfj3y

First, let's figure out what bluetooth is.

Bluetooth(from the English words blue - blue and tooth - tooth; pronounced /bluːtuːθ/), bluetooth- wireless personal area network manufacturing specification ( Wireless personal area network, WPAN). Bluetooth ensures the exchange of information between devices such as personal computers (desktops, pockets, laptops), mobile phones, printers, digital cameras, mice, keyboards, joysticks, headphones, headsets on a reliable, free, universally available radio frequency for short-range communication. Bluetooth allows these devices to communicate when they are within a radius of up to 10 m from each other (range varies greatly depending on obstacles and interference), even in different rooms.

Now knowing that bluetooth is used to build networks and exchange data between devices, we will use it to connect a CNC (CNC) machine and a computer or a phone or a tablet and a laptop.

Since I use the grbl firmware on the arduino platform to control the CNC, we will connect a bluetooth module suitable for arduino to the machine, namely the HC-06 bluetooth module.

Before connecting the Bluetooth module to the Arduino, you need to make sure that the Bluetooth module and Arduino operate at the same speed of the COM port.

If you are using grbl 0.8 firmware, then you do not need to change anything, but if grbl 0.9 and higher, then the speed of the Arduino COM port will become 115200, and the default speed on the module is 9600.

So we need to change the port speed on the Bluetooth module itself.

To configure Bluetooth modules, there are special AT commands, with which we can set the necessary module parameters.

Using AT commands we can change the speed of the COM port or change the name of the Bluetooth device, or find out or change the PIN code for pairing.

In order to connect the Bluetooth module to the computer to enter AT commands, we will need an FTDI programmer (link to it at the beginning of the article). I think the connection diagram is unnecessary here. You need to connect gnd to gnd, 5v to 5v, rx to tx and tx to rx.

After connecting, we will need the HMComAssistant program to enter AT commands and program our module. Download: https://yadi.sk/d/eVzPmnh63Wab5R

Well, here I will give some AT commands for changing the settings of the Bluetooth module:

AT command Module response A comment
AT OK Used to test communications, as a rule, before performing any operations, this command is first used to test communications.
AT+BAUD1 OK or OK1200 Sets the data transfer rate to 1200 baud
AT+BAUD2 OK or OK2400 Sets the baud rate to 2400 baud
AT+BAUD3 OK or OK4800 Sets the baud rate to 4800 baud
AT+BAUD4 OK or OK9600 Sets the baud rate to 9600 baud
AT+BAUD5 OK or OK19200 Sets the baud rate to 19200 baud
AT+BAUD6 OK or OK38400 Sets the baud rate to 38400 baud
AT+BAUD7 OK or OK57600 Sets the baud rate to 57600 baud
AT+BAUD8 OK or OK115200 Sets the baud rate to 115200 baud
AT+BAUD9 OK or OK230400 Sets the baud rate to 230400 baud
AT+BAUDA OK or OK460800 Sets the baud rate to 460800 baud
AT+BAUDB OK or OK921600 Sets the baud rate to 921600 baud
AT+BAUDC OK or OK1382400 Sets the baud rate to 1382400 baud
AT+NAME +NAME=test Returns the current module name
AT+NAMEiarduino_BLU +NAME=test OK Sets a new module name “test“
AT+PIN +PIN=000000 Returns the current password, in this case the password is “000000”
AT+PIN123456 +PIN=123456 OK Set a new password, in this case the password is “123456”
AT+VERSION +VERSION=Firmware V3.0.6,Bluetooth V4.0 LE Returns the firmware version, in this case the password is “Firmware V3.0.6,Bluetooth V4.0 LE”
AT+RESET +RESET OK
AT+HELP ——– Returns a list of all available AT commands

After changing the speed of the com port and setting the PIN code for pairing. (The default pin code for pairing is “1234”, let’s connect the module to the Arduino.

And since I use CNC shield v 3.0. I’ll also provide a connection diagram for it.

I will not create my own diagram, but will take it from one article. May its creator forgive me.

The diagram is certainly not very smooth, but in my opinion it is quite understandable.

So why are resistors used in a circuit? Arduino has 5-volt logic, which means that the Arduino sends a voltage of 5V to all its outputs. But the module says LEVEL 3.3v, which means that Bluetooth requires 3.3V, but not 5V. Therefore, resistors are connected to lower the voltage and prevent failure of the Bluetooth module.

But I decided to use it directly without resistors, let's see how long the module will last, we'll do some kind of crash test.

To control the CNC (CNC) machine from a phone or tablet, I used the “Grbl controller” program, it is free and quite multifunctional. In the video below I briefly showed how the machine is controlled from this program.

But if you connect from a computer, then there is a nuance: when you pair the connection with the module, two new COM ports will appear in the devices. For me it is COM6 and COM7. So one of them is used to send data, and the other is used to receive. Therefore, there is no need to be scared and just try to connect to one; if nothing happens, then connect to another.

But if something is not clear, I showed it clearly in the video:

Would you like to wirelessly turn on/off the lights in your home? If yes, then for such a project you can use Arduino, bluetooth module HC-06, relays and knowledge of the basics of circuit design.

In this article we will look at the basics of interacting the HC-06 bluetooth module with Arduino. Let's look at examples of transmitting and receiving data via Bluetooth using the example of turning on/off an LED.

For the implementation of more serious automated systems like a “smart home”, these basics will come in handy.

Getting started with the HC-06 is quite easy. All you need to know is the location of the contacts for connection. The HC-06 has six pins: wakeup, VCC, GND, TXD, RXD and State. At this stage, we use 4 contacts: VCC, GND, TXD and RXD.


Below is shown exactly how the Bluetooth module is connected to the Arduino.


The HC-06 acts as a serial port through which you send and receive data. That is, using the serial monitor window in the Arduino IDE or a Bluetooth application on your computer or phone, you can monitor and manage your project. For example, you can use Teraterm as a terminal. Before uploading the sketch to the Arduino, disable the HC-06 module. Since the module exchanges data using tx/rx contacts, it will not be possible to upload the sketch. After downloading the sketch, you can connect the bluetooth module.

Echo sketch for Arduino and HC-06

This sketch gives you the ability to send a string to the Arduino via bluetooth and receive a response that is displayed in the serial monitor.

Note. If you are using Arduino Mega, change the line of code while(Serial.available()); on while(Serial.available()>0);. Otherwise, the sketch will not work.

LED sketch for Arduino and HC-06

This program allows you to turn on/off an LED by sending commands to the Arduino via Bluetooth.

Interaction of HC-06 with a computer

The video below shows how to connect the HC-06 to a personal computer or other bluetooth-enabled device.

Note. The video downloaded shows that the program you are using as a serial monitor (Teraterm in this particular case) connects to the INCOMING com port. It is not right. You must use the OUTGOING (outgoing) com port.

After connecting the HC-06, open Teraterm or another suitable terminal. Select the serial port that is responsible for exchanging data with the HC-06 (more detailed explanations about this are in the video).

After successfully connecting the HC-06, you can send data to the Arduino and back. If you uploaded the second sketch, you will be able to turn the LED on/off by sending the characters “n” and “f” respectively.

Example Echo

Example LED

The scope of application of HC-06 is essentially limitless. You can control any robotic systems and processes. We hope that the given basics of working with the HC-06 bluetooth module will be useful to you in your Arduino projects.

Leave your comments, questions and share your personal experiences below. New ideas and projects are often born in discussions!


As a rule, the headings to such articles indicate a specific model of the module, for example, HC-05 or HC-06. In fact, they all connect the same way. What you really need to pay attention to is the operating mode. The Bluetooth module can operate in one of two modes: master or slave.

Slave(slave) - the most common operating mode in which the device waits for a connection, but is itself unable to connect to another device.
This mode can be used in a robot, bluetooth socket, weather station and any other device to which you plan to connect, for example, from a smartphone or computer.

In mode master The (master) device, on the contrary, is the initiator of the connection and can connect to the slave module. To create a connection between two Arduinos via Bluetooth, you will need two modules, one of which is configured to operate in master mode, the other - slave.

Now, perhaps, we can clarify what the difference is between all these HC-03, -04, -05...

  • HC-03, HC-05 - allow you to change the slave/master operating mode using AT commands;
  • HC-04, HC-06 - configured by the manufacturer to operate in a specific mode, which cannot be changed in the future using standard means. Although I didn’t come across master modules;
  • HC-07- is positioned as a replacement for HC-06;
  • HC-08 - works using the Bluetooth v4.0 BLE protocol (Bluetooth Low Energy - Bluetooth with low energy consumption). Allows you to change the operating mode using AT commands;
  • HC-09 - positioned as a replacement for HC-06 and HC-07, but only works in slave mode.
Modules that allow you to change the operating mode are configured as slave by default. You can also find SPP-C Bluetooth modules on sale, which are offered as an improved replacement for HC-05 and HC-06 for working in slave mode.

So, today we will talk about connecting Bluetooth modules to Arduino in slave mode. And not “naked” ones, but already soldered onto an interface board. This board contains a level converter and a voltage stabilizer, which allows you to connect it directly to Arduino and power it from 5 volts. To communicate with the modules, the UART interface (Universal Asynchronus Receiver-Transmitter or universal asynchronous transceiver) is used. All Arduino boards have at least one UART serial port, which means that connecting to them with Bluetooth does not require any specialized libraries or circuits. It is enough to connect the Rx, Tx contacts of the module with the Tx and Rx contacts of the Arduino, respectively. That is, the transmitter of one device is connected to the receiver of another. Below is a diagram of connecting the Bluetooth module to the Arduino UNO.


To exchange data via a serial interface, Arduino uses the Serial object. Let's try to control the LED built into Arduino: we will turn it on when we receive a "1" symbol via Bluetooth and turn it off when we receive a "0". To do this, load the sketch below into it. Please note: pins 0 and 1 (RX and TX) are used when programming the Arduino, so they must be disconnected bluetooth modulebefore uploading the sketch.

char incomingByte = 0 ; void setup() ( Serial .begin(9600); Serial.println("Hello"); ) void loop() ( if (Serial .available()) ( incomingByte = Serial .read()); if (incomingByte==" 0" ) // and check it for equality "0" else if (incomingByte=="1" ) // if not equal, then compare with "1" digitalWrite(LED_BUILTIN, HIGH);

) ) Function we set the data transfer rate for which our module is configured. Typically, modules are factory set to 9600 bps. We upload the code to Arduino and connect Bluetooth. For control we will use a smartphone and a Bluetooth terminal - using this combination you can find quite a few applications in the market. I use Bluetooth Terminal from Alexander Vozjennikov, using its example I will describe further actions, but you can install any other terminal, it’s a matter of taste. I think it will also not be difficult for iPhone owners to find such an application. So, we launch the terminal and agree to the offer to turn on Bluetooth. If the smartphone has not previously communicated with this module, then we look for a new device and try to connect; when prompted for a PIN code, enter 1234 or 0000.

If the connection is established, we can send data to Arduino. Let's try to send 1, the LED should light up; when sending 0 it will go out. If we now press the reset button on the Arduino, the line Hello will appear in the terminal - this is the function executed Serial.println("Hello") in function setup().


But what if, in addition to Bluetooth, you need to connect some other UART device? In the case of Arduino Mega and Mega2560, in addition to the Serial port, we have access to 3 more hardware serial ports: Serial1 (RX-19 and TX-18), Serial2 (RX-17 and TX-16), Serial3 (RX-15 and TX-14) , which means we can use them instead of Serial, so we no longer have to disable the module before flashing the Arduino firmware. For other boards you can use the SoftwareSerial library. This library allows you to implement a serial interface on any digital pins of Arduino using software that duplicates the functionality of UART (hence the name "SoftwareSerial"). The library allows you to programmatically create several serial ports operating at speeds up to 115200 bps. Let's change the previous sketch a little so that we use a software serial port rather than a hardware one.

#include SoftwareSerial mySerial(2 , 3 ); // RX, TX char incomingByte = 0 ; void setup() ( // Set the operating mode of the output to which the built-in LED is connected pinMode(LED_BUILTIN, OUTPUT); // Set the data transfer rate via the serial interface mySerial.begin(9600); mySerial.println("Hello"); ) void loop () ( if (mySerial.available ()) (// If data is received by the serial port incomingByte = mySerial.read(); if (incomingByte=="0" ) // and check if it is equal to "0" and "1" digitalWrite(LED_BUILTIN, LOW); // if "0" is received, then turn off the LED else if (incomingByte=="1" ) digitalWrite (LED_BUILTIN , HIGH ); // if "1" is accepted, then light the LED } }
Here, to work with Bluetooth, a software serial port is created on pins 2 and 3. Other pins can be used, but the following restrictions must be taken into account: not all Arduino Mega and Mega2560 pins support interrupts that occur when the signal level changes, so on these boards as an output Rx only the following pins can be used: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66 ), A13 (67), A14 (68), A15 (69). A similar limitation for the Leonardo board leaves us with the following pins for use as Rx: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

So, let's upload this sketch to Arduino, connect our module to pins 2 (Rx) and 3 (Tx) and try to control the LED from a smartphone. Everything is working! As you can see, there is nothing difficult in controlling an Arduino-based device via Bluetooth.

All that remains is to think about a more convenient interface for managing the end device. If you plan to use a smartphone for these purposes, then you can find a large number of Bluetooth controllers in the market. I advise you to pay attention to the RemoteXY application. It allows you to create your own control interface, tailored for a specific project. You can find detailed documentation and examples on the developer's website. In general, I recommend it!

In the following publications, we will definitely look at configuring HC-0x modules using AT commands and working in master mode. For now, I think this information is enough for a quick start.

While a small but rather complex review is being prepared, I decided to digress a little and write about the Bluetooth-UART module.
Relatively recently, I did a series of reviews dedicated to one of the main devices of a radio amateur, a laboratory power supply. When I was already writing a review of the USB-RS232 adapter, I was about to finish there. But then I thought, why use wires to control the power supply in the 21st century. Read the continuation of this experiment under the cut.

As I wrote above, while working on the last review in the series dedicated to the laboratory power supply



And indirectly
I decided to close this topic, but then I thought, why do I need an extra cable on my desktop? No, if the device is installed permanently, then the cable is much better, cheaper, more reliable, etc. but if I use the power supply relatively rarely (at least much less often than a soldering iron, for example), then an extra cable, which can also get under the same soldering iron, will be completely inconvenient for me.
I thought about it and ordered a Bluetooth adapter.

But let's be consistent.
The scarf was ordered on June 26, on the 28th I received a notification that the seller had sent my parcel, and already on the 29th it began to be tracked, in my opinion very quickly. On July 11, I received my parcel by mail, in my opinion, quite quickly. True, after that it lay untouched for a month; I didn’t have time to work on it, but recently I finally got around to experimenting with it.
It arrived in a white envelope (I was already so used to yellow ones that it was even unusual).

Inside there was only the module itself and a small cable, packed in an antistatic bag.
In principle, there shouldn’t be anything else there, which is also good news.

The module itself is a small board, which is essentially an adapter on which the Bluetooth transceiver board is installed. On the reverse side there is a marking for the purpose of the contacts. Everything is the same in a minimalist style, Food, general, reception, transmission.

From the front side you can see Bluetooth itself and the adapter board on which it is installed. This board is equipped with a power stabilizer (the Bluetooth module itself is powered by 3.3 Volts) and an LED indicating the connection is established (when the connection is established, it shines continuously, when it is not connected, it blinks). In principle, nothing prevents you from using the Bluetooth module separately from the adapter board (it is also available in this version), but it was more convenient for me.

Then I had to somehow start this module, apply power, turn on the search for devices in BlueSoleil, almost immediately I saw a new device in the environment, clicked, entered the standard code for this module 1234, the LED on the board continuously lit up, and the serial ports button became active in BlueSoleil .
After clicking on this button, I was happily notified that I now have COM5.
First of all, I decided to check the current consumed by this device.

The device has 2 modes, active and sleep, with low consumption.
The device automatically goes into sleep mode after 5 seconds of inactivity and wakes up when any command is received.
In operating mode, consumption from 5 Volts is slightly more than 20 mA.

In sleep mode a little more than 4mA. I think that in this mode, more than half are LEDs and a 3.3 stabilizer; if they are excluded, the current will be even less.

After that, I connected the RX and TX pins of the module to each other and checked for echo in the terminal (I use Putty). The connection goes without any problems, I checked the range, it works within the room, if it is important for someone, I can check it at a greater distance, but the test will not be objective, since the range also depends on the Bluetooth adapter in the computer.

This is where my knowledge ended and I went to the Internet for instructions on how to work with these modules.
After surfing the Internet, I found out that there are many modifications of such modules. When buying, I just read on Ali that the module can only work as a client, there are modules that can work as a master, but I didn’t need those.
I found some information on the modules, I’ll copy some here.
What types of modules are there?

The command system of modules (not all, since the command system depends on the firmware, there are HC-05 and Linor), the HC-05 firmware (HC-03/HC-05 modules) has only commands (many of them), the Linvor firmware (modules HC-04/HC-06) other commands (three AT commands in total). Also, the methodology for working with AT commands is different.

By the way, when sending a command to a module, you must send it in its entirety, i.e. first type the entire command, then send it, otherwise the module will not accept the command. I first tried to do this using the terminal from Bray, it worked without problems, but it was not very convenient.

After surfing the Internet some more, I came up with a rather convenient program for configuring these modules.
I connected the module via .
Everything started up without problems, by the way, the default module settings are standard for many devices - 9600,n,8,1
From the program I learned that my module has firmware version 1.8, I don’t know whether this is good or bad, I’m writing just to inform you, in case it will be useful to someone.

I immediately renamed my module, calling it by the name in which I was going to install it.
In general, I opened the power supply, unplugged the already installed COM-USB adapter, connected four wires, launched the program for working with the power supply, and then BUMMER. :((((
The program does not see my power supply, although the echo passes without problems.
After poking around this way and that, I found out that the command from the program comes to the power supply, moreover, even the power supply responds, but the native program does not see a response from the power supply.
I was very upset and decided to use a bonus like Call a Friend.
My friend works as a programmer, and sometimes we do some projects in pairs, I do the hardware, he does the software.
And here he surprised me, because it turned out that after reading my review of the power supply, he decided to write a program himself to control this power supply, but as expected, with blackjack and “girls”, or rather with graphs, large indicators, the ability to add modes battery charge with correct end of charge, logging, etc...
And the most interesting thing was that in order to make it easier to write a program for working with a power supply, he wrote an Emulator for this power supply.
Those. After reading the power supply command system, he made a virtual power supply. Typical approach of a programmer, reminded - CPU not found! Press any key to emulation. :)))
But the most surprising thing was that with this program Bluetooth worked without problems.
Those. It so happened by chance that the program written while working with the power supply emulator works better than the original one from the manufacturer.
Below are screenshots of the program, these are still test versions, still without add-ons, but already showing signs of life, and most importantly, working correctly with a Bluetooth adapter (it also works with USB without problems).
From the screenshots you can see that the program is still crude. The graph autoscales, so at 12 Volts it shows the maximum.



Here I tried to show that the program works via Bluetooth, excuse me, as best I could. :)

The program will be further developed. Most likely it will be added to this review or to one of the subsequent ones, if it is related to this topic (my thirst for improving different things does not allow me to stop at what I already have).

Summary.
The adapter works without problems, there are no complaints or comments, I tried leaving it for a day, nothing hangs, and it doesn’t get hot. I can’t judge the current consumption, I was more than satisfied with it, as was the operating range. The price is quite reasonable.
I haven't found any cons yet.

Future plans include updating the software (although this is more likely in the programmer’s plans), but I want to modify the COM-USB adapter board so that it would be possible to use both connection options (of course, not simultaneously) and so that this switching would happen automatically. Theoretically, signals from the modules can be decoupled using banal diode decouplings, but we haven’t gotten around to it yet.

Just in case to configure these modules.

P.S. Someone will say that a laboratory power supply controlled via Bluetooth is a whim, but in their own way they will be right. But I don’t use the power supply often and it’s not always on the table, and the extra wire just gets in the way. Otherwise, you can even put it in another corner of the room, turn on the battery charging, for example, and periodically look at the status of the process without getting up from your desk. Quite convenient in my opinion.

I hope my review will be useful to someone.

Instead of a cat.

I'm planning to buy +56 Add to favorites I liked the review +78 +144

Introduction

Bluetooth is a popular data transfer technology that everyone knows; until recently we transferred our photos and videos from phone to phone, but now with the advent of the global web and cloud technologies in almost every home, the need for this has disappeared. The popularity of bluetooth technology, however, has not ended; its simplicity and reliability have found a new application. It is currently used by hundreds of different devices, from wireless keyboards to headphones, from speakers to scales, from remote controls to drones. It is for this reason that it is almost impossible to find a modern phone without Bluetooth technology. Naturally, this technology has not bypassed itself in the field of robotics and design; in a short period of time, friends from the Middle Kingdom have released several cheap modules for connecting them to various microcontrollers, including microcontrollers in the Arduino line. In this article we will talk about one of these modules, namely the Bluetooth module ZS-040.

Description

Bluetooth module ZS-040 consists of two printed circuit boards soldered together:

  • Universal factory bluetooth module based on the CSR BC417 chip.
  • An adapter that simplifies the connection of the factory module to various microcontrollers.

Factory module with CSR BC417 chip.

Adapter ZS-040.

  1. The main board is a standard factory module that is used in thousands of different devices. The basis of the factory module is the BC417 (BC417143B) chip [datasheet] from CSR (Cambridge Silicon Radio). The module is factory-wired and has basic functionality for working with it. The module supports Bluetooth version 2.0 technology with data transfer rates up to 3 Mbit/s.
  2. The second board is a simple adapter for more convenient connection of the main module to various microcontrollers such as Arduino, Raspberry PI, and so on. The second module contains a 3.3V voltage stabilizer, reverse polarity protection and, in some cases, a button. This adapter is called ZS-040. Typically everything in the place is named HC-05 or HC-06 depending on the configuration and operating mode.

Connection

Connecting the module to Arduino is quite simple (see table or connection diagram below). The module is powered from the 5V Arduino line (Since the adapter contains a 3.3V voltage stabilizer, you cannot connect the module from the 3.3V line). The transmit line (TXD) is connected directly to one of the Arduino ports, but the receive line (RXD) must be connected through a voltage divider, since we need to convert the 5V signals from the Arduino to 3.3V for the module. This is done with two resistors of 1 and 2 kOhm. In fact, the module will tolerate and will not fail even from 5V signals. However, this will affect its service life. For this reason, the use of a voltage divider is strictly recommended.

Example

// Include the SoftwareSerial library #include "SoftwareSerial.h" // Create a BTserial class to work with the bluetooth module. SoftwareSerial BTserial(8, 9); // RX port, TX port void setup() ( // Adjust the data transfer rate. Serial.begin(9600); BTserial.begin(9600); // Default 9600 bot. ) void loop() ( // Receive data from the bluetooth module and transfer them to the port monitor. if (BTserial.available()) ( Serial.write(BTserial.read()); ) // Receive data from the port monitor and transfer it to the bluetooth module if (Serial.available. ()) ( BTserial.write(Serial.read()); ) )

In this example, we transfer data from the port monitor to the bluetooth module and back.

Check connection

To test our sketch, we will use a phone and an application installed on it. Personally, I use an Android phone and the "Serial Bluetooth Terminal" application. You can download the application in the Play Market.

If for some reason this application does not work for you or you have a phone with a different operating system, do not worry, there are dozens of similar applications on all platforms, use any of them, to do this, write the following query in the search " Bluetooth Terminal" and the store will offer you a dozen other applications.

Now we need to go to the phone settings and find there the item for working with Bluetooth devices. Turn on Bluetooth if it was turned off and wait until your phone finds a new device. I got a Bluetooth module called HC-06. Select it and enter the password. The default password is 1234 or 0000. If for some reason the passwords do not work, try other simple passwords like 1111, 5555, etc.

Now we launch our Serial Bluetooth Terminal application. Open the drop-down list and go to the "Devices" menu. Select our HC-06 module from the list and return to the main window (Tap on the drop-down list and then on the Terminal menu). In the upper right corner, click on the connect button (Two connector icon). All. we transfer data from the application to the port monitor and back. Below I took some screenshots for clarity.

AT commands

As I mentioned earlier, our bluetooth module has basic firmware, which means that its settings can be changed. For this, there are AT commands, the input of which changes the name of the bluetooth module, its password and the data transfer rate. Unfortunately, the module refuses to accept AT commands through the application on the phone or from the port monitor in data transfer mode. But there is a little trick. To do this, we need to connect the bluetooth module directly to the PC. To do this, you need to connect the RXD and TXD module pins directly to the Arduino pins (RX and TX), and turn off the Arduino itself by installing a jumper between the RST and GND ports. In this case, it doesn’t matter what sketch is uploaded to the Arduino, because it will be disabled by our jumper.

Next, open the Arduino IDE, launch the port monitor and send AT commands to our module. If for some reason your module does not respond to commands, in the drop-down lists below you must select “No end of line” and a data transfer rate of 9600 baud.

List of AT commands

Team

Answer
A comment
AT

OK
Check connection.
AT+VERSION

hc01.comV2.0
Bluetooth module firmware version.
AT+NAMEnewName

OKsetname
Set a new name for the bluetooth module (newName).
AT+PIN6789

OKsetPIN
Set a new password (6789).
AT+BAUD1

OK1200
Set the data transfer rate to 1200 baud.
AT+BAUD2

OK2400
Set the baud rate to 2400 baud.
AT+BAUD3

OK4800
Set the baud rate to 4800 baud.
AT+BAUD4

OK9600
Set the baud rate to 9600 baud.
AT+BAUD5

OK19200
Set the baud rate to 19200 baud.
AT+BAUD6

OK38400
Set the baud rate to 38400 baud.
AT+BAUD7

OK57600
Set the baud rate to 57600 baud.
AT+BAUD8

OK115200
Set the baud rate to 115200 baud.
AT+BAUD9

OK230400
Set the baud rate to 230400 baud.
AT+BAUDA

OK460800
Set the baud rate to 460800 baud.
AT+BAUDB

OK921600
Set the baud rate to 921600 baud.
AT+BAUDC

OK1382400
Set the baud rate to 1382400 baud.

Conclusion

This is the first introductory article dedicated to bluetooth modules. Leave your comments and ask your questions. Well, that's all for me, success and good luck to you.

Please enable javascript for comments to work.