Introduction: HC-08 Bluetooth UART Communication Module V2.4 User Guide

About: ElecFreaks is an open design house founded in March 2011. Our goal is to create rapid prototypes and give small-batch manufacture solution for makers and startups. With over 50% staff as engineers and expanded…

Product Introduction

Bluetooth Modem - Minimum Pass-through Module HC08 is a new generation data transmission module based on Bluetooth Specification V4.0 BLE protocol. Its wireless working frequency band is 2.4GHz ISM with GFSK modulation method. The maximum transmit power is 4d Bm. Its receiving sensitivity is -93d Bm. In the wide open environment, it can reach 80m super long-range communication with iphone4s. It has integrated stamp package holes and pins welding holes. You can both mount package and weld pins. It is very convenient to be embedded into the application system. With built-in LED indicator, you can visually see the connection status of Bluetooth. This module adopts core CC2540F256 configured 256K bit. It supports AT commands. Users can change roles(master/slave mode) as well as parameters like Baud rate and the device name according to their own requirements. It is very flexible to use.

Step 1: Product Size

Pin definition

The HC-08 module has 30 pins on board. Specific definitions of pins are listed in the following table:

Step 2: Pin


Pin

Definition

I/O

Explain

1

TXD

output

UART output, 3.3V TTL level

2

RXD

input, weak pull up

UART input, 3.3V TTL level

3

NC

4

NC

5

NC

6

DC

input

Debug clock

7

DD

Input/output

Debug data

8

PIO20

input, weak pull up

NC

9

PIO17

input, weak pull down

NC

10

PIO16

Input, weak pull down

NC

11

RST

input, pull up

Module reset pin, a low level of not less than 10ms reset

12

VCC

input

Power pin, the requirements of 3.3V DC power supply,

the supply current is not less than 100mA

13

GND

Ground

14

LEDCON

input

LED control pin(Note3)

15

PIO14

input, weak pull down

NC

16

PIO13

output

LED output(Note1)

17

PIO11

input, weak pull down

NC

18

PIO12

input, weak pull down

The master module clear memory(Note2)

19

PIO10

input, weak pull down

NC

20

PIO07

input, weak pull up

NC

21

USB_D-

NC

22

USB_D+

NC

23

PIO06

input, weak pull up

NC

24

PIO01

input, weak pull up

NC

25

PIO15

input, weak pull down

NC

26

PIO00

input, weak pull up

27

VCC

input

Power pin, the requirements of 3.3V DC power supply,

the supply current is not less than 100mA

28

GND

Ground

29

RXD

input, weak pull up

UART input, 3.3V TTL level

30

TXD

output

UART output, 3.3V TTL level

Step 3: Note 1:

PIO13 indicates LED output pin, high level output. Please connect LED with resistance in parallel.

Before Connection:

When the master module do not record the address of the slave module, it will illuminate for 100ms per second;

When the master module record the address of the slave module, it will illuminate for 900ms per second;

In the slave module, LED illuminates for 1 second between every 2 seconds.

After connection: LED lights are always illuminated.

Note 2:

Input pin, internal pull-down. This pin is connected to the high electric level. The master module is used to clear the recorded address of the slave module.

Note 3:

Input pin, be used to control the LED. If this pin is grounded, LED off. If this pin is left hanging, LED on.

Step 4: Electrical Characteristics:


Parameter

Test Condition

Representative Value

Working Voltage

-

DC2.0V~3.6V

Master

not connected / connection

21mA/9mA

Working Current

MODE0, not connected / connection

8.5mA/9mA

MODE1, not connected / connection

340μA/1.6mA

(not LED)

Slave

MODE2, not connected / connection

0.4μA/1.6mA

MODE3, not connected / connection

1.2μA-160μA/1.6mA

Step 5: Manual AT Command

AT command is used to set module's parameter. Before connection, module can operate under AT command. After connection, it enters into serial port transparent transmission mode.

The startup time of this module is about 150ms. So it is better to operate AT command after being powered on for 200ms. Unless otherwise indicated, the parameter setting of AT command is effective immediately. At the same time, the modification of parameters and functions will not be lost once power off.

After the successful modification of AT command, it uniformly returns to OK (Except for information checking commands such as "AT+RX, AT+VERSION"). No success achieved, it will not return to any information.

⑴ AT Command List

AT Command

Function

Default

Role

("x"- parameter

1

AT

Test command

-

M/S

2

AT+RX

Check the basic parameters

-

M/S

3

AT+DEFAULT

Restore factory setting

-

M/S

4

AT+RESET

Reset the module

-

M/S

5

AT+VERSION

Check version and date

-

M/S

6

AT+ROLE=x

Change master/slave role

S

M/S

7

AT+NAME=xxxxxxxxxxxx

Revise name

HC-08

M/S

8

AT+ADDR=xxxxxxxxxxxx

Revise address

Hardware

M/S

address

9

AT+RFPM=x

Revise RF power

0(4dBm)

M/S

10

AT+BAUD=x,y

Revise UART baud

9600,N

M/S

11

AT+CONT=x

Set connectability

0(Can be

M/S

connected)

12

AT+MODE=x

Set working mode

0

S

13

AT+AVDA=xxxxxxxxxxxx

Change the broadcast data

-

S

14

AT+TIME=x

Mode 3 broadcast cycle

5(s)

S

The master module to clear

15

AT+CLEAR

the slave module address

-

M

have been recorded.

Note:

1. The AT command behind no newline; if no special instructions, all AT commands are not transmitted using newline.

2. The last 4 senior commands, must be used in combination, can play its due role BLE Bluetooth low energy. Using a Bluetooth low energy, there will be special instructions and program introduced in the following sections.

Step 6: Command Explain

1.Test command

Command:AT

Return:OK.

  1. Check the basic parameters

View the basic parameters such as Bluetooth name, master/slave role, UART baud rate, address and password.

Command:AT+RX

Return:

Name:HC-08 -------->>>> bluetooth name

Role:Slave -------->>>> master/slave role

Baud:9600,NONE -------->>>> UART baud rate

Addr:xx,xx,xx,xx,xx,xx -------->>>> bluetooth address

PIN :000000 -------->>>> bluetooth password

Note: Temporarily does not support change password!

  1. Reset to default

    Command:AT+DEFAULT

    Return:OK

    The module will automatically restart, please carry out new operation on the restart 200ms!

  2. Reset the module

    Command:AT+ RESET

    Return:OK

    The module will automatically restart, please carry out new operation on the restart200ms!

    5.Check version and date

    Command:AT+ VERSION

    Return:HC-08V2.0,2014-08-22

    6.Change master/slave role Set

    command:AT+ROLE=x Query

    command:AT+ROLE=? X:role(M or S),

    M:master; S:slave. Default setting is S(slave).

    Send:AT+ROLE=M

    Return:OK

    Set master role,the module will automatically restart!

    Send:AT+ROLE=?

    Return:Master

    You can view the role is the master module.

  3. Revise name

    Set command: AT+ NAME=xxxxxxxxxxxx

    Query command: AT+ NAME=?

    Default name is HC-08, you can set the other name (Valid within 12 characters, support the visualized ASCII code and part of the escape character. The module supports chinese, but android devices must be converted to "UTF8 code" in order to display normally. More than 12 characters, then it will read the first 12 characters only.). Setup is complete, effective after module automatically reset!

    Example:

    Send:AT+NAME=HCKJ

    Return:OKsetNAME

    Send:AT+NAME=?

    Return:HCKJ

    8.Revise address

    Set command:AT+ADDR=xxxxxxxxxxxx

    Query command:AT+ADDR=?

    The address must be 12 bit "0~F" uppercase characters, namely hexadecimal characters.

    Example:

    Send:AT+ADDR=1234567890AB

    Return:OKsetADDR

    Setup is complete, effective after module automatically resett!

    Send:AT+ADDR=?

    Return:1234567890AB

    Send:AT+ADDR=000000000000

    Return:OKsetADDR

    Send "000000000", module to restore the default hardware address. Module factory default is hardware address.

    9.Revise RF power

    Set command:AT+RFPM=x

    Query command:AT+RFPM=?

    X:RF power,as shown in the following table:

    Parameter

    RF power

    ?

    View the current RF power

    0

    4dBm(default)

    1

    0dBm

    2

    -6dBm

    3

    -23dBm

    Example:

    Send:AT+RFPM=2

    Return:OK

    RF power modified -6dBm.

    Send:AT+RFPM=?

    Return:-6dBm

    RF power is -6dBm.

    When peak current is more than 30mA (when RF power is 4dBm) and the current of button batteries is small(under 20mA), if we want to charge with the button battery, we'd better set the RF power to be -6dBm or -23dBm.

    10.Revise UART baud rate

    Set command:

    AT+BAUD=x(Only modified the UART baud rate)

    AT+BAUD=x,y(Modify the UART baud rate and parity bit)

    Query command:AT+BAUD=?

    x:UART baud rate,y: parity bit, As shown in the following table:
    Parameter

    UART baud :x

    Parameter

    parity bit :y

    ?

    View the current baud rate

    1200

    1200bps

    N

    No parity

    2400

    2400bps

    E

    Even parity

    4800

    4800bps

    O

    Odd parity

    9600

    9600bps(default)

    19200

    19200bps

    38400

    38400bps

    57600

    57600bps

    115200

    115200bps

    Example:

    Send:AT+BAUD=19200

    Return:OK19200

    UART baud rate modified for 19200bps.

    Send:AT+BAUD=4800,E

    Return:OK4800,EVEN

    UART baud rate modified for 4800bps,and even parity.

    Send:AT+BAUD=?

    Return:4800,EVEN

    View UART baud rate and parity bit.

    During master and slave module transparent transmission, each packet under 9600bps baud rate must not exceed the maximum number of 500 bytes. As for each packet with baud rate above 19200bps, please refer to the following table. Between data packets, it must have a certain time interval. The following table is a variety of communication baud rates, the reference value for the time interval :

    baud rate (bps)

    1200

    2400

    4800

    9600

    19200

    38400

    57600

    115200

    500 bytes time interval (ms)

    6800

    3600

    2000

    1000

    300 bytes time interval (ms)

    4200

    2400

    1200

    600

    400

    100 bytes time interval (ms)

    1500

    800

    400

    160

    100

    120

    80 bytes time interval (ms)

    1000

    650

    320

    120

    80

    60

    100

    60 bytes time interval (ms)

    800

    500

    250

    100

    60

    60

    60

    100

    20 bytes time interval (ms)

    200

    100

    50

    20

    20

    20

    20

    20

    1. The above is the measured data. The theoretical fastest total transceiver speed: 2500 bytes/sec, with the speed controlled within 2000 bytes/sec.

    2. Bytes of each packet shall be an integer multiple of 20.

    3. Module sends automatic subcontracting data is an integer multiple of 20 bytes. It is used to send a 100 bytes packet, and it will receive a plurality of packets at another end. Each data packet is an integer multiple of 20 bytes. The total number of bytes is 100.

    11.Set connectability

    Set command:AT+CONT=x

    Query command:AT+CONT=?

    The X parameter functions are as follows:
    Parameter

    Master Role

    Slave Role

    Central

    Peripheral

    0

    Can be connected, the connection

    Can be connected, the connection

    (Default)

    after entering ordinary transparent

    after entering ordinary transparent

    transmission mode

    transmission mode

    Observer

    Broadcaster

    The module can not be connected

    Not connected with the master role,

    1

    to other equipment, but will auto-

    but can be combined with low power

    matically scan the HC-08 from the

    mode 3, the realization of broadcast

    broadcast datamachine package,

    packets send.

    fixed 2sec refresh time.

    Example:

    Send:AT+CONT=1

    Return:OK

    Setup is complete, effective after module automatically reset!

    Send:AT+CONT=?

    Return:Non-Connectable

    The command please with "AT+MODE", "AT+AVDA" and "AT+TIME" command with the use of.

    Note:

    1. The master/slave module "CONT=1" is mainly used for transmitting broadcast data. Sending broadcast data from the slave module, the master module will receive the corresponding data through the serial output.

    2. This model is for the user to grab this broadcast data package by himself only. The specific communication protocol is not described here. If you want to know, please visit the following official website for consultation:

    http://www.hc01.com/

Step 7: 12.Set Working Mode(Only Slave Module)

Set command:AT+MODE=x

Query command:AT+MODE=?
Command

Parameter

Return

Function

=?

0/1/2/3

Gets the current mode.

=0

Full power mode (default), LED open.

Level 1 power saving mode,LED close.

=1

No connection the current is 340μA, the connection

speed like mode0.

Level 2 power saving mode,LED close.

=2

No connection the current is 0.4μA.

AT+

Can not be found, not connected to wake up

MODE

OK

before, after awakening can be connected.

Level 3 power saving mode,LED close.

No connection the current is 1.2μA~160μA(about

32μA default).

=3

Combined with " AT+TIME" to set the broadcast

time, thus to reduce power consumption.

The use of specific methods please refer to the

"AT+TIME" command.

Note:

  • Mode 3 is mainly used for:

    A. Used to reduce the power consumption.

    B. The slave module send the broadcast data to the master module, can achieve one-way communication of one to many (theoretically it can be from a slave module to infinite master module).

    C. As anti-lost alarm, attendance card, heart rate meter or other wireless device.

    2. Mode 1/2/3 are available through the UART port to send 1 byte data to wake up, but front few bytes of data may be garbled after wake up. Therefore we recommend sending 10 bytes hexadecimal code of "0xFF, 0xFF, 0xFF, 0xFF, 0xFF,0xFF, 0xFF, 0xFF, 0xFF, 0xFF" to awaken the module, avoiding the front several data byte might be garbled. Since then, modules work on the full speed mode, the UART port can be normal to send and receive data.

    Under the unconnected status, module after being awakened into full speed mode, which maintains for 5 minutes, and then return to the original mode. As long as 5 minutes in the UART has received data, then retiming.

    If the module is in the connected state, then after awakening, it will remain in the full speed mode. Before connection, module will return the original power mode.

    3. In addition to mode0, the other mode is to close LED. But after connection, LED will be lighted.

    Example: Send:AT+MODE=?

    Return:0

    View the current mode.

    Send:AT+MODE=2

    Return:OK

    Setting mode 2, effective immediately.

  • Change the broadcast data(Only slave module)

    Command:AT+AVDA=xxxxxxxxxxxx

    Parameter "xxxxxxxxxxxx" can be any 1~12 bytes user data. If at this point the

    master module state of AT+CONT=1, then the master module UART port will output the "xxxxxxxxxxxx" data. The broadcast data will not be preserved permanently. It will be deleted after restart.

    Example:

    Slave role send:AT+AVDA=1234567890AB

    Return:OK

    If at this point the master module state of AT+CONT=1, UART port will output:12345 67890AB.

    14.Mode 3 broadcast cycle(Only slaver)

    Set command:AT+TIME=x

    Query command:AT+TIME=?

    Parameter x setting range is as follows:
    x

    1

    2

    3

    4

    5

    6

    7

    8

    9

    A

    B

    C

    D

    E

    F

    time/

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    20

    30

    40

    50

    60

    sec

    (default)

    x

    F

    G

    H

    I

    J

    K

    time/

    1

    2

    5

    10

    30

    60

    min

    Example:

    Send:AT+TIME=F

    Return:OK

    Setting mode3 of the broadcast cycle for 60 seconds. Every 60 seconds, send a broadcast data.

    Send:AT+TIME=?

    Return:60s

    Solution of low power mode (slave module):

    1. The need to wake on wireless:

    Enter "AT+MODE=1" or "AT+MODE=3", the module will enter a low power mode until the master module request connection. After the connection, the current is 1.6mA. Data exchange module will automatically enter the full speed mode before connected, while after connected, it will return to the low power mode.

    2. Can active connection case:

    Enter "AT+MODE=2", it will enter a low power consumption mode2. The module entered the deep sleep state. It can not be discovered by master module. When you connect, you can send arbitrary data to awaken the module, and then it can send and receive data once connected .

    Solution of low power broadcasting mode:

    The first set master role:AT+CONT=1 -> AT+ROLE=M

    And then set slave role:AT+CONT=1 -> AT+AVDA=1234(≦12Bytes data)

    The users' MCU send 10 bytes hexadecimal code of "0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF" to the module of UART port in order to awaken the module into the full power mode. At this point, users can reasonably set according to their need. The above "AT+CONT=1, AT+AVDA=xxxx, AT+MODE=3, AT+TIME=5" is set to: "broadcast and can not connected". The broadcast data is XXXX, mode3(period of 5 seconds). According to the above, the average current is less than 4 μA, TIME will be more than 1 minutes. Longer this time, lower power consumption it will have.

    The user wants to transmit data frequently, proposed to enter mode2 in idle time, need to transmit data to switch to the corresponding mode.

    15.The master module to clear the slave module address have been recorded (Only master)

    Set command: AT+CLEAR

    Query command: OK

    The master module, once connected with the slave module, will remember the MAC address of the slave module in the last time. If you want to connect it to the other slave module, you must remove the current memory. The first way is to put the module 18 pin to high electric level of 200ms, the other way is to use the "AT+CLEAR" command.

Step 8: Reference Schematic


Step 9: Source

This article is from: https://www.elecfreaks.com/11565.html

If you have any questions, you can contact: louise@elecfreaks.com.