Method for communicating with intelligent instrument by using Bluetooth

By re-developing the Bluetooth module and defining the Bluetooth-to-Modbus protocol, the problem of low efficiency in data reading and configuration settings of the traditional communication interface is solved, fast and reliable data transmission and configuration settings are achieved, and the user experience is improved.

CN118714547APending Publication Date: 2024-09-27HANGZHOU PANGU AUTOMATION SYST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411082950.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-08
Publication Date
2024-09-27

AI Technical Summary

Technical Problem

The fieldbus communication of traditional industrial instruments is not conducive to fast and convenient data reading and configuration settings. NFC communication is limited by device proximity requirements and is not popular. The common Bluetooth transparent transmission module in the market leads to insufficient data transmission optimization and poor user experience. .

Method used

Through secondary development of the Bluetooth module, we provide a fast and reliable data link, define a Bluetooth-to-Modbus communication protocol, use timing reading and broadcast features to achieve real-time data transmission, and reduce the need for direct reading of instruments after connection, optimizing data Packet transmission and retry mechanisms to improve efficiency.

Benefits of technology

It realizes fast data reading and configuration settings of instruments during production, debugging, and maintenance, improving user experience. It provides real-time data and configuration information through the Bluetooth module, reduces host waiting time, and improves data transmission efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118714547A
    Figure CN118714547A
Patent Text Reader

Abstract

The invention belongs to the technical field of communication, and discloses a method for communicating with an intelligent instrument by using Bluetooth, which comprises the following steps of: 1, performing secondary development on a program in a Bluetooth module, and providing a rapid and reliable data link; and step 2, defining a Bluetooth to Modbus communication protocol, wherein the data read-write operation which is not commonly used is completed by using the Bluetooth to Modbus communication protocol. As an additional communication interface of an intelligent instrument, the communication interface can provide quick data reading and configuration setting in the production, debugging and maintenance processes of the instrument.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of communication technology, and in particular relates to a method for communicating with an intelligent meter using Bluetooth. Background Art

[0002] Most traditional industrial instruments use fieldbus as the communication interface. Fieldbus is conducive to system integration, but it is not conducive to fast and convenient data reading and configuration setting of instruments during production, debugging and maintenance.

[0003] Some modern instruments provide NFC (near field communication) as a quick access measure during production, debugging and maintenance. However, NFC communication requires the communication host (usually a mobile phone) to be close to the instrument to be communicated. It is only suitable for specific installation methods and locations, and NFC is not a standard feature of every mobile phone.

[0004] Some modern instruments provide Bluetooth as a quick access measure during production, debugging, and maintenance. However, the use of common Bluetooth transparent transmission modules on the market limits the optimization of data transmission, resulting in poor user experience and a lot of time wasted waiting for data transmission. Summary of the invention

[0005] The present invention aims to provide a method for communicating with a smart meter using Bluetooth to solve the above technical problems.

[0006] In order to solve the above technical problems, the specific technical solution of a method for communicating with a smart meter using Bluetooth is as follows: A method for communicating with a smart meter using Bluetooth comprises the following steps: Step 1: Provide fast and reliable data link by secondary development of the program in the Bluetooth module; Step 2: Define the Bluetooth to Modbus communication protocol. Uncommon data read and write operations are completed using the Bluetooth to Modbus communication protocol.

[0007] Furthermore, the step 1 includes step 1.1: setting a timing program in the program of the Bluetooth module, the Bluetooth module regularly reads real-time data from the instrument, and when the Bluetooth host needs to read the real-time data of the instrument, it can immediately obtain the data from the Bluetooth module without going to the instrument to read.

[0008] Furthermore, the step 1 includes step 1.2: utilizing the Bluetooth broadcast feature, when the Bluetooth connection is not established, the instrument key real-time data is broadcast through a broadcast data packet, and the Bluetooth host can see the corresponding real-time data when searching for the Bluetooth device in the search interface.

[0009] Furthermore, the step 1 includes step 1.3: the first two bytes of the Bluetooth broadcast data packet identify the instrument type, different instrument types broadcast different real-time data, and after receiving the broadcast data packet, the Bluetooth host can distinguish the instrument type according to the identification of the first two bytes and make correct analysis of the broadcast data.

[0010] Furthermore, the step 1 includes step 1.4: the Bluetooth module provides real-time data characteristics, and uses the real-time data read at a fixed time to update the data characteristic value. When the Bluetooth host establishes a connection with the Bluetooth module, the instrument data is read by reading the real-time data characteristic value, without the need to read the instrument.

[0011] Furthermore, the step 1 includes step 1.5: the Bluetooth module provides key configuration characteristics, and the key configuration characteristic values ​​include real-time data units, calibers, and sensor coefficients. When the Bluetooth host establishes a connection with the Bluetooth module, reading the configuration characteristic values ​​once can fully display the instrument's real-time data and some key configuration information.

[0012] Furthermore, the step 1 includes step 1.6: the Bluetooth module provides the instrument version characteristics, and the instrument version information is immediately read after the instrument and the Bluetooth module are powered on and stored in the version characteristic value of the Bluetooth module. When the Bluetooth host reads the version information, it does not need to read it from the instrument again.

[0013] Furthermore, the step 1 includes step 1.7: when the Bluetooth host initiates the establishment of the Bluetooth connection, the Bluetooth module immediately reads the key configuration of the instrument as the key configuration characteristic value, and uses the gap between the Bluetooth host initiating the Bluetooth connection and requesting Bluetooth data to read the instrument configuration.

[0014] Furthermore, the step 2 includes step 2.1: implementation method of Bluetooth to Modbus request: when the data length of the Modbus request exceeds 20 bytes, multiple characteristic value write operations are merged into one Modbus request, and the write characteristic value of up to 20 bytes is divided into two parts, the first byte is used as the address offset, and the subsequent bytes are used as part of the Modbus request data packet content. If the total length of the write characteristic value is less than 20 bytes, then it is judged that the current Modbus request data packet ends. If the size of the last subpacket is exactly 20 bytes, then it is necessary to send a write characteristic value operation containing only a 1-byte address offset to inform the Bluetooth module that the Modbus request data packet ends. The data packet sent by the Bluetooth host does not contain the Modbus device address and CRC16 check. After receiving the complete Modbus request data packet, the Bluetooth module adds the device address and CRC16 check and sends it to the instrument.

[0015] Further, the step 2 includes step 2.2: a method for implementing the conversion of Modbus response to Bluetooth: when the Bluetooth module sends a Modbus request data packet, it enters a state of waiting for a Modbus response data packet. If the response times out, the Bluetooth module retries. When the Bluetooth module receives the Modbus response data packet of the instrument, the Bluetooth module checks the address and CRC16 check of the data packet. If there is an error, the Bluetooth module retries. If there is still no correct Modbus response data packet after exceeding the specified number of retries, the Bluetooth module sends a response data packet with an abnormal instrument response to the Bluetooth host. If a correct Modbus response data packet is received, the Bluetooth module removes the Modbus device address and CRC16 and sends it to the Bluetooth host. The Bluetooth module sends an M to the Bluetooth host through notification or instruction. Modbus response data packet adopts notification or indication combined with a readable characteristic to realize the transmission of complete response data packet. The 22-byte content of notification or indication data packet is divided into two parts. The first byte is the total length of Modbus response data packet, and the subsequent content is the first 21 bytes of Modbus response data packet. When the Bluetooth host receives the notification or indication sent by the Bluetooth module, it checks the first byte of the notification or indication data packet content. If the value of the first byte is less than 22, then the notification or indication data packet already contains the complete Modbus response data packet, and there is no need to read the Modbus response characteristic value; if the value of the first byte is greater than or equal to 22, then the notification or indication data packet only contains the first 21 bytes of the Modbus response data packet, and the Modbus response characteristic value needs to be read to read the complete Modbus response data packet.

[0016] The method of using Bluetooth to communicate with an intelligent instrument of the present invention has the following advantages: the present invention, as an additional communication interface for intelligent instruments, can provide quick data reading and configuration settings during the production, debugging and maintenance of instruments. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 It is a schematic diagram of the method of communicating between Bluetooth and smart meters of the present invention. DETAILED DESCRIPTION

[0018] In order to better understand the purpose, structure and function of the present invention, a method for communicating with a smart meter using Bluetooth according to the present invention is further described in detail below in conjunction with the accompanying drawings.

[0019] The present invention adopts a general Bluetooth module with good quality and low price on the market, and performs secondary development on the program in the Bluetooth module to optimize the user experience, provide a fast and reliable data link, and provide an efficient and general Bluetooth to Modbus communication protocol.

[0020] like Figure 1As shown, a method of using Bluetooth to communicate with a smart meter of the present invention specifically includes the following steps: Step 1: Provide fast and reliable data link by secondary development of the program in the Bluetooth module; Step 1.1: Set a timing program in the Bluetooth module program. The Bluetooth module reads real-time data from the instrument at a fixed time. When the Bluetooth host needs to read the real-time data of the instrument, it can immediately obtain the data from the Bluetooth module without going to the instrument to read.

[0021] Step 1.2: Utilize the Bluetooth broadcast feature. When no Bluetooth connection is established, broadcast the instrument's key real-time data through a broadcast data packet. The Bluetooth host can see the corresponding real-time data when it searches for the Bluetooth device in the search interface.

[0022] Step 1.3: The first two bytes of the Bluetooth broadcast data packet identify the instrument type. Different instrument types broadcast different real-time data. After receiving the broadcast data packet, the Bluetooth host can distinguish the instrument type based on the identification of the first two bytes and make correct analysis of the broadcast data.

[0023] Step 1.4: The Bluetooth module provides real-time data features. The data feature value is updated using the real-time data read at regular intervals. When the Bluetooth host establishes a connection with the Bluetooth module, the instrument data is read by reading the real-time data feature value. There is no need to read the instrument, which shortens the waiting time of the Bluetooth host and improves the user experience.

[0024] Step 1.5: The Bluetooth module provides key configuration characteristics. The key configuration characteristic values ​​include real-time data units, calibers, sensor coefficients, etc. When the Bluetooth host establishes a connection with the Bluetooth module, reading the configuration characteristic values ​​once can fully display the instrument's real-time data and some key configuration information.

[0025] Step 1.6: The Bluetooth module provides the instrument version feature. After the instrument and the Bluetooth module are powered on, the instrument version information is immediately read and stored in the version feature value of the Bluetooth module. When the Bluetooth host reads the version information, it does not need to read it from the instrument again, which shortens the waiting time of the Bluetooth host and improves the user experience.

[0026] Step 1.7: When the Bluetooth host initiates the establishment of a Bluetooth connection, the Bluetooth module immediately reads the key configuration of the instrument as the key configuration characteristic value, and uses the gap between the Bluetooth host initiating the Bluetooth connection and requesting Bluetooth data to read the instrument configuration, thereby shortening the waiting time of the Bluetooth host and improving the user experience.

[0027] Step 2: Define the Bluetooth to Modbus communication protocol. Other uncommon data read and write operations are completed using the Bluetooth to Modbus communication protocol.

[0028] Step 2.1: Implementation method of Bluetooth to Modbus request: Due to the limitation of Bluetooth host, only 20 bytes can be written when writing characteristic values, while the Modbus application layer data can reach up to 253 bytes. When the data length of the Modbus request exceeds 20 bytes, multiple characteristic value write operations are merged into one Modbus request. The write characteristic value of up to 20 bytes is divided into two parts, the first byte is used as the address offset, and the subsequent bytes are used as part of the Modbus request data packet content. If the total length of the write characteristic value is less than 20 bytes, it is judged that the current Modbus request data packet ends. If the size of the last sub-packet is exactly 20 bytes, it is necessary to send a write characteristic value operation containing only 1 byte address offset to inform the Bluetooth module that the Modbus request data packet ends. The data packet sent by the Bluetooth host does not contain the Modbus device address and CRC16 check. After receiving the complete Modbus request data packet, the Bluetooth module adds the device address and CRC16 check and sends it to the instrument.

[0029] Step 2.2: Implementation method of converting Modbus response to Bluetooth: After the Bluetooth module sends a Modbus request data packet, it enters the state of waiting for the Modbus response data packet. If the response times out, the Bluetooth module will retry. After the Bluetooth module receives the Modbus response data packet from the instrument, the Bluetooth module will check the address, CRC16 check, etc. of the data packet. If there is an error, the Bluetooth module will retry. If there is still no correct Modbus response data packet after exceeding the specified number of retries, the Bluetooth module will send a response data packet with an abnormal instrument response to the Bluetooth host. If the correct Modbus response data packet is received, the Bluetooth module will remove the Modbus device address and CRC16 and send it to the Bluetooth host. The Bluetooth module sends the Modbus response data packet to the Bluetooth host through notification or indication, but the notification or indication can only send the first 22 bytes at most, and the Modbus response data packet length can reach up to 253 bytes. Therefore, the notification or indication combined with a readable feature is used to realize the transmission of the complete response data packet. The 22-byte content of the notification or indication data packet is divided into two parts. The first byte is the total length of the Modbus response data packet, and the subsequent content is the first 21 bytes of the Modbus response data packet. When the Bluetooth host receives the notification or indication sent by the Bluetooth module, it checks the first byte of the notification or indication data packet. If the value of the first byte is less than 22, the notification or indication data packet already contains a complete Modbus response data packet, and there is no need to read the Modbus response characteristic value; if the value of the first byte is greater than or equal to 22, the notification or indication data packet only contains the first 21 bytes of the Modbus response data packet, and the Modbus response characteristic value needs to be read to read the complete Modbus response data packet.

[0030] It is to be understood that the present invention is described by some embodiments, and it is known to those skilled in the art that various changes or equivalent substitutions may be made to these features and embodiments without departing from the spirit and scope of the present invention. In addition, under the teachings of the present invention, these features and embodiments may be modified to adapt to specific circumstances and materials without departing from the spirit and scope of the present invention. Therefore, the present invention is not limited by the specific embodiments disclosed herein, and all embodiments falling within the scope of the claims of this application are within the scope of protection of the present invention.

Claims

1. A method for communicating with a smart meter using Bluetooth, characterized in that: The steps include: Step 1: Provide fast and reliable data link by secondary development of the program in the Bluetooth module; Step 2: Define the Bluetooth to Modbus communication protocol. Uncommon data read and write operations are completed using the Bluetooth to Modbus communication protocol.

2. The method for communicating with a smart meter using Bluetooth according to claim 1, characterized in that: The step 1 includes step 1.1: setting a timing program in the program of the Bluetooth module, and the Bluetooth module periodically reads real-time data from the instrument. When the Bluetooth host needs to read the real-time data of the instrument, it can immediately obtain the data from the Bluetooth module without going to the instrument to read.

3. The method for communicating with a smart meter using Bluetooth according to claim 1, characterized in that: The step 1 includes step 1.2: utilizing the Bluetooth broadcast feature, when the Bluetooth connection is not established, broadcasting the instrument's key real-time data through a broadcast data packet, and the Bluetooth host can see the corresponding real-time data when searching for the Bluetooth device in the search interface.

4. The method for communicating with a smart meter using Bluetooth according to claim 1, characterized in that: The step 1 includes step 1.3: the first two bytes of the Bluetooth broadcast data packet identify the instrument type, and different instrument types broadcast different real-time data. After receiving the broadcast data packet, the Bluetooth host can distinguish the instrument type according to the identification of the first two bytes and make correct analysis of the broadcast data.

5. The method for communicating with a smart meter using Bluetooth according to claim 1, characterized in that: The step 1 includes step 1.4: the Bluetooth module provides real-time data characteristics, and uses the real-time data read at a fixed time to update the data characteristic value. When the Bluetooth host establishes a connection with the Bluetooth module, the instrument data is read by reading the real-time data characteristic value, without going to the instrument to read.

6. The method for communicating with a smart meter using Bluetooth according to claim 1, characterized in that: The step 1 includes step 1.5: the Bluetooth module provides key configuration characteristics, and the key configuration characteristic values ​​include real-time data units, calibers, and sensor coefficients. When the Bluetooth host establishes a connection with the Bluetooth module, reading the configuration characteristic values ​​once can fully display the instrument real-time data and some key configuration information.

7. The method for communicating with a smart meter using Bluetooth according to claim 1, characterized in that: The step 1 includes step 1.6: the Bluetooth module provides the instrument version characteristics, and the instrument version information is immediately read after the instrument and the Bluetooth module are powered on and stored in the version characteristic value of the Bluetooth module. When the Bluetooth host reads the version information, it does not need to read it from the instrument again.

8. The method for communicating with a smart meter using Bluetooth according to claim 1, characterized in that: The step 1 includes step 1.7: when the Bluetooth host initiates the establishment of the Bluetooth connection, the Bluetooth module immediately reads the key configuration of the instrument as the key configuration characteristic value, and uses the gap between the Bluetooth host initiating the Bluetooth connection and requesting Bluetooth data to read the instrument configuration.

9. The method for communicating with a smart meter using Bluetooth according to claim 1, characterized in that: The step 2 includes step 2.1: implementation method of Bluetooth to Modbus request: when the data length of the Modbus request exceeds 20 bytes, multiple characteristic value write operations are merged into one Modbus request, and the write characteristic value of up to 20 bytes is divided into two parts, the first byte is used as the address offset, and the subsequent bytes are used as part of the Modbus request data packet content. If the total length of the write characteristic value is less than 20 bytes, it is judged that the current Modbus request data packet ends. If the size of the last subpacket is exactly 20 bytes, it is necessary to send a write characteristic value operation containing only a 1-byte address offset to inform the Bluetooth module that the Modbus request data packet ends. The data packet sent by the Bluetooth host does not contain the Modbus device address and CRC16 check. After receiving the complete Modbus request data packet, the Bluetooth module adds the device address and CRC16 check and sends it to the instrument.

10. The method for communicating with a smart meter using Bluetooth according to claim 1, characterized in that: The step 2 includes step 2.2: a method for implementing the conversion of Modbus response to Bluetooth: after the Bluetooth module sends a Modbus request data packet, it enters a state of waiting for a Modbus response data packet. If the response times out, the Bluetooth module retries. After the Bluetooth module receives the Modbus response data packet of the instrument, the Bluetooth module checks the address and CRC16 check of the data packet. If there is an error, the Bluetooth module retries. If there is still no correct Modbus response data packet after exceeding the specified number of retries, the Bluetooth module sends a response data packet of an abnormal instrument response to the Bluetooth host. If a correct Modbus response data packet is received, the Bluetooth module removes the Modbus device address and CRC16 and sends it to the Bluetooth host. The Bluetooth module sends a Modbus response to the Bluetooth host through notification or instruction. The bus response data packet adopts the method of combining notification or indication with a readable characteristic to realize the transmission of the complete response data packet. The 22-byte content of the notification or indication data packet is divided into two parts. The first byte is the total length of the Modbus response data packet, and the subsequent content is the first 21 bytes of the Modbus response data packet. When the Bluetooth host receives the notification or indication sent by the Bluetooth module, it checks the first byte of the notification or indication data packet content. If the value of the first byte is less than 22, then the notification or indication data packet already contains the complete Modbus response data packet, and there is no need to read the Modbus response characteristic value; if the value of the first byte is greater than or equal to 22, then the notification or indication data packet only contains the first 21 bytes of the Modbus response data packet, and the Modbus response characteristic value needs to be read to read the complete Modbus response data packet.