Hi-Link HLK-B40 User manual

Shenzhen Hi-Link Electronic co.,Ltd
HLK-B40
Master-slave integrated Bluetooth transparent transmission module
User Manual
Version:V1.2 Verified:2020-10-31 Copyright@ Hi-Link

User Manual
HLK-B40
CONTENTS
Terminology&noun interpretation................................................................................................................ 2
1. Introduction............................................................................................................................................3
2. Pin definition......................................................................................................................................... 4
3. Typical application circuits....................................................................................................................6
4. Basic functional instructions..................................................................................................................7
4.1 The principle of transmission.........................................................................................................7
4.2 Module operating mode (transmission and AT command mode)..................................................8
4.3 Description of the input and output pin functions...........................................................................9
4.4 Bluetooth device roles and connections.........................................................................................9
5. A quick start guide...............................................................................................................................10
5.1. Test the debug base plate................................................................................................................. 10
5.2. Quickly verify bluetooth serial transmission................................................................................... 11
6. Low power sleep function....................................................................................................................13
7. AT command.........................................................................................................................................13
7.1 ATinstruction format description......................................................................................................13
7.2 AT instruction list and description....................................................................................................14
8. Wireless settings and queries via Bluetooth.......................................................................................... 18
9. OTA functionality................................................................................................................................. 18
10. Contact info..........................................................................................................................................19

User Manual
HLK-B40
Terminology&noun interpretation
Name.
Instructions
Transmission
Transparent transmission is to forward data as is between Bluetooth and serial port
Bluetooth
A short-range wireless communication technology
BLE
Bluetooth Low Energy, a new Bluetooth technology specification that consumes
less power and has a higher transmission and communication distance
GATT
Bluetooth Low Energy (BLE) connections are based on the GATT (Generic
Attribute Profile) protocol and are a common specification for sending and
receiving data over Bluetooth connections
Bluetooth host
One of The roles of the device in the Bluetooth connection, the host to scan the device
slave and actively initiate the connection to the device, etc.
in the Bluetooth connection its leading role
Bluetooth from
the machine
One of the roles of the device in a Bluetooth connection, slave to broadcast its own
information, passively waiting for the connection
Bluetooth
broadcast
Bluetooth from the machine device through periodic broadcasting, so that the
surrounding host equipment can scan and identify themselves, the host device
according to the scanned slave information can initiate a connection to the
computer
Broadcast interval
Bluetooth sends broadcasts slave at intervals that are smaller and faster to scan but
the greater the power consumption, the smaller the power consumption
Connection
interval
When two Bluetooth devices are connected, the smaller the beat of the data, the
smaller the transmission speed, the smaller the delay but the greater the power
consumption
Pair the binding
A mechanism of communication security in Bluetooth technology, which realizes
the security of Bluetooth link layer
OTA
Air upgrade, i.e., the firmware of the module is wirelessly upgraded via Bluetooth
Re-connect
Intervals
When the module is the host, when the Bluetooth connection is not connected or
disconnected, the interval is automatically reconnected
Table 1 The term name interpretation table

User Manual
HLK-B40
1. Introduction
HLK-B40 is a kind of Master-Slave serial port transmission Bluetooth module based on BLE5.1, All kinds of
devices with serial port can use Bluetooth wireless to send and receive data simply and quickly through this module.
The basic functions and features are as follows,
Main frequency 48MHz, 32-bit ARM Cortex M3 core
Fast and stable Bluetooth-serial port transmission, serial port rate up to 921600
Master-to-one Bluetooth, which can be set to host or slave mode, supports binding encryption
Bluetooth from the machine mode can be connected by up to 20 host devices at the same time, supporting custom
broadcast data
Based on BLE5.1, it is faster and has a longer transmission distance and can reach 40 to 100 m in an open
environment
Supports low-power modes, sleep currents of up to6 μA and custom connection and broadcast intervals
Bluetooth transmit power can be adjusted up to 10dBm and receives up to -95dBm
Support for OTA Bluetooth wireless upgrade module firmware, wireless configuration module parameters
The default on-board high-quality ceramic antenna increases the transmission distance and includes an
external antenna
Built-in Watchdog, Long and reliable operation time
Ultrasmall size 14mm×9.5mm×2mm
Wide operating voltage 1.8 to 4.2V, typical 3.3V
Rich output pins (UART, I2C, SPI, up to 15 GPIOs, up to 4 ADCs, up to 6 PWMs) provide flexible and
in-depth hardware and software custom development services
2. Pin definition
Figure 1 Pin Position Diagram

User Manual
HLK-B40
Pins
Symbol.
IO
Type
Functions
1
GND
GND
Power source
2
MIC_BIA
-
Keep the functionality
3
MIC_IN
-
Keep the functionality
4
VMID
-
Keep the functionality
5
AOUT_P
-
Keep the functionality
6
AOUT_N
-
Keep the functionality
7
RESET
I
Reset restart module, high level is effective,
8
VCHG
PWR
Charger input, prohibited without battery
9
VBAT
PWR
The power supply is input to DC3.3V and the
10
GND
GND
Power source
11
VDDIO
-
Keep the functionality
12
PD7
-
Keep the functionality
13
PD6
-
Keep the functionality
14
PD5
-
Keep the functionality
15
PD4
-
Keep the functionality
16
PC7
O
Module Sleep State Output, High: Full Speed,
17
PC6
I
Module Hibernation
Control Input High: Go into hibernation, Low:
Exit Hibernation, Suspend as High
18
PC5
I
Function key input, low level is valid,
suspension is high
19
PA3
-
Keep the functionality
20
PA2
-
Keep the functionality
21
PA1
-
Keep the functionality
22
PA0
-
Keep the functionality
23
UART0_
O
The module serial output
24
UART0_
I
Module serial input

User Manual
HLK-B40
Pins
Symbol.
IO
Type
Functions
25
PA4
O
Bluetooth connection status output,
high: not connected, low: connected
26
PA5
O
Current operating mode output, high: master,
low: slave
27
LED
-
Keep the functionality
28
GND
GND
Power source
29
ANT
External antenna output
Table 2 Pin definition Table
3. Typical application circuits
Below is the basic application circuit reference of this module, if you need more functions, please refer to the
module manual or contact our engineers to assist.
Figure 2 Basic minimum circuit (disables low-power sleep function)
The enable and disable of the module's low-power sleep function can be set by the AT command, which is
disabled by default.
If the low-power sleep function is enabled, the module is controlled by the level of the sleep control input pin,
which is used to enter or exit hibernation, and the module outputs the current sleep state by the sleep state output
pin.

User Manual
HLK-B40
Figure 3 Basic minimum circuit (enables low-power sleep function)
Note:
1. RESET pin can not be suspended, it need to connect 10K drop-down resistance.
2. Metal object blocking will affect Bluetooth signal sending and receiving, use should make the module as
far away from metal objects as possible, PCB design requires modules
No copper can be laid under the antenna section.
4. Basic functional instructions
4.1The principle of transmission
HLK-B40 is a cost-effective Master-slave integrated Bluetooth transparent transmission module
introduced by Hi-Link, designed to enable only serial user devices to quickly and easily use Bluetooth for
wireless transmission, with the help of serial transmission, users do not need to care about complex
Bluetooth protocol stack and RF circuit, just a simple serial port transmission, data can be transmitted
directly on the Bluetooth wireless connection. Transmission is short for transparent transmission, means the
role of the module is equivalent to the serial port and Bluetooth connection between the establishment of
a transparent transmission pipeline, the user in the serial port issued data will be forwarded to the device
connected through Bluetooth, data sent through Bluetooth will also be forwarded to the serial port, the
entire process users do not need to care about complex Bluetooth connection how to
achieve, HLK-B40 module from beginning to end is only the original data transfer and transmission of data
without the user's convenience and transmission.
The principle schematic of the Bluetooth-serial port transmission function is as follows, see the quick start
guide for the specific test verification method.

User Manual
HLK-B40
Figure 4 One-to-one Bluetooth connection transmission function schematic
This module can be connected by multiple Bluetooth host devices when acting as a Bluetooth accessor, including
other B40 modules as hosts. Under a multi-to-one connection, the data received from the serial port of the machine
module is forwarded via Bluetooth to each connected host device, each Data from connected host devices is also
forwarded to the serial port from the machine module.
Figure 5 A map of the many-to-one Bluetooth connection transmission function
4.2 Module operating mode (transmission and AT command mode)
HLK-B40 module has both transmission mode and AT command mode.
In AT command mode, you can query and set the parameters of the module by sending the AT command to
the module through a serial port.
In transmission mode, the module transfers serial data and Bluetooth-connected data in both directions.
When the module starts, the default is transmission mode. Exiting transmission mode into AT mode will not

User Manual
HLK-B40
affect the Bluetooth connection state, string Mouth-Bluetooth pivot is paused, the data received by the serial
port is processed by the current AT instruction;
In transmission mode, the 18th pin PC5 is entered with a short low level (0.5 to 3s) and the module switches
out of transmission to AT command mode.
In AT command mode, the AT-TS-1 command is sent to restore the exit AT command mode to transmission
mode.
The conversion logic for transmission mode and AT command mode is as follows:
Figure 6 A diagram of the conversion logic of the transmission mode and the AT command mode
4.3 Description of the input and output pin functions
Name.
Chip pin
Description
Reset key input
RESET
High level is effective and requires an external 10K drop-
down resistor
Enter the high-level module to restart the module
Function button input
PC5
The inside is pulled up and the action is pulled down
Pull down 0.5 to 3 seconds: exit transmission and switch to
AT command mode;
Pull down 8 to 20 seconds: restore the factory default
settings
The module sleep
control input
PC6
Internal pull-up, suspension or input high-level module
automatically into hibernation, input low normal full-speed
operation;

User Manual
HLK-B40
Valid only if the low-power sleep function is enabled
The module hibernate
state output
PC7
High level - full speed work, low level - hibernation
Bluetooth connection
status output
PA4
High level - not connected, low level - connected,
transmission channel has been established; When the
pairing binding feature enables, the pairing encryption is
successfully represented on the connection
The operating mode
output
PA5
High level = master, low level = slave
Figure 3 Description of the input and output pin functions
4.4 Bluetooth device roles and connections
Devices at both ends of the Bluetooth connection have fixed roles, one is the host role, the other is the slave
role. Different roles of equipment define the corresponding operations and responsibilities.
The host discovers the slave device by scanning the slave broadcast and actively initiates a connection to the
selected slave device (identified by the MAC address) and Maintain the connection and play a leading role in a
Bluetooth connection
The slave broadcasts its own information, such as the device name, etc. The slave passively waits for the
connection request initiated by the master and accepts the request to connect to Bluetooth Successfully established.
This module can be connected to multiple host devices at the same time as a slave.
The B40 module defaults to the slave mode and the settings can be switched through the AT+ROLE command.
After the two devices establish a Bluetooth connection, they can send data to each other via Bluetooth (GATT).
The Bluetooth GATT service and feature UUID of this module can be modified by AT command, the default
values are as follows:
Service UUID:0000fff0-0000-1000-8000-00805f9b34fb
Feature UUID
Action permissions
The function
definition
0000fff1-0000-1000-8000-00805f9b34fb
Read/Notify
Module send,
APP receive
0000fff2-0000-1000-8000-00805f9b34fb
Write Without Response
APP send,
module receive
Figure 4 Bluetooth transmission service UUID default

User Manual
HLK-B40
You can choose to turn on the pairing and binding function of the Bluetooth connection. After it is turned on, the
security can be increased, but the operation steps are increased accordingly. It is valid in slave or master mode. The
pairing method is PASSKEY ENTRY, 6-digit PingCode. After the binding function is turned on, Bluetooth data
can be sent and received only after pairing and binding. Unpaired devices cannot transparently transmit data
through Bluetooth and the module.
In the master mode, you need to set the MAC address of the target slave to be connected. After the module
starts, it will automatically scan and connect to the target slave device and will automatically reconnect and
reconnect if the slave is not found or the connection is disconnected. The interval time can be set by the
AT+RECONNI command, the default is 5s, that is, when it is not connected, it will try to reconnect every 5
seconds until it is connected.
5. A quick start guide
5.1. Test the debug base plate
In order to enable users to quickly verify and debug the module, our company has developed a dedicated B40
test board. It is recommended that you choose to use this test board when you use this module for the first time.
The test board is directly powered by USB and comes with a USB-to-serial function. After connecting to the
computer through the USB cable, you can connect to the module's serial port through the USB-to-serial port. No
additional serial cable is required, which is easy to use.
Figure 7 The module tests the appearance and functional schematic of the base plate

User Manual
HLK-B40
5.2. Quickly verify bluetooth serial transmission
Our company has developed a special mobile phone Bluetooth transparent transmission test APP for this
module for users to use. For APP introduction and instructions, please refer to HLK-B40 Bluetooth Transparent
Transmission Module Mobile APP Instructions.
Use the module test bottom board and the mobile phone Bluetooth transparent transmission test APP to
immediately start to test and verify the module's serial port-Bluetooth transparent transmission function.
The specific test procedures are as follows:
Connect the module to the test board correctly and connect the test board to the computer through a USB
cable.
Open the corresponding serial port on your computer with the serial debugging tool.
Open the transparent transmission test APP on the mobile phone, the APP will automatically search for
surrounding Bluetooth devices and display them in a list.
Click the Bluetooth device name corresponding to the module in the device list to connect. The default name
of the B40 module is HLK_B40_**** and the suffix is the last four digits of the MAC address.
Figure 8 Figure of transmission test measurement tool
After the app is successfully connected to the module, the connection status LED on the test board will turn on,
means the connected state.
At this time, the data can be sent to the serial port of the module in the serial port debugging tool on the
computer and the sent content will be received and displayed as it is by the mobile phone app;
Send data from the transparent transmission test app on the mobile phone to the module, the sent content will be
received by the module as it is and output to the serial port of the module. The received data can be seen in the
serial port debugging tool on the computer. The effect is as follows:

User Manual
HLK-B40
Serial port of module Mobile APP
Figure 9 Data transmission through serial port and app
6. Low power sleep function
This module is developed based on BLE 5.1 supporting low power consumption and can be flexibly
configured in many aspects to further reduce power consumption.
Configurable items
Description
Adjust transmit power
The lower the transmission power, the lower the power consumption but
the shorter the transmission distance
Adjust the broadcast interval
and connection interval
The larger the interval, the lower the power consumption but the greater
the delay
Turn on auto sleep
6μA After the automatic sleep function is turned on, the module can be
controlled by the input level of the external sleep control input pin.
High level: the main chip will sleep automatically.
Low level: wake up to work at full speed.
The minimum operating current can be as low as 6 μ a during dormancy
Figure 5 A list of configuration items to reduce power consumption
All the above can be modified through the AT command, the user can be flexible according to the actual
application scenario and requirements to achieve a balance between power consumption and performance.
When automatic sleep is turned on, the hibernate output outputs different levels to indicate whether the module is

User Manual
HLK-B40
currently dormant or wake-up:
High: wake-up, full-speed operation.
Figure 10 Control and state timing after low power function is turned on
7. AT command
7.1 ATinstruction format description
All at instructions are in ascii string format and end with carriage return.
Power failure will not be lost after setting. All settings will take effect only after restart.
Query class instructions:
Send
Response
AT+<CMD>=?\r\n
Query success:
AT+<CMD>=<val>\r\n
OK\r\n
Or query failed:
AT+<CMD>=<val>\r\n
ERROR\r\n

User Manual
HLK-B40
Set class instructions:
Send
Response
AT+<CMD>=<val>\r\n
Set sucessfully:
AT+<CMD>=<val>\r\n
OK\r\n
Or set failure:
AT+<CMD>=<val>\r\n
ERROR\r\n
For ASCII code: 0x0D 0x0A
7.2 At instruction list and description
Item
command
name
Description
Range parameters
Example
1
VER
Software
versions
Read only
send
response
AT+MAC=?
AT+VER=1.03(20092421)
OK
2
MAC
MAC address
Read only
send
response
AT+MAC=?
AT+MAC=112233445501
OK
3
DEFAULT
Restore the
default
configuration
1
Send
response
AT+DEFAULT=1
AT+DEFAULT=1
OK
4
REBOOT
Restart the
module
1
Send
Response
AT+REBOOT=1
AT+REBOOT=1
OK
5
TS
Restore
transmission
mode
1
Send
response
AT+TS=1
AT+TS=1
OK
6
NAME
Module.
Bluetooth name
Up to 28 characters
Default: HLK_B40_.
send
response
AT+NAME=?
AT+NAME=HLK_B40
OK
send
response
AT+NAME=ble_1234
AT+NAME=ble_1234
OK

User Manual
HLK-B40
7
BAND
Serial.
Porter rate
1200,2400,4800,9600,14400,
19200,38400,57600,115200,
230400,460800,921600
Default:115200
send
response
AT+BAND=?
AT+BAND=115200
OK
send
response
AT+BAND=230400
AT+BAND=230400
OK
8
RFPOWER
Bluetooth.
Transmit power
1-18, 18 grades
Default: 8
The smaller the transmission
distance, the lower the power
consumption; the larger the
transmission distance, the
greater the power
consumption
send
response
AT+RFPOWER=?
AT+RFPOWER=8
OK
send
response
AT+RFPOWER=10
AT+RFPOWER=10
OK
9
SLEEPEN
auto sleep
Enable
0 disable sleep
1 enable sleep
Default value: 0
After enabling, the module
will automatically enter the
sleep state according to the
control of the level of the
SLEEPEN input pin
send
response
AT+SLEEPEN=?
AT+SLEEPEN=0
OK
send
response
AT+SLEEPEN=1
AT+SLEEPEN=1
OK
10
CONNI
Bluetooth
Connection
interval
6~3200,
The unit is 1.25ms, i.e. 7.5-
4000ms.
The default value is 24
The smaller the transceiver,
the faster the power
send
response
AT+CONNI=?
AT+CONNI=24
OK
send
response
AT+CONNI=8
AT+CONNI=8
OK
11
ADVI
Bluetooth
Broadcast
interval
Unit: 625us
Recommended value:
80,160,320,800,
1600,3200
Default value: 800
send
response
AT+ADVI=?
AT+ADVI=800
OK
send
response
AT+ADVI=1600
AT+ADVI=1600
OK
12
ADVDATA
Self-define
Broadcast data
Hexadecimal number, the
number of characters is a
multiple of 2, up to 40
hexadecimal numbers
Default: none
send
response
AT+ADVDATA=?
AT+ADVDATA=03FF1A1B
OK
send
response
AT+ADVDATA=68696C696E6B
AT+ADVDATA=68696C696E6B
OK

User Manual
HLK-B40
13
ROLE
module
BLE role
1 slave
2 host
Default value: 1
send
response
AT+ROLE=?
AT+ROLE=1
OK
send
response
AT+ROLE=2
AT+ROLE=2
OK
14
ENCRYPT
Pairing binding
Enable
0 does not require pairing
binding
1 requires pairing and
binding
Default value: 0
send
response
AT+ENCRYPT=?
AT+ENCRYPT=0
OK
send
response
AT+ENCRYPT=1
AT+ENCRYPT=1
OK
15
PINCODE
Pairing code
6-bit integer
Default value: 000000
send
response
AT+PINCODE=?
AT+PINCODE=000000
OK
send
response
AT+PINCODE=123456
AT+PINCODE=123456
OK
16
PEERMAC
When the
module is the
master, it
automatically
goes to the
MAC address of
the slave
MAC address, 12
hexadecimal numbers
send
response
AT+PEERMAC=?
AT+PEERMAC=AABBCC000001
OK
send
response
AT+PEERMAC=AABBCC000001
AT+PEERMAC=AABBCC000001
OK
17
AUTHPWG
OTA and air-
configured
access
passwords
Up to 8 characters
Default: Hi- Link
send
response
AT+AUTHPWG=?
AT+AUTHPWG=HiLink
OK
send
response
AT+AUTHPWG=68686868
AT+AUTHPWG=68686868
OK
18
CONNSTATE
Query the
device
information for
the current
Bluetooth
connection
Read-only
Responses includes:
Number of devices currently
connected Each
device's Role, MAC
send
respnse
AT+CONNSTATE=?
AT+CONNSTATE=2
M,4E21FB831492
M,539FD7108A6D
OK

User Manual
HLK-B40
19
RECONNI
Bluetooth
automatically
re-connects
when the
module is the
host
Integer, unit s
0: Represents only one
attempt to connect at startup,
not a reconnect
1 to 60: The connection is
automatically reconnected
after a specified number of
send
response
AT+RECONNI=?
AT+RECONNI=0
OK
send
response
AT+RECONNI=10
AT+RECONNI=10
OK
20
UUIDS
Bluetooth
transmission
service UUID
32 hexadecimals
Default:
0000fff00000100080000080
5f9b34fb
21
UUIDR
Read feature
UUID in
transmission
service (module
transmite, APP
receive)
32 hexadecimals
Default:
0000fff10000100080000080
5f9b34fb
22
UUIDW
White feature
UUID in APP
transmission
(APP receive
module
transmite)
32 hexadecimals
Default:
0000fff20000100080000080
5f9b34fb
Table 6 AT command list and description

User Manual
HLK-B40
8. Wireless settings and queries via Bluetooth
In the mobile phone APP, the module can be queried and set up by Bluetooth wireless, please refer to the
HLK-B40 Bluetooth transmission mode phone APP usage instructions.
9. OTA functionality
In the mobile phone APP, through Bluetooth wireless upgrade module firmware, the specific operation
please refer to the HLK-B40 Bluetooth transmission module mobile phone APP Instructions for use.
10. Contact info
Shenzhen Hi-Link Electronic CO.,Ltd
Address:3F,Caiyue Mansion West gate,Liuxian Blvd,MinZhi
Street,LongHua District,Shenzhen,China
Phone:0755-23152658/83575155
Email: [email protected]
Table of contents
Popular Transmitter manuals by other brands

Comnet
Comnet FVT4014SHR Installation and operation manual

Becker
Becker Centronic EasyControl EC142-II Assembly and operating instructions

MGC
MGC UDACT-300A Installation and operation manual supplement

ADJ
ADJ WIFLEX DMX SYSTEM quick start guide

ABB
ABB AWT420 manual

Labom
Labom PASCAL CS21 0 Series operating instructions

Siemens
Siemens CP 1242-7 GPRS V2 operating instructions

Siemens
Siemens SITRANS L Series Compact operating instructions

RKI Instruments
RKI Instruments 65-2451RK-05 Operator's manual

ENERGY SISTEM
ENERGY SISTEM Car Transmitter FM Bluetooth user manual

MikroTik
MikroTik D2352AC quick guide

Emerson
Emerson Rosemount 3300 Series quick start guide