Contacts

HC 06 RF Wireless Bluetooth. What is a Bluetooth module? Description of errors issued by the module

Would you like to organize wireless power on / off in the house? If so, then for a similar project you can use Arduino, Bluetooth Module HC-06, relay and knowledge of the basics of circuitry.

In this article, we look at the basics of the Bluetooth interaction of the HC-06 module with Arduino. Consider examples of transmission and reception of data via bluetooth on the example of turning on / off the LED.

To implement more serious automated systems, like a "smart home", these basics will be as impossible by the way.

Start working with HC-06 simple enough. All you need to know is the location of contacts for connecting. On HC-06 six contacts: Wakeup, VCC, GND, TXD, RXD and STATE. At the stage, we use 4 contacts: VCC, GND, TXD and RXD.


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


HC-06 acts as a serial port through which you pass and accept the data. That is, using the serial monitor window in Arduino IDE Or a Bluetooth application on your computer or phone, you can control and manage your project. For example, TERATERM can be used as a terminal. Before loading the Sketch on Arduino, disconnect the HC-06 module. Since the module generates data exchange using TX / RX contacts, the sketch will not be loaded. After loading the Sketch, you can connect a Bluetooth module.

Echo Sketch for Arduino and HC-06

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

Note. If you are using Arduino Mega, change the WHILE (Serial.available ()) code line; on while (serial.available ()\u003e 0);. Otherwise, the sketch will not work out.

LED Skatch for Arduino and HC-06

This program makes it possible to enable / disable the LED, sending commands on Arduino via Bluetooth.

HC-06 interaction with computer

The video below shows how to connect HC-06 to personal computer Go to a different device with Bluetooth support.

Note. The video downloaded that the program you use as a serial monitor (Teraterm in this particular case) is connected to incoming (included) COM port. It is not right. You need to use outgoing (outgoing) COM port.

After connecting the HC-06, open a Teraterm or other suitable terminal. Select the serial port that is responsible for the exchange of data from HC-06 (more detailed explanations on this is on video).

After successfully connecting HC-06, you can send data to Arduino and back. If you downloaded the second sketch, you can turn on / off the LED, sending "n" and "f" characters, respectively.

An example of echo

Example led.

The scope of application HC-06 is essentially limitless. You can manage any robotic systems and processes. We hope that the presented basics of working with Bluetooth Module HC-06 will be useful to you in projects on Arduino.

Leave your comments, questions and share your personal experience below. New ideas and projects are often born in the discussion!

Looking for an easy way to wireless remote control Your device C. using bluetooth? Use the Bluetooth Module HC-06.

On the part of the managed device, such as Arduino, this module looks like a regular serial interface. Therefore, you can debug all communication with the device on your computer, and then simply connect this Bluetooth module, and everything will work as it should.

With HC-06, you can control the robot directly from your smartphone. Putting one of the numerous control programs on Bluetooth on the phone or tablet, you can turn it into a real advanced joystick, and your robot will be able to obediently turn after the twist of the smartphone. In the same way, you can contact your device from a laptop, or from any other instrument that can connect to Bluetooth devices.

The scope of application of this module is not exhausted by control. It can also be used to send diverse sensors.

Work voltage This Bluetooth module is 3.3 V, but its inputs are tolerant to 5 V, so it is compatible with all Arduino boards.

Connection

The module contacts can be connected to the Mama Pope Mama-Dad Wires or Arduino. And with Troyka Shield through the "Mom Mom" \u200b\u200bwires.

Connection Standard for devices connected by a serial interface:

  • The contact of the RX module connects to the TX contact of the target device.
  • The contact TX module connects to the contact RX of the target device

Settings

All default settings are subject to change using AT commands.

The Bluetooth Module HC-06 can only act in Slave mode. This means that it cannot independently connect to other Bluetooth devices.

Equipment

The kit does not include wires. To connect to the control electronics, use the Macate Wires with the Mom connectors on the module side or

Hello everyone!

There is a modification of the HC-05 module with 6 stars, (State, Rx, TX, GND, VCC, EN), is very popular now to Aliexpress, so, for it, it is not necessary to solder wiring on 34pins (Key) and feed 3.3V to Enable RX-TX operation on outputs must be submitted 3.3B. On the EN and not on Key connector, after that such a module starts to work as it should be started to respond to AT commands sent from a computer or Arduian on Pins. We hardly found this information in one description of this module on the product page for Alikexpress.
In short, everything is also like with KEY in this article, only 3.3B. Apply for EN! (ENTER).
I give a description of the English.

First, The Module Parameters:
1.pcb Dimensions: 37.3mm (Length) * 15.5mm (w)
2 Weight:. 3.5G.
(3) INPUT Voltage: 3.6V-6V, 7V BAN OVER
4 Power Anti-Reverse, Reverse Module Does Not Work
5 Leads to 6 Feet: EN / VCC / GND / RXD / TXD / STATE (Bluetooth Status Leads to the Foot, IS Not Connected to the Output Low, After Connecting Output High)
6 WITH THE CONNECTION STATUS INDICATOR, LED FLASH Means No Bluetooth Connection; LED FLASHING SLOWLY THAT ENTER THE AT COMMAND MODE
7 Onboard 3.3V Regulator Chip, The Input Voltage DC 3.6V-6V; WHEN UNPAIRED, CURRENT OF ABOUT 30MA (BECAUSE LED LIGHTS FLASHING, THE CURRENT STATE OF CHANGE); After Successful Pairing, The Current Is About 10ma
8 Interface Level 3.3V, You can Directly Connect a Variety of Microcontroller (/ 51 / AVR / PIC / ARM / MSP430 etc.), 5V Microcontroller Can Also Be Directly Connected. Directly Connected to the Microcontroller Serial Port, NOT Through the Max232 Chip!
9 Open Area Effective Transmission Distance of 10 Meters, Over 10 Meters Are Possible, But Do Not Guarantee The Quality of the Connection
10. After Successful Pairing, CAN BE Used As a Full-Duplex Serial Port. Do Not Need to Know Anything But The Bluetooth Protocol, But Only Supports 8 Data Bits, 1 Stop Bit, No Parity Communication Format. This Is The Most Common Communication Format That Does Not Support Other Formats!
11 Press The Key to Give The Bluetooth Module Is Energized to Enter At Mode, Set Parameters and Query Information
12 CAN BE SWITCHED MASTER AND SLAVE MODE VIA AT COMMANDS
13 Modules Default Baud Rate IS 9600, The Default Passkey IS 1234, The Default Name for The HC-05
14 Protection with Transparent Shrink Tube
Second, Wiring Methods:
VCC: POSITIVE POWER SUPPLY
GND: Power Supply IS Negative
RXD: Receive Side, The Bluetooth Module Receive Data Sent to the Other Device; TXD Terminal Normally Connected To the Other Device To Send
TXD: Sending End, The Bluetooth Module to Send Data to Other Devices; RXD Terminal Normally Connected to Other Devices Receiving
En: Enable, Then You Need to Enter At Mode 3.3V

For wireless exchange of information, Bluetooth technology can be used between different devices on small distances. For these purposes, the Chinese industries produces various Bluetooth modules, among which the models of HC-05 and HC-06 were wide popular. At one time, I purchased the HC-06 on Aliexpress, where I will conduct further experiments, as well as connect to my Chinese analogue of Arduino.

Directly the Bluetooth module itself. In this form, it can be used in various devices, where it is sold directly into the fee. The module has 34 outputs, among which: conclusions for connecting to a computer by UART, the sound transmission using the PCM method (pulse code modulation), analog input and output, contacts to connect to a USB connector, SPI interface, and general purpose ports. In fact, not all of these conclusions are available for use, access to the sound transmission outputs (5-8), analog input and output (9, 10), as well as to the contact group for connecting to USB (15, 20) is blocked.

HC-06 is built on the BC417 chip (BlueCore4-External Device), the Bluetooth V2.0 specification. On board, there is also quartz at 26 MHz and flash memory for 8 MB. Power is carried out from 3.3V.

For its designs, it is the most convenient to use a module with a batch board, on which the necessary contacts are displayed for connections, as well as there is a voltage stabilizer that allows you to eat from 5 volts.
When buying such modules, you may encounter various marking them. In essence, this is the same device that is characterized by the firmware that defines the Master / Slave mode.

The difference between HC-05 from HC-06 is that HC-05 can be used as a slave (MASTER) or master (Slave). These modes are set using AT commands. The button on the module board switches to the input mode of AT commands. Master mode allows the module to detect a similar device itself and organize communication with it. The HC-06 module can only work in one fixed Slave mode.

There are also models HC-03 and HC-04, but they are produced for industrial purposes.

The designation of contacts on the HC-06 board.

State - Check the state of the module. On this contact duplicates a signal that displays the built-in LED on the board. If it blinks very quickly, then the module is in active condition. In the establishment mode, the current is 30-40 mA. When the module establishes a connection with another device, the LED is simply lit. In the data transfer mode, the current is 8 mA.
RX. - Getting data.
TX. - data transfer.
GND. - Connects to Earth.
+ 5V. - Food +5 Volt
En - Turn on / off the module. If this contact is to submit logical 1 (5 volts), the module will turn off if you submit a logical 0 or not connect to this contact, the module will work.

By default, HC-06 has a name to detect other devices " HC-06.", With PIN" 1234 ».

To change this data, you need to connect the module to a computer and using the TRAIN program to enter the AT command. This can be done using the USB to COM adapter with TTL levels. For these purposes, the adapter is suitable for PL2303HX, CH340G, or another similar one. On the computer by this time the driver must already be installed for USB adapterbut.

Contacts connect as follows:

HC-06. USB TO COM
+ 5V. + 5V.
GND. GND.
RX. TX.
TX. RX.

When connecting this assembly to a computer, the red LED on the Bluetooth module board will flash quickly. You can use any terminal program to enter AT commands, I use Arduino IDE for this purpose.

In the settings, select the number of the virtual COM port on which the USB adapter is connected, in my case it is COM44. Open the window " Consecutive port monitor».

We introduce capital letters command " AT."If the device successfully connected, in response it should be returned" OK" By default, the rate of data exchange of 9600 bodes.

To check the firmware version, enter the command " AT + VERSion."In my case, the answer returned" Oklinvorv1.8.».

Team " AT + Nameyyy.", Where uU. - an arbitrary set of symbols on the Latin, we can change the name by which our Bluetooth device module will be found (default HC-06). In my example, I entered " AT + NAMEFOX.", The answer is coming back OksetName..

Team " AT + PINXXXX.", Where xxxx- an arbitrary set of numbers, you can change the PIN code (default 1234). In response, returns " Oksetpin.».

Team " AT + Baudx", Where x. - Value from 1 to 9, you can change the speed in the baudes (by default 9600).

1 - 1200
2 - 2400
3 - 4800
4 - 9600
5 - 19200
6 - 38400
7 - 57600
8 - 115200
9 - 230400

Suppose if we conduct the command " AT + BAUD8.", Where 8 - the speed of 115200 baud, returns in response" OK115200.».

Connect HC-06 to Arduino.

Example 1. Will in Arduino Skatch, with which we will turn on and off the LED, sprinkled on 13 ARDUINO PINE, via a Bluetooth module.

iNT DATA;
int led \u003d 13;
void setup ()
{
Serial.begin (9600);
Pinmode (LED, Output);
DigitalWrite (LED, HIGH);
}
void loop ()
{
if (serial.available ())
{
Data \u003d serial.read ();
if (data \u003d\u003d "1")
{
DigitalWrite (LED, HIGH);
}
if (data \u003d\u003d "0")
{
DigitalWrite (LED, LOW);
}
}
}

If you do not have on the board of this LED, connect it to 13 pins according to the diagram, the ratings of the resistors can be taken from 220 ohms to 1k.

Severe Arduino and connect HC-06. Contact TX. Module connect to contact RX. Arduino (PIN 0 on the UNO board), and contact RX., to contact TX. (PIN 1). Contacts + 5V. and GND., Connected to the appropriate hopes of Arduino.

Design assembly. After feeding the Arduino power, the LED on HC-06 must flash quickly.

ARDUINO control via HC-06, using a computer.

Example I will show on Windows XP. The computer must be connected to the computer. any USB Bluetooth adapter and drivers are installed on it.

In my case, this adapter was used.

When it is connected to the PC, the corresponding icon appears in the tray (near the clock).

Click on the right mouse button on this icon and select "CONTEXTER MENU" Add Bluetooth device».

Put the switch " The device is installed and ready to detect"And click" Further».

In the list of detected devices, our Bluetooth module will appear, with the new name I changed earlier. Choose it and click " Further».

In the next window, enter a PIN code to connect to the module by selecting " Use the access key from the documentation:». The default is "1234", But I changed it to "9999". Click " Further».

The Bluetooth module has been successfully contacted by the computer, what can be found from the corresponding window. You should pay attention to the formation of a link between two Bluetooth devices, two new virtual COM ports will be created on the computer (will be displayed in the device manager), one for outgoing data, the other for incoming. We will need a port for outgoing data, in my case it is COM45.

Re-open some Terminal Program, I will use Arduino IDE. In the settings, choose the outgoing port (I have COM45), open " Serial port monitor"I introduce alternate commands" 1 "And" 0 " When "1" command, the LED lights up, with "0" goes out.

Arduino control via HC-06 with a smartphone.

Probably all modern smartphones have built-in Bluetooth in their composition. It remains only to install the terminal program. In my case was used Lumia 640 ds., with installed Windows Mobile 10.. As a program of the terminal I use "". On Android smartphones, everything is similar, as a program you can use " Bluetooth Terminal».

For owners of smartphones apple companies It will not work with Bluetooth modules HC-05 and HC-06 (Bluetooth V2.0), for them will have to use adapters with BLE technology ( Bluetooth Low. ENERGY), Bluetooth 4.0 specification. The bright representative is the HM-10 module.

Match HC-06 with a bluetooth smartphone.

1. in " Parameters»Smartphone Choosing an item" Devices».
2. Next " Bluetooth and other devices».
3. Turn on the smartphone bluetooth slider and click on " plus in square»To search and add a new Bluetooth device, in our case HC-06.

4. In the section " Add device"Choose" ".
5. The smartphone will search for Bluetooth devices located in the district and display their names. In my example, the HC-06 module was found, which I renamed " fox.».

6. Enter the PIN code of the device to which you connect, press the button " Connect».

Install and launch the terminal program "". The HC-06 module connected to the smartphone is displayed in the list, select it.

A field will appear to enter commands and the send button. We introduce alternately 1 "And" 0 "And watch the LED on 13 pine, which will be lit or go out.

Example 2.. Connect to Arduino three LEDs and try to control them via Bluetooth Module HC-06.

LEDs connected to 9, 11 and 13 pins if you want to use other pins, you need to specify in the Sketch.

iNT DATA;
int led1 \u003d 9;
int led2 \u003d 11;
int led3 \u003d 13;
void setup ()
{
Serial.begin (9600);
pinmode (LED1, Output);
pinmode (LED2, Output);
pinmode (LED3, Output);
digitalWrite (LED1, HIGH);
digitalWrite (LED2, HIGH);
digitalWrite (LED3, HIGH);
}
void loop ()
{
if (serial.available ())
{
data \u003d serial.read ();
if (data \u003d\u003d "1")
{
digitalWrite (LED1, HIGH);
}
if (data \u003d\u003d "2")
{
digitalWrite (LED1, LOW);
}
if (Data \u003d\u003d "3")
{
digitalWrite (LED2, HIGH);
}
if (data \u003d\u003d "4")
{
digitalWrite (LED2, LOW);
}
if (data \u003d\u003d "5")
{
digitalWrite (LED3, HIGH);
}
if (Data \u003d\u003d "6")
{
digitalWrite (LED3, LOW);
}
}
}

When pouring the Sketch, the HC-06 module must be disconnected from Arduino, because the computer, and bluetooth work on the UART. Arduin cannot work with multiple devices on one UART.

Run the terminal program and try the sketch in action. The meaning of the LED control is next, there are three LEDs, each of which can be either enabled or turned off. It turns out 6 commands. Commands are numbers from 1 to 6 ( 1, 3, 5 - Welcome 1, 2 and 3 LEDs. 2, 4, 6 - to repay). The numbers can be entered one or in the form of combinations. For example: 145 - Welcome the first, repay the 2nd, light the 3rd.

Example 3.. Connect to the Arduino relay module from the article "" and try to control the powerful load via Bluetooth. In fact, we will have a smart socket. You can connect different loads (light bulbs, pumps, fans) to relays-modules and manage them at a distance.

Skatch for this example will appear in the near future.

Bluetooth The HC-05 module is connected via the UART bus and is able to execute AT commands. AT command is a string starting with the letters "AT" (from English aT.tention - "Attention"). The module executes the received command and sends the response back (the result of the execution of the command), which is also a string. In Bluetooth HC-05 modules, each command (as well as the answer) must end with the symbols of the transfer of the string "\\ R \\ n".

Connection:

  • You can control the Bluetooth module HC-05 either from a computer or through a microcontroller, for example, Arduino. The RX output of the module is connected to the TX output, and the TX output of the module is connected to the output of the Rx of that device from which it will be controlled.
  • To connect the module to a computer (without microcontrollers) A USB-UART adapter will be required, or an RS232-UART adapter, or a programmer with TX RX outputs, instead of the USB-UART adapter, you can use the Arduino fee, as described in the article. To send commands to the module, you will need to install the terminal program. One of these terminals is a freely distributed TERMITE program with the support of Russian.
  • To connect the module to Arduino You can use the UART hardware or software bus. When using a hardware bus, the module is connected to the TX and RX conclusions specified on the board. When using a software bus, the module is connected to the assigned TX and RX Arduino outputs.

Setup:

The Bluetooth HC-05 module will be able to receive commands only if the following serial port parameters are properly configured:

  • roomport:It can be found experimentally, disconnect the adapter or arduino, see which ports are available. Connect the adapter or Arduino and look at what ports are available. The port appeared is the same.
  • Data transfer rate:In normal mode, Bluetooth Module HC-05 saves the last set data transfer rate, but by default it is 3,8400 bits / s (rarely 9600 bps). If both speeds do not fit, then see Note at the end of the article.
  • Data transfer parameters:The module stores the latest data transfer settings. The default parameter values: the number of bits in the package is 8, the stop bit size \u003d 1, without checking.
  • Transmitted text:You need to install the "Add CR & LF (NL) characters" item. These are the "\\ R \\ n" line translation symbols that you cannot install yourself at the end of the AT commands.

To configure these parameters in the TERMITE program, click on the Settings button. In the same window, you can install the Russian language.

When using Arduino, the port number is specified in the Tools tab. Data transfer parameters are used by default. To add NL & CR characters, use the menu in the lower right corner of the serial port monitor.

Check:

After each power connection or restarting the module, before sending commands, click on the module button briefly. If the module does not have a button, then briefly submit a high level on the conclusion K. After which the module will remain as usual, but will perceive the AT commands. In addition to the usual mode, the module can operate in AT commands. About how to enter this mode and what it differs from the usual, is described below, in the note section.

To check the connection with the Bluetooth module, send a test command. AT.(Enter the text AT.and press ENTER). If the connection is set correctly, the module will answer OK.. After that, you can send the rest of the AT commands.

AT commands:

If the terminal program shows the CR & LF or NL & CR symbols, then the characters "\\ r \\ n" in the commands do not need!
Commands can be ordinary: AT + command \\ R \\ n, requests: AT + command? \\ R \\ n, or settings: AT + command \u003d parameter (s) \\ r \\ n.

AT command: Answer: Purpose:
AT. AT.\\ r \\ n Ok \\ r \\ n Test Team:
Used to check the connection with the module.
Reset. AT + Reset.\\ r \\ n Ok \\ r \\ n Module program restart command:
The module behaves like after a short-term power outage.
Version. AT + VERSion?\\ r \\ n + Version: VERSION\\ r \\ n
Ok \\ r \\ n
Request version of the module firmware:
The module returns the version in the form of a string to 32 bytes.
An example of an answer: + version: hc01.comv2.1 \\ r \\ n ok \\ r \\ n
AT + ORGL AT + ORGL\\ r \\ n Ok \\ r \\ n Reset Custom Settings:
The module resets the following settings:
Class \u003d 0, iac \u003d 9e8b33, Role \u003d 0, CMode \u003d 0, UArt \u003d 38400,0,0, PSWD \u003d 1234, Name \u003d HC01.com.
ADDR AT + ADDR?\\ r \\ n + Addr: ADDRESS\\ r \\ n
Ok \\ r \\ n
Request Address Module:
The module returns three parts of its NAP address: UAP: Lap separated by colon.
Each part consists of hexadecimal numbers.
An example of an answer: + Addr: 1234: 56: 789ABC \\ R \\ N OK \\ R \\ N
Name. AT + NAME?\\ r \\ n + Name: NAME\\ r \\ n
Ok \\ r \\ n
Quest / installation of the module name:
The name of the module is represented by a string up to 32 bytes.
An example of an answer: + name: iararduino \\ r \\ n ok \\ r \\ n
Installation Example: AT + NAME \u003d iararduino \\ r \\ n
Some modules respond to the AT + NAME? \\ R \\ N command only when the module is pressed or the presence of a high level at the input K.
AT + NAME \u003dName \\ R \\ n Ok \\ r \\ n
RName. AT + RNAME? Address \\ R \\ n + RName: NAME\\ r \\ n
Ok \\ r \\ n
Request the name of the Bluetooth device found:
The address is entered after a space, and part of the address (NAP, UAP, LAP) are separated by a comma. The module returns the name of the Bluetooth found device located in the action zone, the address of which was in the query.
Sample request: AT + NAME? 1234,56,789ABC \\ R \\ N
An example of an answer: + RName: ovaruino \\ r \\ n ok \\ r \\ n
Role AT + ROLE?\\ r \\ n + Role: ROLE\\ r \\ n
Ok \\ r \\ n
Request / installation of the module role:
The role of the module is represented by a number:
0 - slave, 1 - presenter, 2 - slave in the cycle *.
An example of a response: + Role: 1 \\ R \\ N
Installation example: AT + ROLE \u003d 0 \\ R \\ N
AT + ROLE \u003dThe role \\ r \\ n Ok \\ r \\ n
Class AT + CLASS?\\ r \\ n + Class: A TYPE\\ r \\ n
Ok \\ r \\ n
Request / installation of the device type:
The device type is represented by a 32 bit number by which you can define a module assignment: Bluetooth keyboard, Bluetooth mouse, headset ...
Installation Example: AT + Class \u003d 0 \\ R \\ N
AT + Class \u003dType \\ R \\ n Ok \\ r \\ n
IAC AT + IAC?\\ r \\ n + Iac: THE CODE\\ r \\ n ok \\ r \\ n Request / Set code general access Giac:
The code is represented by a 32 bit number and is used to detect Bluetooth devices.
In the role of the lead this code The module will access other Bluetooth devices for their search (survey), and in the role of the slave on this code will be provided with access to a survey of the module by other leading.
An example of an answer: + iac: 9e8b33 \\ r \\ N OK \\ R \\ N
An example of installation: AT + IAC \u003d 9E8B33 \\ R \\ N
AT + IAC \u003dCode \\ r \\ n Ok \\ r \\ n
or
Fail \\ r \\ n
Inqm. AT + INQM?\\ r \\ n + Inqm: MODE,Count,TIME\\ r \\ n
Ok \\ r \\ n
Query / Installing the Module Survey Mode:
The parameters used are settings for the search command (survey) of other Bluetooth devices.
- Search mode is represented by a number:
0 standard, 1-search signal intensity.
- The number is represented by a number of defining the limit number of Bluetooth devices found, after which you want to stop the search.
- The search time sets the timeout after which the search stops. Real time Search in seconds equal to the specified number multiplied by 1.28.
An example of an answer: + Inqm: 1,1,48 \\ R \\ N OK \\ R \\ N
Installation Example: AT + INQM: 1,1,48 \\ R \\ N
AT + INQM \u003dMode, count, time \\ r \\ n Ok \\ r \\ n
or
Fail \\ r \\ n
PSWD. AT + PSWD?\\ r \\ n + PSWD: THE CODE\\ r \\ n
Ok \\ r \\ n
Request / Installing PIN-code:
Access code is represented by a string up to 16 bytes.
The code of the module as a slave device is a password access to the current module.
The code of the module as a master device is a password access to external Bluetooth devices.
An example of a response: + PSWD: 1234 \\ R \\ N OK \\ R \\ N
Installation Example: AT + PSWD \u003d 1234arduino \\ r \\ n
AT + PSWD \u003dCode \\ r \\ n Ok \\ r \\ n
UART. AT + UART?\\ r \\ n + Uart: Soon,STOP,Prov\\ r \\ n
Ok \\ r \\ n
Question / installation speed UART:
The speed is represented by the number of bits / s
Stop bit is represented by a number: 0 - one, 1 - two
Check is represented by a digit: 0 - without checking,
1 - Interactivity check, 2 - Readability.
An example of an answer: + Uart: 38400,0,0 \\ R \\ N OK \\ R \\ N
An example of installation: AT + UART \u003d 38400,0.0 \\ R \\ N
At + uart \u003dSumps, stop, prov \\ r \\ n Ok \\ r \\ n
CMode. AT + CMode?\\ r \\ n + CMOD: MODE\\ r \\ n
Ok \\ r \\ n
Request / Set Connection Mode:
Mode is represented by a number:
0 - The module in the role of the master connects only to that Bluetooth device, the address of which is specified by the AT + BIND command.
1 - The module in the role of the host connects to any Bluetooth device driven.
2 - The module in the role of the slave works in the cycle *
An example of an answer: + CMOD: 0 \\ R \\ N OK \\ R \\ N
Installation Example: AT + CMOD \u003d 1 \\ R \\ N
AT + CMode \u003dMode \\ R \\ N Ok \\ r \\ n
Bind. AT + BIND?\\ r \\ n + Bind: ADDRESS\\ r \\ n
Ok \\ r \\ n
Request / installation of a fixed address:
If the module is in the role of the master (Role \u003d 1) and the connection mode is set to a fixed address (CMode \u003d 0), it will only be connected to that Bluetooth to the device whose address is specified by this command.
Parts of the address are entered: when installing - through a comma, and when responding - through a colon.
Answer example: + Bind: 1234: 56: 789ABC \\ R \\ N OK \\ R \\ N
An example of installation: AT + BIND \u003d 0.0.0 \\ R \\ N
AT + BIND \u003dAddress \\ R \\ n Ok \\ r \\ n
POLAR AT + POLAR?\\ r \\ n + Polar: Log.,Log.\\ r \\ n
Ok \\ r \\ n
Request / setting an active logical level to turn on LEDs:
Polarity is represented by a number 0 or 1 corresponding to the active logical level.
The first parameter specifies the logical level to turn on the LED connected to the PiO8 output (displays the operation mode), and the second for the LED connected to the PiO9 output (displays the connection status).
An example of an answer: + Polar: 1.1 \\ R \\ N OK \\ R \\ N
Installation Example: AT + POLAR \u003d 1.1 \\ R \\ N
AT + POLAR \u003dLog, log \\ r \\ n Ok \\ r \\ n
Pio. AT + PIO \u003dNumber, level \\ R \\ n Ok \\ r \\ n Installing the logical level PIO:
Allows you to set the logical level on the PIO output. The output number is represented by a number from 2 to 11, except 8 and 9. The level is represented by a number 0 or 1.
An example of installation: AT + PIO \u003d 11.0 \\ R \\ N
MPIO. AT + MPIO?\\ r \\ n + Mpio: NUMBER\\ r \\ n
Ok \\ r \\ n
Quest / installation of logical levels PIO:
Allows you to learn or set logical levels at all PIO outputs.
The levels are represented by a hexadecimal number, each bit of which corresponds to the PIO output level.
An example of an answer: + MPIO: 1F0 \\ R \\ N OK \\ R \\ N
Installation Example: AT + MPIO: CFC \\ R \\ N
AT + MPIO \u003dNumber \\ r \\ n Ok \\ r \\ n
Ipscan. AT + IPSCAN?\\ r \\ n + Ipscan: BUT,B.,IN,G.\\ r \\ n
Ok \\ r \\ n
Request / setting IP scan settings:
A - scan interval
B - scanning duration
B - page interval
G - number of pages
An example of an answer: + ipscan: 1024,512,1024,512 \\ r \\ n ok \\ r \\ n
Installation example: AT + IPSCAN: 1024,512,1024,512 \\ R \\ n
AT + IPSCAN \u003dA, B, B, G \\ R \\ N Ok \\ r \\ n
Sniff. AT + SNIFF?\\ r \\ n + Sniff: BUT,B.,IN,G.\\ r \\ n
Ok \\ r \\ n
Request / setting the parameters of the energy-saving mode:
A - Maximum Time
B - Minimum time
In - repetition period
Mr. Taimaut
An example of an answer: + Sniff: 0,0,0,0 \\ r \\ N OK \\ R \\ N
Installation example: AT + Sniff \u003d 0.0.0.0 \\ r \\ n
AT + Sniff \u003dA, B, B, G \\ R \\ N Ok \\ r \\ n
Ensniff. AT + ENSNIFF \u003dAddress \\ R \\ n Ok \\ r \\ n Transition to energy-saving mode:

Sample Team: AT + ENSNIFF \u003d 1234,56,789ABC \\ R \\ N
Exsniff. AT + Exsniff \u003dAddress \\ R \\ n Ok \\ r \\ n Exit from the energy saving mode:
Parts of the address are entered through commas (NAP, UAP, LAP)
Example of the command: AT + ExSniff \u003d 1234,56,789ABC \\ R \\ N
Senm. AT + SENM?\\ r \\ n + Senm: SECRET,CIPHER\\ r \\ n
Ok \\ r \\ n
Quest / installation of security parameters:
Secrecy mode is represented by a number:
0 - off
1 - unprotected connection
2 - protection at the service level
3 - Protection at the connection level
4 - Unknown Mode
Encryption mode is represented by a number:
0 - without encryption
1 - only PTP traffic is encrypted
2 - All traffic is encrypted
An example of a response: + Senm: 0.0 \\ R \\ N OK \\ R \\ N
Installation Example: AT + SENM: 0.0 \\ R \\ N
AT + SENM \u003dSecret, cipher \\ r \\ n Ok \\ r \\ n
PMSAD. AT + PMSAD \u003dAddress \\ R \\ n Ok \\ r \\ n Deleting a device from a list of pairs:
Deleting a Bluetooth device from the list will see the need to re-form a pair to connect to it.
Parts of the address of the device being removed is entered through a comma (NAP, UAP, LAP)
Sample Team: AT + PMSAD \u003d 1234,56,789ABC \\ R \\ N
Rmaad. AT + RMAAD.\\ r \\ n Ok \\ r \\ n Deleting all devices from the list of pairs:
Cleaning this list Will the need to re-form pairs with Bluetooth devices for connecting to them.
FSAD. AT + FSAD \u003dAddress \\ R \\ n Ok \\ r \\ n
or
Fail \\ r \\ n
Search device in the list of pairs:
If a Bluetooth device with specified address It is in the list, the module will return OK \\ R \\ N otherwise FAIL \\ R \\ N.
Parts of the address are entered through commas (NAP, UAP, LAP)
Request Example: AT + FSAD \u003d 1234,56,789ABC \\ R \\ N
ADCN. AT + ADCN?\\ r \\ n + ADCN: QUANTITY\\ r \\ n
Ok \\ r \\ n
Request for the number of devices in the list of couples:
When making a pair-led pair, the pair data automatically falls into the list of pairs and for subsequent connections (even after turning off the power) is not required to re-install a pair.
An example of an answer: + ADCN: 10 \\ R \\ N OK \\ R \\ N
Mrad. AT + MRAD?\\ r \\ n + MRAD: ADDRESS\\ r \\ n
Ok \\ r \\ n
Request device address from the list of pairs:
The module will return the Bluetooth address of the device from the list of pairs with which the last successful connection was performed.
Parts of the address are displayed through a colon (NAP: UAP: Lap)
An example of a response: + MRAD: 1234: 56: 789ABC \\ R \\ N OK \\ R \\ N
State AT + State?\\ r \\ n + State: STATUS\\ r \\ n
Ok \\ r \\ n
Module status request:
The module will return its current status as a string:
Initialized - Initialization
Ready - Ready
Pairable - Education Couple
Paired - Couple is formed
Inquiring - Request
Connecting - Connection
Connected - connected
Disconnected - disconnected
NUKNOW - Unknown State
An example of an answer: + state: Connected \\ R \\ N OK \\ R \\ N
Init AT + Init.\\ r \\ n Ok \\ r \\ n
or
Fail \\ r \\ n
SPP profile initialization:
SPP profile emulates a serial port.
INQ. AT + INQ.\\ r \\ n + INQ: address, type, signal \\ r \\ n
+ INQ: address, type, signal \\ r \\ n
...
+ Inq: address, type, signal \\ r \\ n
Search (survey) Bluetooth devices:

The module is looking for a Bluetooth device in the action radius and outputs each found module on a new row. Search mode (survey) is set by the AT + INQM command, the survey code is set by the AT + IAC command, the type of desired devices is specified by the AT + Class command. The search is completed upon reaching the limit number of Bluetooth devices found, or when you reach the timeout, or the AT + InQC command.
Response example: + Inq: 1234: 56: 789ABC, 240404.7FFF
Inqc. AT + INQC.\\ r \\ n Ok \\ r \\ n Complete the search (survey) Bluetooth devices:
Early completing the Bluetooth device searching devices initiated by the AT + INQ command
Pair. AT + PAIR \u003dAddress, Taymouth \\ R \\ N Ok \\ r \\ n
or
Fail \\ r \\ n
Create a pair with a Bluetooth device:
Creating a pair or bluetooth pairing Devices are initiated by the master.
Timeout is indicated by a decimal number in seconds.
If the pair is created, then information about it will be automatically recorded in the list of steam, the module will answer OK \\ R \\ N after which you can connect the Bluetooth device by the AT + LINK command. If the pair is not created (for example, a PIN code or timeout has expired), the module will respond Fail \\ R \\ N.
Sample Team: AT + PAIR \u003d 1234,56,789ABC, 10 \\ R \\ N
LINK. AT + Link \u003dAddress \\ R \\ n Ok \\ r \\ n
or
Fail \\ r \\ n
Connect to Bluetooth device:
After executing this command, you can communicate with a Bluetooth device connected.
The command is available to the module as a master.
Sample Team: AT + Link \u003d 1234,56,789ABC \\ R \\ N
DISC AT + DISC.\\ r \\ n + Disc: RESULT\\ r \\ n
Ok \\ r \\ n
Disconnect from Bluetooth Devices:
The command indicates the module to disconnect from the Bluetooth device with which the connection is set. After disconnecting from the Bluetooth device, information about it is saved in the list of steam. If you need to re-connect to this device again, the creation of the pair will optionally (if the Bluetooth device is intentionally not removed from the list of pairs).
After executing the command, the module will respond by the result of its execution:
Success - Success
Link_loss - the connection is lost
No_slc - missing SLC
Timeout - Expired Waiting Time
Error - Error
An example of a response: + Disc: Success \\ R \\ N OK \\ R \\ N

* Slave in the cycle - This is a leading role of the module in which it sends all that receives from the lead.
** For some commands, the module responds only when the module button is pressed or the presence of a high level at the output K.

Description of errors issued by the module:

If you send a command that the module does not know cannot, or the command is wrong arguments, the module will return the string "Error :( NUMBER) ", Where, according to the specified sixteen digital number, you can determine what the module" swears ".

Error No. Error description
0 Wrong AT command (no such command)
1 The result is default
2 Password save error
3 Too long device name (more than 32 bytes)
4 The device name is not specified.
5 Part of the NAP address is too long (more than 4 digits in the hexadecimal system)
6 Part of the UAP address is too long (more than 2 discharges in the hexadecimal system)
7 Part of the Lap address is too long (more than 6 digits in the hexadecimal system)
8 Not specified PIO port mask
9 The PIO output number is not specified.
A. Not specified Type (class) device
B. Too long type (class) device
C. Not specified General IAC Access Code (Inquire Access Code)
D. Too long shared IAC Access Code (Inquire Access Code)
E. Invalid Shared Access Code IAC (Inquire Access Code)
F. Not specified password (or password is empty)
10 Too long password (more than 16 bytes)
11 Invalid module role
12 Invalid data transfer rate
13 Invalid Stop Bit Size
14 Invalid parity bit setting
15 The device is missing in the list of pairs (list of conjugate Bluetooth devices)
16 Serial Port Profile (SPP, Serial Port Profile) is not initialized
17 SPP profile re-initialization (SPP, Serial Port Profile)
18 Invalid mode Bluetooth polling devices
19 Too long survey time
1A. Not specified Bluetooth address device
1b. Invalid security regime (secrecy)
1C. Invalid encryption mode

Note:

If you press the button or submit a high level to the input K directly at the time of turning on the module (power supply), the module will switch to AT commands. In this mode, the module will not connect to other modules, but this mode has a fixed speed \u003d 38400 bits / s. If when setting up, in the normal mode of operation of the module, you could not determine the module speed, then you can enter this mode and set a new speed. The newly installed speed will take effect only in normal mode, for this it will be necessary to restart the module without holding the button and without feeding the high level to the input K at the time of inclusion. Remember that in the usual mode, not earlier than in a second second after powering (or rebooting), you must briefly press the button or submit a short-term high level to the input K module, otherwise it will not perceive the AT commands.

If you want to have the ability to "click" on the program, but your module has no output k, use the command AT + PIO \u003d 11, level\\ r \\ n where the level seems to be 1 or 0 corresponding to the logical level installed. ( AT + PIO \u003d 11.0\\ R \\ N - The button is released , AT + PIO \u003d 11.1\\ R \\ N - button pressed).

Some modules have an EN output that controls the power and tighten to the VCC. If the EN output is a low logical level, then the power of chips will turn off. This output You can use for software entry into AT commands. If immediately after removing the low level from the EN output to file the AT + PIO \u003d 11.1 \\ R \\ N command, it will be equivalent to turning on the module with the button pressed.

Creating a driven waiting for the host connection:

  • AT + DISC.
  • AT + ORGL
  • AT + RMAAD.\\ R \\ N - Clear a list of pairs (authorized devices) To the module did not connect the one who disconnected.
  • AT + NAME \u003doreuino \\ r \\ n - set the name of the module (no more than 32 characters).
  • AT + PSWD \u003d1234 \\ R \\ n - install PIN for connecting to module (no more than 16 characters).
  • AT + ROLE \u003d 0\\ r \\ n - install the role of the slave (if it is not installed when the user settings is reset).
  • AT + Reset.\\ R \\ n - restart the module.

No earlier than in a second second after rebooting (team AT + Reset.\\ r \\ n) You need to briefly press the button or submit a short-term high level to the input of the K module, otherwise it will not perceive new AT commands.

If the module with a leading role is connected to the slave modules to their address, and not through their name, then the address of this (slave) module can be found by executing the AT + ADDR command? \\ R \\ n.

Creating a host with a connection to the slave:

  • AT + DISC.\\ r \\ n - break the connection (in case the module is connected).
  • AT + ORGL\\ r \\ n - reset user settings to default values.
  • AT + RMAAD.\\ R \\ N - Clear the list of pairs (authorized devices) To the module did not try to connect to that from whom disconnected.
  • AT + BIND \u003dAddress \\ R \\ n - set a fixed address to connect (specify the address of the driven Bluetooth device)
  • AT + CMode \u003d 0\\ R \\ n - specify the module to connect only to a fixed address
  • AT + ROLE \u003d 1\\ R \\ n - install the role of the master device
  • AT + PSWD \u003d1234 \\ R \\ N - Remember PIN Slave Bluetooth Device
  • AT + PAIR \u003dAddress, 10 \\ r \\ n - form a pair with a slave Bluetooth device by specifying its address and timeout 10 seconds
  • .


Did you like the article? Share it