E-mail: info@hyxkiot.com Call: +86 13480952801
Your Location:Home > News > Industry News

How to Program Wireless Bluetooth Module

Release date:2022-1-6 19:03:16

Bluetooth: It is a wireless technology standard that can realize short-distance data exchange between fixed devices, mobile devices and building personal area networks (using UHF radio waves in the ISM band of 2.4-2.485 GHz). The difference between wireless and wired communication lies in the different transmission media. The most commonly used Bluetooth module is the HC-05 master-slave integrated Bluetooth serial communication module, which is a data transmission module based on Bluetooth Specification V2.0 with EDR Bluetooth protocol. The wireless working frequency band is 2.4GHz ISM, and the modulation method is GFSK. The maximum transmit power of the module is 4dBm, and the on-board PCB antenna can realize communication at a distance of 10 meters. At present, HYXK's Bluetooth 5.1 module HY-BT102 can replace HC-05 with PIN to PIN. The following is the difference between Bluetooth wireless connection and wired communication, take the Bluetooth module HY-BT102 communication as an example


When using the Bluetooth module, HYXK will provide the corresponding information, so the difficulty of getting started is relatively small. But everyone must be careful about the following points:

1) Port connection, when connected to the serial port of the microcontroller, the two can read and write each other. For example, the single-chip microcomputer transmits data to the Bluetooth module HC-05, that is, writes data to the HC-05, and HC-05 reads the data from the single-chip, then the write terminal pin (TX) of the single-chip computer at the serial port connection is the same as the HC-05 read terminal (RX) is connected. On the contrary, when Bluetooth transmits data to the microcontroller, the HC-05 write terminal (TX) T is connected to the read terminal pin (RX) of the microcontroller.

One sentence summary: Must remember that the MCU TX is connected to Bluetooth RX, and the MCU RX is connected to Bluetooth TX, otherwise Bluetooth must not work normally. Note: Only when the read-write terminal is connected correctly can it communicate normally.

2) Bluetooth configuration, the setting determines the role of the Bluetooth module after it is automatically connected to work. The master role (Master) will automatically search for pairing connections, and the slave role (Slave) will only passively accept connections and will not actively search. The loopback role (Loopback) belongs to Passive connection, receiving data from the remote Bluetooth master device and returning the data to the remote Bluetooth master device as it is.

If two HC05 modules want to establish a connection, one of them must be set as master and the other can be set as slave or loopback. If an HC05 module communicates with a computer Bluetooth or mobile phone Bluetooth, the computer or mobile phone can actively establish a connection, so HC05 can be used Slave device, the factory default is also set as a slave device.

3) Bluetooth working mode. On the Bluetooth module, there must be a mode pin KEY, which defaults to low level when floating, and the module works in serial port transparent transmission mode; when high level, the module enters AT command mode.


The AT command mode is also called the parameter setting mode. The single-chip microcomputer can set the common parameters of the Bluetooth module through AT commands, such as name and baud rate.

Serial port throughput mode, after the AT mode is set, the Bluetooth module can officially work externally. For example, the MCU sends data to the Bluetooth module through the serial port, and the Bluetooth module sends the data directly to the mobile phone. After the mobile phone receives the message, it may send the successfully received command to the MCU according to the response from the mobile phone server, but it is not an AT command mode reply.

Notice

When designing a Bluetooth product, pay attention to the Bluetooth module working in the 2.4G wireless frequency band, and try to avoid the influence of various factors on the wireless transmission and reception, and also pay attention to the following points:

1. Avoid using metal in the product shell surrounding the Bluetooth module. When using a partial metal shell, keep the antenna part of the module away from the metal part as much as possible. The metal connecting wires or metal screws inside the product should be as far away as possible from the antenna part of the module.

2. The antenna part of the module should be placed around the carrier board PCB. It is not allowed to be placed in the board, and the carrier board under the antenna is milled out. It is parallel to the antenna and no copper or wiring is allowed. It is also a better choice to expose the antenna part directly to the carrier board.

3. Try to spread a large piece of GND under the module, and try to extend the wiring to the periphery.

Copyright © 2021 Shenzhen Huayang Xinke Electronics Co., Ltd. All rights reserved