Plug-and-play communication method and device for sensor module and main control module

By using the method of determining the pins at the tail of the sensor module and reordering the data of the main control module, the plug-and-play problem of the sensor module is solved, and flexible connection and high-reliability communication are achieved.

CN121967545APending Publication Date: 2026-05-01ANHUI ZHIYUAN DIGITAL TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ANHUI ZHIYUAN DIGITAL TECHNOLOGY CO LTD
Filing Date
2025-12-26
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Existing IIC, SPI, and 485 bus communication methods are complex in hardware design, costly, and cannot achieve plug-and-play functionality when connecting a large number of sensor modules.

Method used

The sensor module identifies its own position by judging the pins at the tail end. Data messages are transmitted from the tail end, and the main control module reorders the data to achieve plug-and-play functionality.

Benefits of technology

It enables flexible connection and expansion of sensor modules, reduces hardware design difficulty and cost, and ensures data reliability and safety.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121967545A_ABST
    Figure CN121967545A_ABST
Patent Text Reader

Abstract

According to the plug-and-play communication method and device for the sensor modules and the main control module, the sensor modules are connected in a string mode, whether the modules are located at the tail or not is recognized through tail judgment pins, data messages are sent out from the tail sensor modules, and the data messages are sent out from the main control module. Other sensor modules add own data after receiving the data message and transmit the data message backwards to the main control module, so that a large number of sensor modules can be connected to realize plug and play; data messages are subjected to data reordering operation in the main control module, the number of the modules is increased or decreased during operation, the data sequence is not affected, plug and play of the main control module and the sensor module of the measurement equipment is finally achieved, data are verified, and the data reliability is high.
Need to check novelty before this filing date? Find Prior Art

Description

A plug-and-play communication method and device between a sensor module and a main control module. Technical Field

[0001] This invention relates to the field of communication technology, and in particular to a plug-and-play communication method and apparatus for a sensor module and a main control module. Background Technology

[0002] With the rapid development of measurement technology and the continuous improvement of automation levels in production sites, the number of objects requiring measurement is constantly increasing, necessitating the connection of numerous sensors to measurement equipment. Existing IIC, SPI, and 485 buses can enable communication between the measurement equipment's main control module and sensor modules. Referring to Figure 1, communication can be achieved by connecting the measurement equipment's main control module and sensor modules to the IIC / SPI / 485 bus. The IIC / SPI / 485 bus operates on a master-slave communication model; the measurement equipment's main control module initiates polling to obtain data from each sensor.

[0003] However, referring to Figure 2, the SPI bus has MOSI master transmit / slave receive, MISO master receive / slave transmit, CLK clock, and CS chip select signal lines. The CS (chip select) signal line needs to be configured separately for each slave (sensor module), which limits the number of sensor modules that can be connected in hardware, reducing flexibility. Furthermore, when the number of sensor modules to be connected is large, the required CS chip select signal lines are excessive, increasing the difficulty and cost of hardware design.

[0004] Referring to Figure 3, the IIC bus has a serial data line (SDA) and a serial clock line (SCL), while the 485 bus requires two differential signal lines. An address needs to be assigned to each sensor module because sensor modules on the same bus need to be distinguished by their addresses. Plug-and-play functionality cannot be achieved using either hardware or software coding.

[0005] Therefore, a new communication method needs to be designed to enable measurement equipment to flexibly connect and expand a large number of sensors. Summary of the Invention

[0006] The present invention aims to provide a plug-and-play communication method and apparatus for a sensor module and a main control module that overcomes or at least partially solves the above-mentioned problems.

[0007] To achieve the above objectives, the technical solution of the present invention is specifically implemented as follows: The first aspect of the present invention provides a plug-and-play communication method between a sensor module and a main control module, comprising: a sensor module determining whether it is at the end of a sensor string, wherein the sensor string is formed by multiple sensor modules connected end-to-end in a serial port and ultimately connected to the main control module; if it is at the end of the sensor string, it puts data in the first module data area of ​​the first message, sets the module quantity to 1, writes a checksum, and sends the first message, wherein the message is a preset format message, including: module data, module quantity, and checksum; if it is not at the end of the sensor string, it receives the message, verifies the checksum in the message, and after the verification is successful, extracts the module quantity i in the message, puts data in the (i+1)th module data area of ​​the message, sets the module quantity to i+1, updates the checksum, and sends the message, wherein i=1,2,...n,n≥1 and is a natural number, and represents the number of sensors in the sensor string.

[0008] Optionally, the method further includes: if the sensor module is not at the end of the sensor string and no message is received within a preset time, then data is placed in the data area of ​​the first module in the first message, the number of modules is set to 1, a check code is written, and the first message is sent.

[0009] Optionally, the sensor module determines whether it is at the end of the sensor string by: setting a tail determination pin on the sensor module, wherein the tail determination pin is short-circuited when the sensor module is connected to another sensor module in a direction away from the main control module; the sensor module determines whether the tail determination pin is short-circuited, and if it is not short-circuited, it determines that it is at the end of the sensor string, and if it is short-circuited, it determines that it is not at the end of the sensor string.

[0010] A second aspect of the present invention provides a plug-and-play communication method between a sensor module and a main control module, comprising: the main control module receiving a message sent by the sensor module according to the method described above; verifying the checksum in the message; if the verification passes, reordering the module data in the message so that the order of the data is consistent with the order of the actual sensors; and processing the reordered data.

[0011] Optionally, the main control module reorders the module data in the message by: saving the nth module data in the message to the first data in the formal data list; saving the (n-1)th module data to the second data in the formal data list; and so on, until the first module data is saved to the nth data in the formal data list.

[0012] A third aspect of the present invention provides a plug-and-play communication device for sensor modules and a main control module, comprising: a judgment module for determining whether it is at the end of a sensor string, wherein the sensor string is formed by multiple sensor modules connected end-to-end in a serial port and finally connected to the main control module; a first processing module for, when the judgment module determines that it is at the end of the sensor string, placing data in the first module data area of ​​the first message, setting the module quantity to 1, writing a checksum, and sending the first message, wherein the message is a preset format message, including: module data, module quantity, and checksum; and a second processing module for, when the judgment module determines that it is not at the end of the sensor string, receiving the message, verifying the checksum in the message, and after successful verification, extracting the module quantity i in the message, placing data in the (i+1)th module data area of ​​the message, setting the module quantity to i+1, updating the checksum, and sending the message, wherein i = 1, 2, ..., n, n ≥ 1 and is a natural number, and represents the number of sensors in the sensor string.

[0013] Optionally, the second processing module is further configured to, when the judgment module determines that it is not at the end of the sensor string and no message is received within a preset time, put data in the first module data area of ​​the first message, set the module number to 1, write the verification code, and send the first message.

[0014] Optionally, the judgment module determines whether it is at the end of the sensor string by: determining whether the end judgment pin is shorted; if it is not shorted, it determines that it is at the end of the sensor string; if it is shorted, it determines that it is not at the end of the sensor string. The end judgment pin is located on the sensor module and is shorted when the sensor module is connected to another sensor module in a direction away from the main control module.

[0015] A fourth aspect of the present invention provides a plug-and-play communication device for a sensor module and a main control module, comprising: a receiving module for receiving a message sent by the sensor module according to the method described above; a reordering module for verifying the checksum in the message, and if the verification passes, reordering the module data in the message so that the order of the data is consistent with the order of the actual sensors; and a processing module for processing the reordered data.

[0016] Optionally, the reordering module reorders the module data in the message in the following manner: saving the nth module data in the message to the first data in the formal data list; saving the (n-1)th module data to the second data in the formal data list; until the first module data is saved to the nth data in the formal data list.

[0017] Therefore, the plug-and-play communication method and device for sensor modules and main control modules provided by this invention allows sensor modules to be connected in series. The tail pin is used to identify whether a module is at the tail end. Data packets are sent from the tail sensor modules. Other sensor modules receive the data packets, add their own data, and then pass them on to the main control module. A large number of sensor modules can be connected to achieve plug-and-play functionality. The data packets undergo data reordering in the main control module. Adding or removing modules during operation does not affect the data order. Ultimately, the main control module and sensor modules of the measuring equipment can be plugged and played, and the data is verified, ensuring high data reliability. Attached Figure Description

[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 is a schematic diagram of the communication method between the main control module and the sensor module in the prior art; Figure 2 is a schematic diagram of the communication method between the main control module and the sensor module in the prior art via SPI bus; Figure 3 is a schematic diagram of the communication method between the main control module and the sensor module via IIC bus or 485 bus in the prior art; Figure 4 is a flowchart of a plug-and-play communication method between the sensor module and the main control module provided in an embodiment of the present invention; Figure 5 is a hardware connection diagram of the sensor module and the main control module provided in an embodiment of the present invention; Figure 6 is a schematic diagram of the tail judgment pin of the sensor module provided in an embodiment of the present invention; Figure 7 is a schematic diagram of the message format provided in an embodiment of the present invention; Figure 8 is a schematic diagram of the correspondence between the sensor module and the module data provided in an embodiment of the present invention; Figure 9 is a schematic diagram of the message processing flow of the sensor module provided in an embodiment of the present invention; Figure 10 is another sensor provided in an embodiment of the present invention. Figure 11 is a flowchart of a plug-and-play communication method between a sensor module and a main control module, provided in an embodiment of the present invention. Figure 12 is a flowchart of a plug-and-play communication method between a sensor module and a main control module, provided in an embodiment of the present invention. Figure 13 is a flowchart of a data reordering process performed by the main control module, provided in an embodiment of the present invention. Figure 14 is a flowchart of the data reordering process performed by the main control module, provided in an embodiment of the present invention. Figure 15 is a flowchart of a message processing process performed by the main control module, provided in an embodiment of the present invention. Figure 16 is a structural diagram of a plug-and-play communication device between a sensor module and a main control module, provided in an embodiment of the present invention. Figure 17 is a structural diagram of another plug-and-play communication device between a sensor module and a main control module, provided in an embodiment of the present invention. Detailed Implementation

[0020] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.

[0021] Figure 4 shows a flowchart of a plug-and-play communication method between a sensor module and a main control module provided by an embodiment of the present invention. This communication method is applied to a sensor module. Referring to Figure 4, the plug-and-play communication method between a sensor module and a main control module provided by an embodiment of the present invention includes: S401, the sensor module determines whether it is at the end of a sensor string. The sensor string is formed by connecting multiple sensor modules end to end in a string through a serial port and finally connecting them to the main control module.

[0022] Specifically, this invention first designs the hardware connection between the sensor modules and the main control module: Referring to Figure 5, in this invention, the sensor modules are connected end-to-end in a serial port, ultimately connecting to the main control module. Data is sent from the sensor module furthest from the main control module at the end, and sequentially transmitted through the other sensor modules to the main control module.

[0023] As an optional embodiment of the present invention, the sensor module determining whether it is at the end of the sensor string includes: setting a tail determination pin in the sensor module, wherein the tail determination pin is short-circuited when the sensor module is connected to another sensor module in a direction away from the main control module; the sensor module determines whether the tail determination pin is short-circuited, and if it is not short-circuited, it determines that it is at the end of the sensor string, and if it is short-circuited, it determines that it is not at the end of the sensor string.

[0024] Specifically, referring to Figure 6, each sensor module is equipped with a tail judgment pin. When the next module is connected (i.e., a sensor module far from the main control module), the tail judgment pin is shorted. When the tail judgment pin is shorted, the sensor module is in transmission mode. After receiving the data message from the previous module, it adds its own data to the message and finally sends the data out. If the tail judgment pin is not shorted, it indicates that the module is at the tail end, and the sensor module is in active transmission mode, sending messages at certain time intervals.

[0025] S402, If it is at the end of the sensor string, data is placed in the first module data area of ​​the first message, the module quantity is set to 1, a checksum is written, and the first message is sent. The message is a preset format message, including: module data, module quantity, and checksum. S403, If it is not at the end of the sensor string, the message is received, the checksum in the message is verified, and after the verification is passed, the module quantity i in the message is extracted, data is placed in the (i+1)th module data area of ​​the message, the module quantity is set to i+1, the checksum is updated, and the message is sent. Here, i=1,2,...n,n≥1 and is a natural number, which is the number of sensors in the sensor string.

[0026] Specifically, the messages sent by the sensor module of this invention are of fixed length and include module data, the number of modules, and a checksum. The checksum can be a CRC (Cyclic Redundancy Check) checksum, which is not specifically limited in this invention. The message structure can be as shown in Figure 7. Data is placed in reverse order in the data message, from the tail sensor module to the head sensor module, with module data sequentially placed into module 1 data, module 2 data, ..., module n data, as shown in Figure 8. The maximum number of modules in the message and the corresponding module data space are determined during programming, based on hardware resource limitations and actual application requirements.

[0027] As an optional implementation of this invention, the plug-and-play communication method between the sensor module and the main control module provided in this embodiment further includes: if the sensor module is not at the end of the sensor string and has not received a message within a preset time, then data is placed in the data area of ​​the first module in the first message, the module quantity is set to 1, a checksum is written, and the first message is sent. This measure is used so that when a sensor fails, the subsequent modules can act as the tail module to actively send messages, and the subsequent modules can still work.

[0028] Specifically, the non-tail sensor modules in this invention can also operate in active transmission mode. When a sensor module malfunctions and cannot send a message, the sensor modules connected after it and operating in transmission mode will not receive the message and will not send messages forward. If this situation cannot be handled, the main control module will not receive any messages, and the device will become completely ineffective. To address this situation, when a non-tail module does not receive a valid message for an extended period, it will also enter active transmission mode, allowing subsequent modules to operate normally and ensuring that some sensor module data can be sent to the main control module, thus improving the reliability of the device.

[0029] The following provides an example of a specific message processing flow for a sensor module. Referring to Figure 9, the message processing flow of the sensor module provided in this embodiment of the invention includes: Since the tail-end sensor module is in active transmission mode because its tail-end judgment pin is not short-circuited, it will actively send a message. The data area of ​​module 1 in the message is written with the data of this module, and the module count is written as 1.

[0030] Under normal circumstances, modules other than the tail module are in transmission mode because the tail detection pin is shorted. After receiving a message from the previous module, the module adds its own data to the message and then sends it out. The specific process is as follows: 1. Calculate the CRC (Cyclic Redundancy Check) checksum of the message and compare it with the CRC checksum in the message. If they are the same, the check passes. If they fail, the message is discarded, and preparation is made to receive the next message.

[0031] 2. After verification, read the number of modules n and add the data of this module to the "module n+1 data" position in the message.

[0032] 3. Increment the number of modules n by one.

[0033] 4. Update the CRC (Cyclic Redundancy Check) check code.

[0034] 5. Send message.

[0035] After the above process, the sensor module can write data sequentially to the corresponding positions in the message. When the main control module parses the message, it can obtain the module data and the location of the corresponding module, which facilitates subsequent data processing.

[0036] Therefore, the plug-and-play communication method between the sensor module and the main control module provided in this embodiment of the invention allows the sensor module to determine whether it is at the end of the sensor string by having a tail-end judgment pin. Sensor modules not at the tail end obtain their position relative to the tail-end sensors from the number of modules in the data packet and store their data in the corresponding position. Ultimately, the data packet contains data, data-module correspondence information, and the number of sensors. No separate configuration of the sensor modules is required; plug-and-play functionality can be achieved using the same hardware and software.

[0037] Furthermore, the plug-and-play communication method between the sensor module and the main control module provided in this embodiment of the invention ultimately achieves plug-and-play functionality for the sensor module and maintains high reliability, preventing all data from becoming invalid due to the failure of a single sensor module. Additionally, the checksum in the data message further ensures the reliability of the transmitted data.

[0038] Figure 10 shows a flowchart of another plug-and-play communication method between a sensor module and a main control module provided by an embodiment of the present invention. This communication method is applied to the main control module. Referring to Figure 10, the plug-and-play communication method between a sensor module and a main control module provided by an embodiment of the present invention includes: S1001, the main control module receives a message sent by the sensor module according to the above method; S1002, the checksum in the message is verified. If the verification passes, the module data in the message is reordered so that the order of the data is consistent with the order of the actual sensors; S1003, the reordered data is processed.

[0039] Specifically, the main control module of this invention performs data reordering as a necessary measure to avoid data confusion when adding or removing sensor modules. The module data in the data message is arranged in reverse order, with module data 1 representing the data of the last sensor module and module data n representing the data of the first sensor module closest to the main control module (n being the number of modules). When a sensor module is added or removed, the correspondence between the module data in the message and the actual modules will change. Figure 11 shows an addition of one sensor module compared to Figure 8, with module 1 data corresponding to the newly added sensor module. The original three sensor module data have shifted one position to the right, corresponding to the data of modules 2, 3, and 4. Figure 12 shows a reduction of one sensor module compared to Figure 8, with the remaining sensor module data shifted one position to the left. This change in the correspondence between data and sensor modules is detrimental to subsequent processing, so data reordering is necessary.

[0040] As an optional implementation of this invention, the main control module reorders the module data in the message by: saving the nth module data in the message to the first data in the formal data list; saving the (n-1)th module data to the second data in the formal data list; until the first module data is saved to the nth data in the formal data list.

[0041] Specifically, the number 'n' in the data message represents not only the number of connected sensor modules, but also that the nth module is the last module to receive the message, i.e., the header module closest to the main control module. Regardless of whether sensor modules are added or removed, the data for module 'n' is always the data for the header module.

[0042] Data reordering extracts module data from the data packet, rearranges it in reverse order, and saves it to the official data list. The official data list is arranged with the first module data as the first data and the last module data as the last data. The operation steps are: put module n data from the data packet into data 1 of the official data list, module n-1 data into official data 2, module n-2 data into official data 3, ..., module 2 data into official data n-1, and module 1 data into official data n. The program processing flow is shown in Figure 13, and the processing effect is shown in Figure 14.

[0043] After data reordering, the data in the official data list is consistent with the actual sensor module order. Adding or removing sensor modules does not affect the correspondence between the data and the sensor modules.

[0044] The following provides an example of a specific message processing flow for the main control module. Referring to Figure 15, the message processing flow of the main control module provided in this embodiment of the invention includes: 1. First, calculate the CRC (Cyclic Redundancy Check) check code and compare it with the check code in the message. If they are the same, the check passes and subsequent processing continues. If they are different, the message is discarded.

[0045] 2. Data reordering.

[0046] 3. Subsequent data processing.

[0047] Therefore, the plug-and-play communication method between the sensor modules and the main control module provided in this invention allows the sensor modules to be connected in series. A tail-end detection pin identifies whether a module is at the tail end. Data packets are sent from the tail-end sensor modules. Other sensor modules receive the data packets, add their own data, and then pass them on until they reach the main control module. The data packets undergo data reordering in the main control module, ultimately achieving plug-and-play functionality. In this invention, non-tail-end sensor modules can switch to active transmission mode if they haven't received a valid packet for a long time, improving the robustness of the entire device. Checksums in the data packets ensure the reliability of transmitted data. Through this invention, plug-and-play functionality between the main control module and sensor modules of the measuring equipment can be achieved, while data verification ensures high data reliability.

[0048] Figure 16 shows a schematic diagram of the structure of the plug-and-play communication device between the sensor module and the main control module provided in an embodiment of the present invention. This plug-and-play communication device between the sensor module and the main control module uses a sensor module. The following is only a brief description of the structure of the plug-and-play communication device between the sensor module and the main control module. For other matters not covered, please refer to the relevant description in the above-mentioned plug-and-play communication method between the sensor module and the main control module. Referring to Figure 15, the plug-and-play communication device between the sensor module and the main control module provided in this embodiment of the present invention includes: a judgment module, used to determine whether it is at the end of a sensor string, wherein the sensor string is formed by multiple sensor modules connected end to end in a serial port and finally connected to the main control module; a first processing module, used to... When the judgment module determines that the sensor is at the end of the sensor string, it places data in the first module data area of ​​the first message, sets the module quantity to 1, writes a checksum, and sends the first message. The message is a preset format message, including: module data, module quantity, and checksum. The second processing module is used to receive the message when the judgment module determines that the sensor is not at the end of the sensor string, verify the checksum in the message, extract the module quantity i from the message after verification, place data in the (i+1)th module data area of ​​the message, set the module quantity to i+1, update the checksum, and send the message. Here, i = 1, 2, ..., n, n ≥ 1 and is a natural number, which is the number of sensors in the sensor string.

[0049] As an optional embodiment of the present invention, the second processing module is further configured to, when the judgment module determines that the sensor is not at the end of the sensor string and no message has been received within a preset time, insert data into the data area of ​​the first module in the first message, set the module quantity to 1, write a checksum, and send the first message. This measure enables subsequent modules to act as the tail module and actively send messages when a sensor fails, allowing the subsequent modules to still function.

[0050] As an optional implementation of this invention, the judgment module determines whether it is at the end of the sensor string by: determining whether the end judgment pin is short-circuited; if it is not short-circuited, it determines that it is at the end of the sensor string; if it is short-circuited, it determines that it is not at the end of the sensor string. The end judgment pin is disposed on the sensor module, and the end judgment pin is short-circuited when the sensor module is connected to another sensor module in a direction away from the main control module.

[0051] Therefore, the plug-and-play communication device between the sensor module and the main control module provided in this embodiment of the invention allows the sensor module to determine whether it is at the end of the sensor string by having a tail-end judgment pin. Sensor modules not at the tail end obtain their position relative to the tail-end sensors from the number of modules in the data packet and store their data in the corresponding position. Ultimately, the data packet contains data, data-module correspondence information, and the number of sensors. No separate configuration of the sensor modules is required; plug-and-play functionality can be achieved using the same hardware and software.

[0052] Furthermore, the plug-and-play communication device between the sensor module and the main control module provided in this embodiment of the invention ultimately achieves plug-and-play functionality for the sensor module and possesses high reliability, preventing all data from becoming invalid due to the failure of a single sensor module. Additionally, the checksum in the data message further ensures the reliability of the transmitted data.

[0053] Figure 17 shows a schematic diagram of the structure of the plug-and-play communication device between the sensor module and the main control module provided in an embodiment of the present invention. This plug-and-play communication device between the sensor module and the main control module uses the main control module. The following is only a brief description of the structure of the plug-and-play communication device between the sensor module and the main control module. For other matters not covered, please refer to the relevant description in the above-mentioned plug-and-play communication method between the sensor module and the main control module. Referring to Figure 16, the plug-and-play communication device between the sensor module and the main control module provided in this embodiment of the present invention includes: a receiving module, used to receive messages sent by the sensor module according to the above method; a reordering module, used to verify the check code in the message, and if the verification passes, reorder the module data in the message so that the order of the data is consistent with the order of the actual sensors; and a processing module, used to process the reordered data.

[0054] As an optional implementation of this invention, the reordering module reorders the module data in the message in the following manner: saving the nth module data in the message to the first data in the formal data list; saving the (n-1)th module data to the second data in the formal data list; until the first module data is saved to the nth data in the formal data list.

[0055] Therefore, the plug-and-play communication device for sensor modules and main control module provided in this invention allows sensor modules to be connected in series. A tail-end detection pin identifies whether a module is at the tail end. Data packets are sent from the tail-end sensor modules. Other sensor modules receive the data packets, add their own data, and then pass them on until they reach the main control module. The data packets undergo data reordering in the main control module, ultimately achieving plug-and-play functionality. In this invention, non-tail-end sensor modules can switch to active transmission mode if they haven't received a valid packet for a long time, improving the robustness of the entire device. Checksums in the data packets ensure the reliability of transmitted data. Ultimately, this invention enables plug-and-play functionality between the main control module and sensor modules of the measuring equipment, while ensuring data verification and high data reliability.

[0056] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A plug-and-play communication method between a sensor module and a main control module, characterized in that, include: The sensor module determines whether it is at the end of the sensor string, which is formed by connecting multiple sensor modules end-to-end via a serial port and finally connecting to the main control module. If it is at the end of the sensor string, it puts data into the first module data area of ​​the first message, sets the module count to 1, writes a checksum, and sends the first message. The message is a preset format message, including: module data, module count, and checksum. If it is not at the end of the sensor string, it receives the message, verifies the checksum in the message, and after successful verification, extracts the module count i from the message, puts data into the (i+1)th module data area of ​​the message, sets the module count to i+1, updates the checksum, and sends the message. Here, i = 1, 2, ..., n, n ≥ 1 and is a natural number, representing the number of sensors in the sensor string.

2. The method according to claim 1, characterized in that, Also includes: If the sensor module is not at the end of the sensor string and no message is received within a preset time, then data is placed in the data area of ​​the first module in the first message, the number of modules is set to 1, a checksum is written, and the first message is sent.

3. The method according to claim 2, characterized in that, The sensor module determines whether it is at the end of the sensor string by: setting a tail determination pin on the sensor module, wherein the tail determination pin is short-circuited when the sensor module is connected to another sensor module in a direction away from the main control module; the sensor module determines whether the tail determination pin is short-circuited, and if it is not short-circuited, it determines that it is at the end of the sensor string, and if it is short-circuited, it determines that it is not at the end of the sensor string.

4. A plug-and-play communication method between a sensor module and a main control module, characterized in that, include: The main control module receives messages sent by the sensor module according to the method described in any one of claims 1 to 3; The checksum in the message is verified. If the verification passes, the module data in the message is reordered so that the order of the data is consistent with the order of the actual sensors. The reordered data is then processed.

5. The method according to claim 4, characterized in that, The main control module reorders the module data in the message by: saving the nth module data in the message to the first data in the formal data list; saving the (n-1)th module data to the second data in the formal data list; and so on, until the first module data is saved to the nth data in the formal data list.

6. A plug-and-play communication device for a sensor module and a main control module, characterized in that, include: A judgment module is used to determine whether it is at the end of a sensor string, which is formed by multiple sensor modules connected end-to-end via a serial port and finally connected to the main control module. A first processing module is used to, when the judgment module determines that it is at the end of the sensor string, put data in the first module data area of ​​the first message, set the module count to 1, write a checksum, and send the first message, wherein the message is a preset format message, including: module data, module count, and checksum. A second processing module is used to, when the judgment module determines that it is not at the end of the sensor string, receive the message, verify the checksum in the message, and after successful verification, extract the module count i in the message, put data in the (i+1)th module data area of ​​the message, set the module count to i+1, update the checksum, and send the message, wherein i = 1, 2, ..., n, n ≥ 1 and is a natural number, representing the number of sensors in the sensor string.

7. The apparatus according to claim 6, characterized in that, The second processing module is further configured to, when the judgment module determines that the sensor is not at the end of the sensor string and no message is received within a preset time, put data in the data area of ​​the first module in the first message, set the number of modules to 1, write the verification code, and send the first message.

8. The apparatus according to claim 7, characterized in that, The judgment module determines whether it is at the end of the sensor string by: determining whether the end judgment pin is shorted; if it is not shorted, it determines that it is at the end of the sensor string; if it is shorted, it determines that it is not at the end of the sensor string. The end judgment pin is set on the sensor module, and the end judgment pin is shorted when the sensor module is connected to another sensor module in a direction away from the main control module.

9. A plug-and-play communication device for a sensor module and a main control module, characterized in that, include: A receiving module is configured to receive messages sent by the sensor module according to the method described in any one of claims 1 to 3; The reordering module is used to verify the checksum in the message. If the verification passes, the module data in the message is reordered so that the order of the data is consistent with the order of the actual sensors. The processing module is used to process the reordered data.

10. The apparatus according to claim 9, characterized in that, The reordering module reorders the module data in the message in the following way: it saves the nth module data in the message to the first data in the formal data list; it saves the (n-1)th module data to the second data in the formal data list; and so on, until the first module data is saved to the nth data in the formal data list.