KS0355 keyestudio HC-08 Bluetooth Module: Difference between revisions

From Keyestudio Wiki
Jump to navigation Jump to search
 
(36 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[image:UNO R3--.png|thumb|600px|right|Keyestudio UNO R3 Board]]
[[image:KS0355.png|thumb|600px|right|Keyestudio HC-08 Bluetooth Module]]




== Overview==
== Overview==
Keyestudio HC-08 Bluetooth module is a new digital transmission module, based on the Bluetooth Specification V4.0 BLE Bluetooth protocol.
Keyestudio HC-08 Bluetooth module is a new digital transmission module, based on the Bluetooth Specification V4.0 BLE Bluetooth protocol.<br>
Its wireless working frequency band is 2.4GHz ISM, and the modulation method is GFSK.  
Its wireless working frequency band is 2.4GHz ISM, and the modulation method is GFSK. <br>
The module's default transmit power is 4dBm. Receive sensitivity -93dBm.  
The module's default transmit power is 4dBm. Receive sensitivity -93dBm. <br>
The module is compatible with both Android and Apple systems. In an open environment, it can communicate with iphone4s, to achieve ultra-long-distance communication of 80 meters.
The module is compatible with both Android and Apple systems. In an open environment, it can communicate with iphone4s, to achieve ultra-long-distance communication of 80 meters.
It also comes with an LED status indicator. When using, you can directly see the connection state of Bluetooth.
It also comes with an LED status indicator. When using, you can directly see the connection state of Bluetooth.<br>
The module uses the CC2540F256 chip from TI, configured with 256K bytes of space, supporting the AT command. For need, the users can change the role (master or slave mode), baud rate of serial port, device name and other parameters, very flexible use.
The module uses the CC2540F256 chip from TI, configured with 256K bytes of space, supporting the AT command. For need, the users can change the role (master or slave mode), baud rate of serial port, device name and other parameters, very flexible use.
<br>[[File:Ks0355-图片1.png|800px|frameless|thumb]]<br>
== Detailed Interface==
<br>[[File:KS0355 HC-08蓝牙 (9).jpg|700px|frameless|thumb]]<br>




Line 33: Line 38:
* Slave MODE1, not connected / connected: 6μA ~ 2.6mA / 1.6mA
* Slave MODE1, not connected / connected: 6μA ~ 2.6mA / 1.6mA
* Slave MODE2, not connected / connected: 0.4μA/1.6mA
* Slave MODE2, not connected / connected: 0.4μA/1.6mA
'''Extra:'''
*Compatible with Android and Apple System  <br>
*Environmental-friendly
==Dimensions==
*Dimensions: 49mm*17mm*7mm
<br>[[File:Ks0355-图片2.png|700px|frameless|thumb]]<br>




==AT Command Settings==
==AT Command Settings==
Before setting the AT command, for hardware, you need a USB to serial module (such as FT232 module) and several DuPont lines. For software, need a serial port assistant software, and install well the driver for the USB to serial module.
Before setting the AT command, for hardware, you need a USB to serial module (such as [http://www.keyestudio.com/ks0277.html  FT232 module ] ) and several DuPont lines. For software, need a serial port assistant software, and install well the driver for the USB to serial module.<br>
First, connect the Bluetooth module to FT232 module using DuPont line. The connection method is as follows.
First, connect the Bluetooth module to FT232 module using DuPont line. The connection method is as follows.
{| width="50%" cellspacing="0" border="1"
{| width="50%" cellspacing="0" border="1"
Line 65: Line 79:
|}
|}


Connected well, then connect the FT232 module (drive installation completed) to the computer using a USB cable.  
Connected well, then connect the FT232 module (drive installation completed) to the computer using a USB cable. <br>
First right-click the computer, for properties ->Device Manager to find the corresponding COM port. Then open the serial port assistant software, set the COM port, and the baud rate (initial default 9600).
First right-click the computer, for '''properties''' ->'''Device Manager''' to find the corresponding COM port. Then open the serial port assistant software, set the COM port, and the baud rate (initial default 9600).<br>
After the connection is successful, you can start to set the AT command according to the instructions.
After the connection is successful, you can start to set the AT command according to the instructions.
 


==AT Command Instructions==
==AT Command Instructions==
===1)Testing Instruction===
===1)Testing Instruction===


Line 86: Line 101:
|-
|-
|}
|}


===2)Check the basic parameters===
===2)Check the basic parameters===
Line 105: Line 121:
|-
|-
|}
|}


===3)Factory Data Reset Instruction===
===3)Factory Data Reset Instruction===
Line 122: Line 139:
|-
|-
|}
|}


===4)Module Restart Instruction===
===4)Module Restart Instruction===
Line 138: Line 156:
|-
|-
|}
|}


===5)Check the software version===
===5)Check the software version===
Line 173: Line 192:
Send: AT+ROLE=M  Return: Master ( to restart)<br>
Send: AT+ROLE=M  Return: Master ( to restart)<br>
Send: AT+ROLE=?  Return: Master (without restart)<br>
Send: AT+ROLE=?  Return: Master (without restart)<br>


===7)Inquire and Modify the Bluetooth Name===
===7)Inquire and Modify the Bluetooth Name===
Line 192: Line 212:
|}
|}
Send: AT+NAME=?  Return: OK+NAME=HC-08<br>
Send: AT+NAME=?  Return: OK+NAME=HC-08<br>
Send: AT+NAME=keyestudioReturn: OKsetNAME<br>
Send: AT+NAME=keyestudio Return: OKsetNAME<br>
Send: AT+NAME=?  Return: OK+NAME=keyestudio<br>
Send: AT+NAME=?  Return: OK+NAME=keyestudio<br>


Line 212: Line 232:
|-
|-
|}
|}
Send: AT+ADDR=?  Return: xxxxxxxxxxxx(current Bluetooth address of module)<br>
Send: AT+ADDR=?  Return: xxxxxxxxxxxx(current Bluetooth address of module)<br>
Send: AT+ADDR=AABBCCDDEEFF  Return: OKsetADDR<br>
Send: AT+ADDR=AABBCCDDEEFF  Return: OKsetADDR<br>
Send: AT+ADDR=?  Return: AA,BB,CC,DD,EE,F<br>
Send: AT+ADDR=?  Return: AA,BB,CC,DD,EE,F<br>
===9)Inquire and Modify the RF Power===
{| width="50%" cellspacing="0" border="1"
|-
! align="center" scope="col" | Command
! align="center" scope="col" | Response
! align="center" scope="col" | Instruction
|-
|-
| align="center" | AT+RFPM=x
| align="center" | 4dBm(0 dBm /-6 dBm / -23dBm)
| align="Light" | Query/set the RF power of the module<br>
'''Note:''' the parameter x is as shown in the table below.<br>
And query and settings are represented by a code name.
|-
|}
Send: AT+RFPM=?  Return: 4dBm (query RF Power is 4dBm)<br>
Send: AT+RFPM=2  Return: OK (set the RF Power as -6dBm)<br>
Send: AT+RFPM=?  Return: -6dBm (query RF Power is -6dBm)<br>
'''x''' is the code name of RF power, shown as the table below: <br>
{| width="50%" cellspacing="0" border="1"
|-
| align="center" | parameter'''x'''
| align="center" | RF power transmitting power
|-
|-
| align="center" | ?
| align="center" | view the current RF power
|-
|-
| align="center" | 0
| align="center" | 4dBm(factory default)
|-
|-
| align="center" | 1
| align="center" | 0dBm
|-
|-
| align="center" | 2
| align="center" | -6dBm
|-
|-
| align="center" | 3
| align="center" | -23dBm
|-
|}
===10)Inquire and Modify the Serial Baud Rate===
{| width="50%" cellspacing="0" border="1"
|-
! align="center" scope="col" | Command
! align="center" scope="col" | Response
! align="center" scope="col" | Instruction
|-
|-
| align="center" | AT+BAUD=xx(or AT+BAUD=xx,y)
| align="center" | OK9600
| align="Light" | Serial port settings<br>
'''Note:''' as shown in the following table, the parameters '''xx''' and '''y''' respectively represent the Baud rate and check bit.
|-
|}
Send: AT+BAUD=?  Return: 9600,NONE<br>
Send: AT+BAUD=19200,E  Return: OK19200,EVEN<br>
(set the parameter of serial port as:  baud rate 19200, even-parity check)<br>
'''xx''' represents the serial baud rate, '''y''' represents the check bit. As the table shown below:<br>
{| width="50%" cellspacing="0" border="1"
|-
| align="center" | parameter
| align="center" | serial baud rate '''xx'''
| align="center" | parameter
| align="center" | check bit '''y'''
|-
|-
| align="center" | ?
| align="center" | view the current baud rate
| align="center" |
| align="center" |
|-
|-
| align="center" | 1200
| align="center" | 1200bps
| align="center" | N
| align="center" | NONE
|-
|-
| align="center" | 2400
| align="center" | 2400bps
| align="center" | E
| align="center" | EVEN
|-
|-
| align="center" | 4800
| align="center" | 4800bps
| align="center" | O
| align="center" | ODD
|-
|-
| align="center" | 9600
| align="center" | 9600bps(factory default)
| align="center" |
| align="center" |
|-
|-
| align="center" | 19200
| align="center" | 19200bps
| align="center" |
| align="center" |
|-
|-
| align="center" | 38400
| align="center" | 38400bps
| align="center" |
| align="center" |
|-
|-
| align="center" | 57600
| align="center" | 57600bps(factory default)
| align="center" |
| align="center" |
|-
|-
| align="center" | 115200
| align="center" | 115200bps
| align="center" |
| align="center" |
|-
|}
When the host and slave transmit communication, please do not exceed 500 bytes for each data package below 9600bps baud rate. <br>
For the maximum number of bytes per packet above 19200bps baud rate, please refer to the following table. <br>
There is a certain time interval among the data packets. The following table is the reference value for the time interval for various communication baud rates:
{| width="60%" cellspacing="0" border="1"
|-
| align="center" | baud rates (bps)
| align="center" | 1200
| align="center" | 2400
| align="center" | 4800
| align="center" | 9600
| align="center" | 19200
| align="center" | 38400
| align="center" | 57600
| align="center" | 115200
|-
|-
| align="center" | send 500 bytes time interval (ms)
| align="center" | 6800
| align="center" | 3600
| align="center" | 2000
| align="center" | 1000
| align="center" |
| align="center" |
| align="center" |
| align="center" |
|-
|-
| align="center" | send 300 bytes time interval (ms)
| align="center" | 4200
| align="center" | 2400
| align="center" | 1200
| align="center" | 600
| align="center" | 400
| align="center" |
| align="center" |
| align="center" |
|-
|-
| align="center" | send 100 bytes time interval (ms)
| align="center" | 1500
| align="center" | 80
| align="center" | 400
| align="center" | 160
| align="center" | 100
| align="center" | 120
| align="center" |
| align="center" |
|-
|-
| align="center" | send 80 bytes time interval (ms)
| align="center" | 1000
| align="center" | 650
| align="center" | 320
| align="center" | 120
| align="center" | 80
| align="center" | 60
| align="center" | 100
| align="center" |
|-
|-
| align="center" | send 60 bytes time interval (ms)
| align="center" | 800
| align="center" | 500
| align="center" | 250
| align="center" | 100
| align="center" | 60
| align="center" | 60
| align="center" | 60
| align="center" | 100
|-
|-
| align="center" | send 20 bytes time interval (ms)
| align="center" | 200
| align="center" | 100
| align="center" | 50
| align="center" | 20
| align="center" | 20
| align="center" | 20
| align="center" | 20
| align="center" | 20
|-
|}
===11)Inquire and set the module whether connectable===
{| width="50%" cellspacing="0" border="1"
|-
! align="center" scope="col" | Command
! align="center" scope="col" | Response
! align="center" scope="col" | Instruction
|-
|-
| align="center" | AT+CONT=x
| align="center" | OK/Connectable/Non-Connectable
| align="Light" | Set the connectability.<br>
Non-connectable is mainly used for broadcast data.
|-
|}
Send: AT+CONT=?    Return: Connectable(query result “connectable”)<br>
Send: AT+CONT=1    Return: OK  (set the “Non-connectable” successfully)<br>
The functions of parameter '''x''' is as follows: <br>
{| width="50%" cellspacing="0" border="1"
|-
| align="center" | Parameter
| align="center" | Master
| align="Light" | Slave
|-
|-
| align="center" | 0(default)
| align="center" | (Central)<br>
Connectable, enter the normal transmission mode after connection.
| align="Light" | (Peripheral)<br>
Connectable, enter the normal transmission mode after connection.
|-
|-
| align="center" | 1
| align="center" | (Observer)<br>
The current module cannot connect to other modules or devices, but it will automatically scan the broadcast packet of HC-08 slave and refresh once per 2s.
| align="Light" | (Broadcaster)<br>
cannot connect to the host, but it can be combined with low power mode 1 for broadcast packet transmission.
|-
|}
Please usewith the "AT+MODE", "AT+AVDA" and "AT+AINT" instructions to reach the best results.<br>
'''1.''' For the Master/Slave, CONT=1 is used to transmit the broadcast data. The Slave sends the broadcast data, and the Master receives the corresponding broadcast data and outputs it through the serial port.<br>
'''2.''' This mode is only for the HC-08 module, or for those users who have Android development capabilities and can grab this packet themselves.
===12)Update broadcast data instruction (only set by Slave )===
{| width="50%" cellspacing="0" border="1"
|-
! align="center" scope="col" | Command
! align="center" scope="col" | Response
! align="center" scope="col" | Instruction
! align="center" scope="col" | Details
|-
|-
| align="center" | AT+AVDA=xxx
| align="center" | OK
| align="Light" | Set the broadcast data
| align="Light" | '''1.''' The parameter "xxx" can be any user data of 1~12 bytes. If the Master status AT+CONT=1 at this time, the Master serial port will output xxx data. This broadcast data will not be saved permanently and will expire after the module is restarted.<br>
'''2.''' Since the Master is fixed for 2s scanning, the broadcast data received from the same Slave can be output only once in 2s. Moreover, this mode is characterized by "continuous broadcast from the Slave and continuous scanning by the Master", so the Master will continuously output data.<br>
'''3.''' The higher the broadcast density of the slave, the easier the data is received by the Master. The higher the broadcast density, the higher the power consumption of the Slave.
|-
|}
Send: AT+AVDA=1234567890AB    Return: OK  <br>
If at this moment, for Master, AT+CONT=1, and successfully scan the broadcast from the Slave, the serial port will output: 1234567890AB
===13)Inquiry and modify the power consumption mode (only set by Slave )===
{| width="50%" cellspacing="0" border="1"
|-
! align="center" scope="col" | Command
! align="center" scope="col" | Response
! align="center" scope="col" | Instruction
|-
|-
| align="center" | AT+MODE=x
| align="center" | OK/Connectable/Non-Connectable
| align="Light" | Set the power consumption <br>
'''Note:''' only set by Slave
|-
|}
Send: AT+MODE=?  Return: 0/1/2
Send: AT+MODE=1  Return: OK
The functions of parameter '''x''' is as follows:
{| width="50%" cellspacing="0" border="1"
|-
! align="center" scope="col" | parameter
! align="center" scope="col" | Return
! align="center" scope="col" | Explanations
|-
|-
| align="center" | ?
| align="center" | 0/1/2
| align="Light" | Gain the current power consumption mode
|-
|-
| align="center" | 0
| align="center" | OK
| align="Light" | Full power consumption mode(factory default)
|-
|-
| align="center" | 1
| align="center" | OK
| align="Light" | Primary energy saving mode.<br>
Before connection, the current is determined by the setting of AT+AINT. After connection, mainly determined by AT+CINT.<br>
The MODE1 already covers the MODE3 of V2.4 version, and more reasonable!
|-
|-
| align="center" | 2
| align="center" | OK
| align="Light" | Secondary energy saving mode (sleep mode). <br>
The current during sleep is 0.4μA.<br>
It can't be found and can't be connected during sleep. It can be found and connected after activatedby the serial port.
|-
|}
'''Note:'''
'''1.''' Power consumption mode 1 is mainly used for:<br>
''A.'' The main low-power mode of module, can provide low-power standby for transparent transmission, and can also be used as low-power broadcast data.<br>
''B.'' The Slave broadcasts data to the Master, supporting one-to-many single communication (in theory, one slave can send to an unlimited number of master. <br>
If you want to receive more data from slave, it is recommended to set a high baud rate).<br>
''C.'' For wireless reading devices such as anti-lost device, check-in card, heart rate meter, etc.<br>
'''2.''' Power mode 1 and mode 2 can be activated by sending more than 1 byte of data through the serial port, but the first few bytes of data may be garbled. <br>
Therefore, it is recommended to send a 10-byte hexadecimal code "0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF" to wake up the module, avoiding the first few garbled bytes. <br>
After that, the module works in full speed mode, and the serial port can send and receive data normally.<br>
In the unconnected state, the module wakes up and enters full speed mode for 20 seconds (default, can be adjusted by AT command), and then returns to the original power mode.<br> As long as the serial port has received data within 20 seconds, it will be re-timed.<br>
If the module is connected, it will remain in full speed mode after waking up. It will return to the original power mode unless disconnection.
===14)Set the broadcast interval instruction===
{| width="50%" cellspacing="0" border="1"
|-
! align="center" scope="col" | Command
! align="center" scope="col" | Response
! align="center" scope="col" | Instruction
! align="center" scope="col" | Details
|-
|-
| align="center" | AT+AINT=xx
| align="center" | OK+AINT=xx
| align="Light" | Query/set up the broadcast interval (affect the power consumption when not connected)
| align="Light" | The unit of xx is 625us (that is, if xx=1, the broadcast interval is 625us*1=625us). <br>
The range is 32~16000.(equivalent to 20ms~10s). <br>
Default: 320 (i.e. 200ms)
|-
|}
Input: AT+AINT=?    Return: OK+AINT=320 <br>
Input: AT+AINT=1600  Return: OK+AINT=1600 (modify the broadcast interval as 1000ms)<br>
'''Note:''' The instruction AT+AINT replaces AT+TIME of V2.4 version to set the broadcasting cycle, which can set the interval TIME more accurate.
===15)Inquire and set the connection interval===
{| width="50%" cellspacing="0" border="1"
|-
! align="center" scope="col" | Command
! align="center" scope="col" | Response
! align="center" scope="col" | Instruction
! align="center" scope="col" | Details
|-
|-
| align="center" | AT+CINT=x,y
| align="center" | OK+CINT=x,y
| align="Light" | Query/set up the connection interval
(directly affect the connection power, the master need to set at the same time)
| align="Light" | '''x:''' minimum connection interval; '''y:''' maximum connection interval.<br>
'''Unit:''' 1.25ms;<br> '''Setting range:''' 6~3199 (7.5ms~4s).<br>
'''1.''' This value directly affects the actual connection interval: x ≤ actual connection interval ≤y<br>
'''2.''' must meet theconditions: x≤y<br>
'''3.''' You can separatelyenter a parameter x. If at this time the recorded y<x, y will be directly equal to x.<br>
'''4.''' Default value: 6,12
|-
|}
Input: AT+CINT=?  Return:OK+CINT=6,12 (Query the minimum connection interval is 1.25*6=7.5ms, the maximum connection interval is 1.25*12=15ms)<br>
Input:AT+CINT=16,32  Return:OK+CINT=16,32 (Set the connection interval to 20ms~40ms)<br>
Input:AT+CINT=80  Return:OK+CINT=80,80 (set the connection interval to 100ms)<br>
===16)Inquire and set the connection timeout===
{| width="50%" cellspacing="0" border="1"
|-
! align="center" scope="col" | Command
! align="center" scope="col" | Response
! align="center" scope="col" | Instruction
! align="center" scope="col" | Details
|-
|-
| align="center" | AT+CTOUT=x
| align="center" | OK+CTOUT=x
| align="Light" | Query/set connection timeout
| align="Light" |'''Unit:''' 10ms;  <br>
'''Range:''' 10-3200 (100ms - 32s).<br>
This value directlyaffects the time of disconnection, that is, the time of"unexpecteddisconnection".(active disconnection is not affected by this value)<br>
'''Default value:''' 200
|-
|}
Input: AT + CTOUT =? Return: OK+CTOUT=200 (query connection timeout is 10ms*200=2s)<br>
Input: AT+CTOUT=100  Return: OK+CTOUT=100<br>
===17)Clear the recorded slave address only by Master===
{| width="50%" cellspacing="0" border="1"
|-
! align="center" scope="col" | Command
! align="center" scope="col" | Response
! align="center" scope="col" | Instruction
! align="center" scope="col" | Details
|-
|-
| align="center" | AT+CLEAR
| align="center" | OK
| align="Light" | Clear the memory address, equivalent to the key function.<br>
| align="Light" |As long as the master has connected to the slave, it remembers the address of the last connected slave. <br>
If you want to connect to other slaves, you must clear the current memory of slave address. <br>
There are two methods to clear the memory. One is to connect the module’s 18-pin (KEY pin) to a High level of 200mS or more. The other is to input the AT+CLEARcommand in the unconnected state.
|-
|}
As long as the master has connected to the slave, it remembers the address of the last connected slave. <br>
If you want to connect to other slaves, you must clear the current memory of slave address. <br>
There are two methods to clear the memory. One is to connect the module’s 18-pin (KEY pin) to a High level of 200mS or more. The other is to input the '''AT+CLEAR''' command in the unconnected state.<br>
===18)Inquiry and set the LED ON/OFF instruction===
{| width="50%" cellspacing="0" border="1"
|-
! align="center" scope="col" | Command
! align="center" scope="col" | Response
! align="center" scope="col" | Instruction
! align="center" scope="col" | Details
|-
|-
| align="center" | AT+LED=x
| align="center" | OK+LED=x
| align="Light" | Query/set LED working mode<br>
'''Note:''' turn off the LED with instructions and turn it on again. The module will not take effect until it is reset
| align="Light" |'''?:''' query; <br>  '''0:''' turn off; <br>  '''1:''' turn on
|-
|}
===19)Inquiry and set the UUID search instruction===
{| width="50%" cellspacing="0" border="1"
|-
! align="center" scope="col" | Command
! align="center" scope="col" | Response
! align="center" scope="col" | Instruction
! align="center" scope="col" | Details
|-
|-
| align="center" | AT+LUUID=xxxx
| align="center" | OK+LUUID=xxxx
| align="center" | Query/Set the UUID Connection (Search UUID)<br>
| align="Light" | The general Bluetooth master (without display, difficult to manually select) has set the UUID filter search.<br>
In this case, only slaves with the same UUID can be searched.<br>
Default: FFF0 (that is 0xFFF0);<br>
The parameter must be in the range of 0~F.
|-
|}
Input:AT + LUUID =?    Return: OK+LUUID=FFF0 (query LUUID: FFF0)<br>
Input: AT+LUUID=1234  Return: OK+LUUID=1234 (set LUUID)<br>
===20)Inquiry and set the service UUID instruction===
{| width="50%" cellspacing="0" border="1"
|-
! align="center" scope="col" | Command
! align="center" scope="col" | Response
! align="center" scope="col" | Instruction
! align="center" scope="col" | Details
|-
|-
| align="center" | AT+SUUID=xxxx
| align="center" | OK+SUUID=xxxx
| align="Light" | Query/set the service UUID
| align="Light" | The general Bluetooth master (without display, difficult to manually select) has set the UUID filter search.<br>
In this case, only slaves with the same UUID can be searched.<br>
Default: FFF0 (that is 0xFFF0);<br>
The parameter must be in the range of 0~F.
|-
|}
Input:AT + LUUID =?    Return: OK+LUUID=FFF0 (query LUUID: FFF0)<br>
Input: AT+LUUID=1234  Return: OK+LUUID=1234 (set LUUID)<br>
===21)Inquiry and set the pass-through UUID instruction===
{| width="50%" cellspacing="0" border="1"
|-
! align="center" scope="col" | Command
! align="center" scope="col" | Response
! align="center" scope="col" | Instruction
! align="center" scope="col" | Details
|-
|-
| align="center" | AT+TUUID=xxxx
| align="center" | OK+TUUID=xxxx
| align="Light" | Query/set the pass-through UUID
| align="Light" | This pass-through UUID must be correct in order to transmit and receive data properly.<br>
Default: FFE1 (meaning 0xFFE1);<br>
The parameters must be in the range of 0~F.
|-
|}
Input: AT + TUUID =?  Return: OK+TUUID=FFE1 (query SUUID: FFE1)<br>
Input: AT+TUUID=1234  Return: OK+TUUID=1234 (set SUUID)<br>
===22)Inquiry and set the automatic sleep time instruction===
{| width="50%" cellspacing="0" border="1"
|-
! align="center" scope="col" | Command
! align="center" scope="col" | Response
! align="center" scope="col" | Instruction
! align="center" scope="col" | Details
|-
|-
| align="center" | AT+AUST=x
| align="center" | OK+AUST=x
| align="Light" | Query/Set the automatic Sleep time
| align="Light" | '''?:''' Query (default 20s, the shorter the time, the more power saving.)<br>
'''Setting range:''' 1~300 (unit: s)<br>
In low power mode, if no operation after activating the module, it will return to the low power mode set by the user after x seconds.
|-
|}
Input: AT+AUST=?  Return: OK+AUST=20 (Query the automatic sleep time is 20S)<br>
Input: AT+AUST=60  Return: OK+AUST=60 (Set the automatic sleep time to 60S)<br>
'''Note:''' AUST defaults by 20 seconds. In the MODE1 low-power mode, since the mode is discoverable and connectable, AUST can be set to a minimum of 1 second to save power.
If it is MODE2 low power mode, since this mode is undiscoverable and unconnectable, it is recommended to set AUST to 20 seconds or more to ensure that the module has enough time to connect with other Bluetooth master devices after waking up through the serial port.
==Used With UNO R3 Control Board==
===Description===
In the experiment, we don’t set the AT command for Bluetooth module, but directly use it together with UNO R3. Bluetooth is default by Slave, default baud rate to 9600. When using, first upload the test code to UNO R3, then connect the Bluetooth to UNO R3, use phone APP and Bluetooth module to achieve the communication function between your phone and UNO R3 control board.<br>
<span style=color:red> '''Note:''' when using, must first upload the code to UNO board, then connect the Bluetooth module to UNO R3. Or else fail to compile the code. </span><br>
===Wire it Up===
Connect the 5V pin to 5V, GND to GND, TX pin to RX (digital 0), RX pin to TX (digital 1).
<br>[[Image:KS0355-1.png|700px|frameless]]<br>
===Upload the Code===
Copy and paste the code below to Arduino IDE. <br>
* [http://wiki.keyestudio.com/index.php/How_to_Download_Arduino_IDE Download Arduino IDE]
* [http://wiki.keyestudio.com/index.php/How_to_Install_Arduino_Driver Install Arduino Driver]
<pre>
int val;
int ledpin=13;
void setup()
{
Serial.begin(9600);
pinMode(ledpin,OUTPUT);
} void loop()
{ val=Serial.read();
if(val=='a')
{
digitalWrite(ledpin,HIGH);
delay(250);
digitalWrite(ledpin,LOW);
delay(250);
Serial.println("keyestudio");
}
}
</pre>
==Test Result==
Upload the above code to UNO R3, then connect well the Bluetooth, powered up, you should see the red led on Bluetooth module flash. <br>
Then click the APP icon of [https://drive.google.com/open?id=1eIez1uIcWNSBpKeCOOrVJEeEVjf8t5cM    HC-COM] [[Image:KS0355-2.png|600px|frameless]] , enter the device search, click the device HC-08 to connect the Bluetooth. Bluetooth connected, the red led on the module will always on.<br>
Enter a letter “a” and click “Send”, you should see the character “keyestudio” appear on the APP. <br>
<br>[[Image:KS0355-3.jpg|600px|frameless]]<br>
<br>[[Image:KS0355-4.png|600px|frameless]]<br>
==Resources==
https://fs.keyestudio.com/KS0355
==Buy From==
*[https://www.keyestudio.com/keyestudio-hc-08-bluetooth-master-slave-module-transceiver-for-arduino-compatible-with-ios-and-android-p0055.html  '''From official website''']
*[https://www.aliexpress.com/store/product/Keyestudio-HC-08-Bluetooth-Master-Slave-Module-Transceiver-for-Arduino-Compatible-with-iOS-and-Android/1452162_32907441181.html?spm=2114.12010612.8148356.6.16e41583zZ9jL8  '''From Aliexpress:''']
  [[Category: Module]]

Latest revision as of 14:48, 4 March 2021

Keyestudio HC-08 Bluetooth Module


Overview

Keyestudio HC-08 Bluetooth module is a new digital transmission module, based on the Bluetooth Specification V4.0 BLE Bluetooth protocol.
Its wireless working frequency band is 2.4GHz ISM, and the modulation method is GFSK.
The module's default transmit power is 4dBm. Receive sensitivity -93dBm.
The module is compatible with both Android and Apple systems. In an open environment, it can communicate with iphone4s, to achieve ultra-long-distance communication of 80 meters. It also comes with an LED status indicator. When using, you can directly see the connection state of Bluetooth.
The module uses the CC2540F256 chip from TI, configured with 256K bytes of space, supporting the AT command. For need, the users can change the role (master or slave mode), baud rate of serial port, device name and other parameters, very flexible use.
thumb


Detailed Interface


thumb


Technical Details

  • Working voltage: DC 5V
  • Working frequency band: 2.4G
  • Air speed: 1Mbps
  • Communication interface: UART3.3VTTL level
  • Antenna interface: built-in PCB antenna
  • Sleep current: 0.4μA
  • RSSI support: not supported
  • Receive sensitivity: -93dBm@1Mbps
  • Communication level: 3.3V
  • Bluetooth version: V4.0
  • Modulation method: GFSK
  • Transmit power: 4dBm (default)
  • Reference distance: 80m
  • Working temperature: -25℃ to +75℃
  • Working humidity: 10% to 90%
  • Storage temperature: -40℃ to +85℃
  • Working current (excluding LED)
  • Host not connected / connected: 21mA / 9mA
  • Slave MODE0, not connected / connected: 8.5mA/9mA
  • Slave MODE1, not connected / connected: 6μA ~ 2.6mA / 1.6mA
  • Slave MODE2, not connected / connected: 0.4μA/1.6mA

Extra:

  • Compatible with Android and Apple System
  • Environmental-friendly


Dimensions

  • Dimensions: 49mm*17mm*7mm


thumb


AT Command Settings

Before setting the AT command, for hardware, you need a USB to serial module (such as FT232 module ) and several DuPont lines. For software, need a serial port assistant software, and install well the driver for the USB to serial module.
First, connect the Bluetooth module to FT232 module using DuPont line. The connection method is as follows.

HC-08 Bluetooth Module FT232 module
5V VCC(5V)
GND GND
TX RX
RX TX

Connected well, then connect the FT232 module (drive installation completed) to the computer using a USB cable.
First right-click the computer, for properties ->Device Manager to find the corresponding COM port. Then open the serial port assistant software, set the COM port, and the baud rate (initial default 9600).
After the connection is successful, you can start to set the AT command according to the instructions.


AT Command Instructions

1)Testing Instruction

Command Response Instruction
AT OK Test


2)Check the basic parameters

Command Response Instruction
AT+RX Name:HC-08-- >>>> user-defined name for Bluetooth

Role:Slave-->>>> module’s role(master/slave)
Baud:9600,NONE-->>>> serial baud rate, check bit.
Addr:xx,xx,xx,xx,xx,xx-->>>> Bluetooth Address
PIN :000000-->>>> Bluetooth password(invalid)

Inquire the basic parameters of module


3)Factory Data Reset Instruction

Command Response Instruction
AT+DEFAULT OK Factory Data Reset

Note: The slave address that the host has recorded will not be cleared! To clear, use the AT+CLEAR instruction to clear in the unconnected state.
The module will restart automatically, and a new operation can be performed after restarting for 200ms!


4)Module Restart Instruction

Command Response Instruction
AT+RESET OK restart the module

Note: The module will restart automatically, and a new operation can be performed after restarting for 200ms!


5)Check the software version

Command Response Instruction
AT+VERSION HC-08V3.1, 2017-07-07 view the software version and release date


6)Modify the module’s role

Command Response Instruction
AT+ROLE=x Master/Slave Set the Master/ Slave

Note: By Slave default, the module will automatically restart after setting.
A new operation can be performed after restarting for 200ms.

Send: AT+ROLE=M Return: Master ( to restart)
Send: AT+ROLE=? Return: Master (without restart)


7)Inquire and Modify the Bluetooth Name

Command Response Instruction
AT+NAME=xxx OKsetNAME Set the Bluetooth name

Note: Query to fill in the“?”, and set the Bluetooth name.
(Limited to 12 characters, support visual ASCII code and partial escape characters. The module supports Chinese character input, and Android device must be converted to "UTF8 encoding" to display properly. Send more than 12 characters, only recognize the first 12 characters. )
This command does not filter any characters. If you need Chinese characters, you can transcode them according to your own device format.

Send: AT+NAME=? Return: OK+NAME=HC-08
Send: AT+NAME=keyestudio Return: OKsetNAME
Send: AT+NAME=? Return: OK+NAME=keyestudio


8)Inquire and Modify the Bluetooth Address

Command Response Instruction
AT+ADDR=xxxxxxxxxxxx OKsetADDR Modify the module's MAC address

(do not recommend to modify the module's MAC address to avoid conflicts)
Note: The address must be a 12-bit 0~F number or uppercase Character, that is a hexadecimal character. Query to fill in the "?”

Send: AT+ADDR=? Return: xxxxxxxxxxxx(current Bluetooth address of module)
Send: AT+ADDR=AABBCCDDEEFF Return: OKsetADDR
Send: AT+ADDR=? Return: AA,BB,CC,DD,EE,F


9)Inquire and Modify the RF Power

Command Response Instruction
AT+RFPM=x 4dBm(0 dBm /-6 dBm / -23dBm) Query/set the RF power of the module

Note: the parameter x is as shown in the table below.
And query and settings are represented by a code name.

Send: AT+RFPM=? Return: 4dBm (query RF Power is 4dBm)
Send: AT+RFPM=2 Return: OK (set the RF Power as -6dBm)
Send: AT+RFPM=? Return: -6dBm (query RF Power is -6dBm)
x is the code name of RF power, shown as the table below:

parameterx RF power transmitting power
? view the current RF power
0 4dBm(factory default)
1 0dBm
2 -6dBm
3 -23dBm


10)Inquire and Modify the Serial Baud Rate

Command Response Instruction
AT+BAUD=xx(or AT+BAUD=xx,y) OK9600 Serial port settings

Note: as shown in the following table, the parameters xx and y respectively represent the Baud rate and check bit.

Send: AT+BAUD=? Return: 9600,NONE
Send: AT+BAUD=19200,E Return: OK19200,EVEN
(set the parameter of serial port as: baud rate 19200, even-parity check)

xx represents the serial baud rate, y represents the check bit. As the table shown below:

parameter serial baud rate xx parameter check bit y
? view the current baud rate
1200 1200bps N NONE
2400 2400bps E EVEN
4800 4800bps O ODD
9600 9600bps(factory default)
19200 19200bps
38400 38400bps
57600 57600bps(factory default)
115200 115200bps

When the host and slave transmit communication, please do not exceed 500 bytes for each data package below 9600bps baud rate.
For the maximum number of bytes per packet above 19200bps baud rate, please refer to the following table.
There is a certain time interval among the data packets. The following table is the reference value for the time interval for various communication baud rates:

baud rates (bps) 1200 2400 4800 9600 19200 38400 57600 115200
send 500 bytes time interval (ms) 6800 3600 2000 1000
send 300 bytes time interval (ms) 4200 2400 1200 600 400
send 100 bytes time interval (ms) 1500 80 400 160 100 120
send 80 bytes time interval (ms) 1000 650 320 120 80 60 100
send 60 bytes time interval (ms) 800 500 250 100 60 60 60 100
send 20 bytes time interval (ms) 200 100 50 20 20 20 20 20


11)Inquire and set the module whether connectable

Command Response Instruction
AT+CONT=x OK/Connectable/Non-Connectable Set the connectability.

Non-connectable is mainly used for broadcast data.

Send: AT+CONT=? Return: Connectable(query result “connectable”)
Send: AT+CONT=1 Return: OK (set the “Non-connectable” successfully)

The functions of parameter x is as follows:

Parameter Master Slave
0(default) (Central)

Connectable, enter the normal transmission mode after connection.

(Peripheral)

Connectable, enter the normal transmission mode after connection.

1 (Observer)

The current module cannot connect to other modules or devices, but it will automatically scan the broadcast packet of HC-08 slave and refresh once per 2s.

(Broadcaster)

cannot connect to the host, but it can be combined with low power mode 1 for broadcast packet transmission.

Please usewith the "AT+MODE", "AT+AVDA" and "AT+AINT" instructions to reach the best results.
1. For the Master/Slave, CONT=1 is used to transmit the broadcast data. The Slave sends the broadcast data, and the Master receives the corresponding broadcast data and outputs it through the serial port.
2. This mode is only for the HC-08 module, or for those users who have Android development capabilities and can grab this packet themselves.


12)Update broadcast data instruction (only set by Slave )

Command Response Instruction Details
AT+AVDA=xxx OK Set the broadcast data 1. The parameter "xxx" can be any user data of 1~12 bytes. If the Master status AT+CONT=1 at this time, the Master serial port will output xxx data. This broadcast data will not be saved permanently and will expire after the module is restarted.

2. Since the Master is fixed for 2s scanning, the broadcast data received from the same Slave can be output only once in 2s. Moreover, this mode is characterized by "continuous broadcast from the Slave and continuous scanning by the Master", so the Master will continuously output data.
3. The higher the broadcast density of the slave, the easier the data is received by the Master. The higher the broadcast density, the higher the power consumption of the Slave.

Send: AT+AVDA=1234567890AB Return: OK
If at this moment, for Master, AT+CONT=1, and successfully scan the broadcast from the Slave, the serial port will output: 1234567890AB


13)Inquiry and modify the power consumption mode (only set by Slave )

Command Response Instruction
AT+MODE=x OK/Connectable/Non-Connectable Set the power consumption

Note: only set by Slave

Send: AT+MODE=? Return: 0/1/2 Send: AT+MODE=1 Return: OK

The functions of parameter x is as follows:

parameter Return Explanations
? 0/1/2 Gain the current power consumption mode
0 OK Full power consumption mode(factory default)
1 OK Primary energy saving mode.

Before connection, the current is determined by the setting of AT+AINT. After connection, mainly determined by AT+CINT.
The MODE1 already covers the MODE3 of V2.4 version, and more reasonable!

2 OK Secondary energy saving mode (sleep mode).

The current during sleep is 0.4μA.
It can't be found and can't be connected during sleep. It can be found and connected after activatedby the serial port.

Note: 1. Power consumption mode 1 is mainly used for:
A. The main low-power mode of module, can provide low-power standby for transparent transmission, and can also be used as low-power broadcast data.
B. The Slave broadcasts data to the Master, supporting one-to-many single communication (in theory, one slave can send to an unlimited number of master.
If you want to receive more data from slave, it is recommended to set a high baud rate).
C. For wireless reading devices such as anti-lost device, check-in card, heart rate meter, etc.

2. Power mode 1 and mode 2 can be activated by sending more than 1 byte of data through the serial port, but the first few bytes of data may be garbled.
Therefore, it is recommended to send a 10-byte hexadecimal code "0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF" to wake up the module, avoiding the first few garbled bytes.
After that, the module works in full speed mode, and the serial port can send and receive data normally.
In the unconnected state, the module wakes up and enters full speed mode for 20 seconds (default, can be adjusted by AT command), and then returns to the original power mode.
As long as the serial port has received data within 20 seconds, it will be re-timed.
If the module is connected, it will remain in full speed mode after waking up. It will return to the original power mode unless disconnection.


14)Set the broadcast interval instruction

Command Response Instruction Details
AT+AINT=xx OK+AINT=xx Query/set up the broadcast interval (affect the power consumption when not connected) The unit of xx is 625us (that is, if xx=1, the broadcast interval is 625us*1=625us).

The range is 32~16000.(equivalent to 20ms~10s).
Default: 320 (i.e. 200ms)

Input: AT+AINT=? Return: OK+AINT=320
Input: AT+AINT=1600 Return: OK+AINT=1600 (modify the broadcast interval as 1000ms)
Note: The instruction AT+AINT replaces AT+TIME of V2.4 version to set the broadcasting cycle, which can set the interval TIME more accurate.


15)Inquire and set the connection interval

Command Response Instruction Details
AT+CINT=x,y OK+CINT=x,y Query/set up the connection interval

(directly affect the connection power, the master need to set at the same time)

x: minimum connection interval; y: maximum connection interval.

Unit: 1.25ms;
Setting range: 6~3199 (7.5ms~4s).
1. This value directly affects the actual connection interval: x ≤ actual connection interval ≤y
2. must meet theconditions: x≤y
3. You can separatelyenter a parameter x. If at this time the recorded y<x, y will be directly equal to x.
4. Default value: 6,12

Input: AT+CINT=? Return:OK+CINT=6,12 (Query the minimum connection interval is 1.25*6=7.5ms, the maximum connection interval is 1.25*12=15ms)
Input:AT+CINT=16,32 Return:OK+CINT=16,32 (Set the connection interval to 20ms~40ms)
Input:AT+CINT=80 Return:OK+CINT=80,80 (set the connection interval to 100ms)


16)Inquire and set the connection timeout

Command Response Instruction Details
AT+CTOUT=x OK+CTOUT=x Query/set connection timeout Unit: 10ms;

Range: 10-3200 (100ms - 32s).
This value directlyaffects the time of disconnection, that is, the time of"unexpecteddisconnection".(active disconnection is not affected by this value)
Default value: 200

Input: AT + CTOUT =? Return: OK+CTOUT=200 (query connection timeout is 10ms*200=2s)
Input: AT+CTOUT=100 Return: OK+CTOUT=100


17)Clear the recorded slave address only by Master

Command Response Instruction Details
AT+CLEAR OK Clear the memory address, equivalent to the key function.
As long as the master has connected to the slave, it remembers the address of the last connected slave.

If you want to connect to other slaves, you must clear the current memory of slave address.
There are two methods to clear the memory. One is to connect the module’s 18-pin (KEY pin) to a High level of 200mS or more. The other is to input the AT+CLEARcommand in the unconnected state.

As long as the master has connected to the slave, it remembers the address of the last connected slave.
If you want to connect to other slaves, you must clear the current memory of slave address.
There are two methods to clear the memory. One is to connect the module’s 18-pin (KEY pin) to a High level of 200mS or more. The other is to input the AT+CLEAR command in the unconnected state.


18)Inquiry and set the LED ON/OFF instruction

Command Response Instruction Details
AT+LED=x OK+LED=x Query/set LED working mode

Note: turn off the LED with instructions and turn it on again. The module will not take effect until it is reset

?: query;
0: turn off;
1: turn on


19)Inquiry and set the UUID search instruction

Command Response Instruction Details
AT+LUUID=xxxx OK+LUUID=xxxx Query/Set the UUID Connection (Search UUID)
The general Bluetooth master (without display, difficult to manually select) has set the UUID filter search.

In this case, only slaves with the same UUID can be searched.
Default: FFF0 (that is 0xFFF0);
The parameter must be in the range of 0~F.

Input:AT + LUUID =? Return: OK+LUUID=FFF0 (query LUUID: FFF0)
Input: AT+LUUID=1234 Return: OK+LUUID=1234 (set LUUID)


20)Inquiry and set the service UUID instruction

Command Response Instruction Details
AT+SUUID=xxxx OK+SUUID=xxxx Query/set the service UUID The general Bluetooth master (without display, difficult to manually select) has set the UUID filter search.

In this case, only slaves with the same UUID can be searched.
Default: FFF0 (that is 0xFFF0);
The parameter must be in the range of 0~F.

Input:AT + LUUID =? Return: OK+LUUID=FFF0 (query LUUID: FFF0)
Input: AT+LUUID=1234 Return: OK+LUUID=1234 (set LUUID)


21)Inquiry and set the pass-through UUID instruction

Command Response Instruction Details
AT+TUUID=xxxx OK+TUUID=xxxx Query/set the pass-through UUID This pass-through UUID must be correct in order to transmit and receive data properly.

Default: FFE1 (meaning 0xFFE1);
The parameters must be in the range of 0~F.

Input: AT + TUUID =? Return: OK+TUUID=FFE1 (query SUUID: FFE1)
Input: AT+TUUID=1234 Return: OK+TUUID=1234 (set SUUID)


22)Inquiry and set the automatic sleep time instruction

Command Response Instruction Details
AT+AUST=x OK+AUST=x Query/Set the automatic Sleep time ?: Query (default 20s, the shorter the time, the more power saving.)

Setting range: 1~300 (unit: s)
In low power mode, if no operation after activating the module, it will return to the low power mode set by the user after x seconds.

Input: AT+AUST=? Return: OK+AUST=20 (Query the automatic sleep time is 20S)
Input: AT+AUST=60 Return: OK+AUST=60 (Set the automatic sleep time to 60S)

Note: AUST defaults by 20 seconds. In the MODE1 low-power mode, since the mode is discoverable and connectable, AUST can be set to a minimum of 1 second to save power. If it is MODE2 low power mode, since this mode is undiscoverable and unconnectable, it is recommended to set AUST to 20 seconds or more to ensure that the module has enough time to connect with other Bluetooth master devices after waking up through the serial port.


Used With UNO R3 Control Board

Description

In the experiment, we don’t set the AT command for Bluetooth module, but directly use it together with UNO R3. Bluetooth is default by Slave, default baud rate to 9600. When using, first upload the test code to UNO R3, then connect the Bluetooth to UNO R3, use phone APP and Bluetooth module to achieve the communication function between your phone and UNO R3 control board.

Note: when using, must first upload the code to UNO board, then connect the Bluetooth module to UNO R3. Or else fail to compile the code.


Wire it Up

Connect the 5V pin to 5V, GND to GND, TX pin to RX (digital 0), RX pin to TX (digital 1).
KS0355-1.png


Upload the Code

Copy and paste the code below to Arduino IDE.

int val; 
int ledpin=13; 
void setup() 
{ 
Serial.begin(9600);
 pinMode(ledpin,OUTPUT); 
} void loop()
{ val=Serial.read(); 
if(val=='a')
 { 
digitalWrite(ledpin,HIGH); 
delay(250); 
digitalWrite(ledpin,LOW); 
delay(250);
 Serial.println("keyestudio");
}
}

Test Result

Upload the above code to UNO R3, then connect well the Bluetooth, powered up, you should see the red led on Bluetooth module flash.
Then click the APP icon of HC-COM KS0355-2.png , enter the device search, click the device HC-08 to connect the Bluetooth. Bluetooth connected, the red led on the module will always on.
Enter a letter “a” and click “Send”, you should see the character “keyestudio” appear on the APP.

KS0355-3.jpg

KS0355-4.png


Resources

https://fs.keyestudio.com/KS0355

Buy From