Agricultural sensor data acquisition method and system based on OPC UA

The communication protocols of agricultural sensors are unified managed through OPC UA technology, which solves the problem of low sensor data transmission efficiency and achieves efficient and safe data collection and transmission.

CN116801128BActive Publication Date: 2024-09-27HUIZHIAN INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211681581.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-23
Publication Date
2024-09-27
Estimated Expiration
2042-12-23

AI Technical Summary

Technical Problem

In the existing technology, the protocols of agricultural sensors are not unified, resulting in low data transmission efficiency and difficulty in achieving unified management.

Method used

Adopt an agricultural sensor data collection method based on OPC UA, obtain sensor data by scanning the agricultural monitoring management platform, determine the sensor type and communication protocol, establish a communication port with the OPC UA server, and use data verification formulas to ensure the accuracy and reliability of data transmission .

Benefits of technology

The efficiency of sensor data collection and transmission is improved, and the effective management of sensor communication protocols and the security of data transmission are achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116801128B
    Figure CN116801128B
Patent Text Reader

Abstract

The present invention proposes an agricultural sensor data collection method and system based on OPC UA. The agricultural sensor data collection method includes: obtaining agricultural data collected by agricultural sensors acquired through scanning an agricultural monitoring and management platform, obtaining the sensor type used to collect agricultural data and the number of sensors corresponding to each type of sensor; determining the communication protocol corresponding to each sensor according to the agricultural sensor type, and obtaining the communication protocol type in the agricultural sensor data transmission process; sending the communication protocol type corresponding to the agricultural sensor to an OPC UA server, and establishing a communication port corresponding to the communication protocol type through the OPC UA server. The system includes modules corresponding to the steps of the method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention proposes an agricultural sensor data acquisition method and system based on OPC UA, belonging to the technical field of data acquisition. Background Art

[0002] With the need for agricultural informatization, various sensors are needed in the planting process, such as temperature and humidity sensors, carbon dioxide sensors, light sensors, etc. There are many types of sensors involved. The protocols of various sensors required in the farm are different. It will waste a lot of time to achieve unified management of sensors. Summary of the invention

[0003] The present invention provides an agricultural sensor data collection method and system based on OPC UA to solve the problem of low data transmission efficiency caused by the inability to uniformly manage the protocol in the prior art:

[0004] An agricultural sensor data collection method based on OPC UA, the agricultural sensor data collection method comprising:

[0005] By scanning the agricultural data collected by agricultural sensors obtained by the agricultural monitoring and management platform, the types of sensors used to collect agricultural data and the number of sensors corresponding to each type of sensor are obtained;

[0006] Determine the communication protocol corresponding to each sensor according to the type of the agricultural sensor, and obtain the type of communication protocol during the data transmission of the agricultural sensor;

[0007] The communication protocol type corresponding to the agricultural sensor is sent to the OPC UA server, and a communication port corresponding to the communication protocol type is established through the OPC UA server.

[0008] Furthermore, by scanning the agricultural data collected by the agricultural sensors obtained by the agricultural monitoring and management platform, the sensor types used to collect the agricultural data and the number of sensors corresponding to each type of sensor are obtained, including:

[0009] Agricultural data collected by agricultural sensors obtained through scanning agricultural monitoring and management platforms;

[0010] Acquire an agricultural data type corresponding to the agricultural data according to the agricultural data, wherein the agricultural data type includes temperature data, humidity data, light data and soil pH value data;

[0011] Extracting the agricultural sensor corresponding to the agricultural data according to the agricultural data type;

[0012] Classifying the agricultural sensors according to the agricultural data type to obtain an agricultural sensor set based on the agricultural data type;

[0013] The number of agricultural sensors included in each of the agricultural sensor sets is extracted.

[0014] Further, determining the communication protocol corresponding to each sensor according to the type of the agricultural sensor, and obtaining the type of the communication protocol in the data transmission process of the agricultural sensor, including:

[0015] Extracting the number of types of agricultural sensors and the number of types of communication protocols;

[0016] When the number of types of the communication protocols is not less than the number of types of the agricultural sensors, the communication protocol type corresponding to each type of agricultural sensor is obtained according to the rule that different types of agricultural sensors correspond to different types of communication protocols;

[0017] When the number of types of the communication protocols is lower than the number of types of the agricultural sensors, the type of communication protocol corresponding to each type of agricultural sensor is obtained according to the types of the agricultural sensors and the number of agricultural sensors corresponding to each type.

[0018] Further, when the number of types of the communication protocols is less than the number of types of the agricultural sensors, the type of communication protocol corresponding to each type of agricultural sensor is obtained according to the type of the agricultural sensor and the number of agricultural sensors corresponding to each type, including:

[0019] Corresponding a communication protocol to the agricultural sensor type whose number of agricultural sensors is less than a first preset number threshold;

[0020] Allocate the corresponding agricultural sensor types whose number of agricultural sensors is not less than a first preset number threshold but less than a second preset number threshold to two different communication protocols in units of complete types;

[0021] The corresponding agricultural sensor types whose number of agricultural sensors is not less than the second preset number threshold are completely allocated to the remaining unactivated multiple communication protocols in units of complete types.

[0022] Further, the communication protocol type corresponding to the agricultural sensor is sent to the OPC UA server. After the communication port corresponding to the communication protocol type is established by the OPC UA server, the OPC UA server first uses the established communication port to collect multiple data from each sensor, and detects whether the currently established communication port is accurate and reliable based on the multiple data collected from each sensor. The specific steps include:

[0023] Step A1: The OPC UA server uses formula (1) to perform a data check based on the length of the multiple data collected from each sensor, the header and the tail of the data frame.

[0024]

[0025] Where Y1(a_i) represents the first test value of the i-th data collected from the a-th sensor; Q 16 (a_i) represents the hexadecimal form of the frame header data of the i-th data extracted from the a-th sensor; 16 (a_i) represents the hexadecimal form of the frame tail data of the i-th data extracted from the a-th sensor; q 16 (a) represents the hexadecimal format of the standard data frame header of the ath sensor; p 16 (a) represents the hexadecimal format of the standard data frame tail of the a-th sensor; | | represents the absolute value; [C(a_i)] 16 Indicates the hexadecimal form of the i-th data collected from the a-th sensor; len{[C(a_i)] 16} represents the data length of the i-th data collected from the a-th sensor in hexadecimal format; >> represents right shift; << represents left shift;

[0026] If Y1(a_i)=0, it means that the i-th data collected from the a-th sensor has been successfully verified once;

[0027] If Y1(a_i)≠0, it means that the i-th data collected from the a-th sensor failed the first test;

[0028] Step A2: Use formula (2) to perform a second check on the data based on the data checksum of multiple data collected from each sensor.

[0029]

[0030] Where Y2(a_i) represents the secondary inspection value of the i-th data collected from the a-th sensor; J 16 (a_i) represents the hexadecimal form of the data checksum of the i-th data extracted from the a-th sensor; [C(a_i)] 16 (k) represents data [C(a_i)] 16 The value at the kth position in ;

[0031] If Y2(a_i)=0, it means that the i-th data collected from the a-th sensor has been successfully verified;

[0032] If Y2(a_i)≠0, it means that the i-th data collected from the a-th sensor has failed the secondary inspection;

[0033] Step A3: Using formula (3), control whether the communication port corresponding to the communication protocol type needs to be re-established according to the verification status of the primary and secondary verification of multiple data of each sensor.

[0034]

[0035] Where E[X(r)] represents the control value for re-establishing the communication port corresponding to the r-th communication protocol type; X(r) represents the set of sensor numbers corresponding to the r-th communication protocol type; a∈X(r) represents finding all a values ​​belonging to X(r); n(a) represents the total number of data collected from the a-th sensor; G[] represents a normalization function, if the value in the brackets is not equal to 0, the function value is 1, if the value in the brackets is equal to 0, the function value is 0;

[0036] If E[X(r)]=1, it means that the check fails, and the communication port corresponding to the r-th communication protocol type is controlled to be re-established;

[0037] If e[X(r)]=0, it means that the check is passed and there is no need to re-establish the communication port corresponding to the r-th communication protocol type.

[0038] An agricultural sensor data acquisition system based on OPC UA, the agricultural sensor data acquisition system comprising:

[0039] A scanning module is used to obtain the agricultural data collected by agricultural sensors acquired through the agricultural monitoring and management platform by scanning, and obtain the sensor types used to collect agricultural data and the number of sensors corresponding to each type of sensor;

[0040] A protocol determination module, used to determine the communication protocol corresponding to each sensor according to the type of the agricultural sensor, and obtain the communication protocol type in the data transmission process of the agricultural sensor;

[0041] An establishing module is used to send the communication protocol type corresponding to the agricultural sensor to the OPC UA server, and establish a communication port corresponding to the communication protocol type through the OPC UA server.

[0042] Furthermore, the scanning module includes:

[0043] The agricultural data collection module is used to scan the agricultural data collected by agricultural sensors obtained by the agricultural monitoring and management platform;

[0044] A data type acquisition module, used for acquiring an agricultural data type corresponding to the agricultural data according to the agricultural data, wherein the agricultural data type includes temperature data, humidity data, light data and soil pH value data;

[0045] A sensor extraction module, used for extracting agricultural sensors corresponding to the agricultural data according to the agricultural data type;

[0046] A classification module, used to classify the agricultural sensors according to the agricultural data type, and obtain a set of agricultural sensors in units of the agricultural data type;

[0047] The sensor quantity extraction module is used to extract the quantity of agricultural sensors contained in each of the agricultural sensor sets.

[0048] Furthermore, the protocol determination module includes:

[0049] A type quantity extraction module, used to extract the type quantity of the agricultural sensor type and the type quantity of the communication protocol;

[0050] A first protocol type acquisition module is used to acquire the communication protocol type corresponding to each type of agricultural sensor according to the rule that different types of agricultural sensors correspond to different types of communication protocols when the number of types of the communication protocols is not less than the number of types of the agricultural sensors;

[0051] The second protocol type acquisition module is used to acquire the communication protocol type corresponding to each type of agricultural sensor according to the type of agricultural sensor and the corresponding number of each type of agricultural sensor when the number of types of the communication protocol is lower than the number of types of the agricultural sensor.

[0052] Furthermore, the first protocol type acquisition module includes:

[0053] A first protocol allocation module is used to assign a communication protocol to a type of agricultural sensor whose number of agricultural sensors is less than a first preset number threshold;

[0054] A second protocol allocation module is used to allocate the corresponding agricultural sensor types whose number of agricultural sensors is not less than a first preset number threshold but less than a second preset number threshold to two different communication protocols in units of complete types;

[0055] The third protocol allocation module is used to allocate the corresponding agricultural sensor types whose number of agricultural sensors is not less than the second preset number threshold to the remaining unactivated multiple communication protocols in units of complete types.

[0056] Further, the communication protocol type corresponding to the agricultural sensor is sent to the OPC UA server. After the communication port corresponding to the communication protocol type is established by the OPC UA server, the OPC UA server first uses the established communication port to collect multiple data from each sensor, and detects whether the currently established communication port is accurate and reliable based on the multiple data collected from each sensor. The specific steps include:

[0057] Step A1: The OPC UA server uses formula (1) to perform a data check based on the length of the multiple data collected from each sensor, the header and the tail of the data frame.

[0058]

[0059] Where Y1(a_i) represents the first test value of the i-th data collected from the a-th sensor; Q 16 (a_i) represents the hexadecimal form of the frame header data of the i-th data extracted from the a-th sensor; 16 (a_i) represents the hexadecimal form of the frame tail data of the i-th data extracted from the a-th sensor; q 16 (a) represents the hexadecimal format of the standard data frame header of the ath sensor; p 16 (a) represents the hexadecimal format of the standard data frame tail of the a-th sensor; | | represents the absolute value; [C(a_i)] 16 Indicates the hexadecimal form of the i-th data collected from the a-th sensor; len{[C(a_i)] 16} represents the data length of the i-th data collected from the a-th sensor in hexadecimal format; >> represents right shift; << represents left shift;

[0060] If Y1(a_i)=0, it means that the i-th data collected from the a-th sensor has been successfully verified once;

[0061] If Y1(a_i)≠0, it means that the i-th data collected from the a-th sensor failed the first test;

[0062] Step A2: Use formula (2) to perform a second check on the data based on the data checksum of multiple data collected from each sensor.

[0063]

[0064] Where Y2(a_i) represents the secondary inspection value of the i-th data collected from the a-th sensor; J 16 (a_i) represents the hexadecimal form of the data checksum of the i-th data extracted from the a-th sensor; [C(a_i)]16 (k) represents data [C(a_i)] 16 The value at the kth position in ;

[0065] If Y2(a_i)=0, it means that the i-th data collected from the a-th sensor has been successfully verified;

[0066] If Y2(a_i)≠0, it means that the i-th data collected from the a-th sensor has failed the secondary inspection;

[0067] Step A3: Using formula (3), control whether the communication port corresponding to the communication protocol type needs to be re-established according to the verification status of the primary and secondary verification of multiple data of each sensor.

[0068]

[0069] Where E[X(r)] represents the control value for re-establishing the communication port corresponding to the r-th communication protocol type; X(r) represents the set of sensor numbers corresponding to the r-th communication protocol type; a∈X(r) represents finding all a values ​​belonging to X(r); n(a) represents the total number of data collected from the a-th sensor; G[ ] represents a normalization function, if the value in the brackets is not equal to 0, the function value is 1, if the value in the brackets is equal to 0, the function value is 0;

[0070] If E[X(r)]=1, it means that the check fails, and the communication port corresponding to the r-th communication protocol type is controlled to be re-established;

[0071] If E[X(r)]=0, it means that the check is passed and there is no need to re-establish the communication port corresponding to the r-th communication protocol type.

[0072] Beneficial effects of the present invention:

[0073] The agricultural sensor data acquisition method and system based on OPC UA proposed in this invention takes OPC UA as the core technology, and utilizes its advantages such as strong data transmission security, integrated address space and cross-platform, to design and implement the sensor data acquisition system. At the same time, the OPC UA architecture is used to realize the communication between the communication protocols of the sensors, and the collection of equipment data information effectively improves the efficiency of data collection and data transmission. BRIEF DESCRIPTION OF THE DRAWINGS

[0074] Figure 1 is a flow chart of the method of the present invention;

[0075] Figure 2 The system block diagram of the system of the present invention. DETAILED DESCRIPTION

[0076] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.

[0077] The embodiment of the present invention proposes an agricultural sensor data collection method based on OPC UA, such as Figure 1 As shown, the agricultural sensor data collection method includes:

[0078] S1. Scan the agricultural data collected by agricultural sensors obtained by the agricultural monitoring and management platform to obtain the sensor types used to collect agricultural data and the number of sensors corresponding to each type of sensor;

[0079] S2. Determine the communication protocol corresponding to each sensor according to the type of the agricultural sensor, and obtain the type of communication protocol during the data transmission of the agricultural sensor;

[0080] S3. Send the communication protocol type corresponding to the agricultural sensor to the OPC UA server, and establish a communication port corresponding to the communication protocol type through the OPC UA server.

[0081] The working principle of the above technical solution is: first, by scanning the agricultural data collected by the agricultural sensors obtained by the agricultural monitoring and management platform, the sensor type used to collect agricultural data and the number of sensors corresponding to each type of sensor are obtained; then, according to the agricultural sensor type, the communication protocol corresponding to each sensor is determined, and the communication protocol type in the agricultural sensor data transmission process is obtained; finally, the communication protocol type corresponding to the agricultural sensor is sent to the OPC UA server, and a communication port corresponding to the communication protocol type is established through the OPC UA server.

[0082] The effect of the above technical solution is as follows: the agricultural sensor data collection method based on OPC UA proposed in this embodiment takes OPC UA as the core technology, and utilizes its advantages such as strong data transmission security, integrated address space and cross-platform, to design and implement the sensor data collection system. At the same time, the OPC UA architecture is used to realize the communication between the communication protocols of the sensors, and the collection of equipment data information effectively improves the efficiency of data collection and data transmission.

[0083] In one embodiment of the present invention, agricultural data collected by agricultural sensors acquired by scanning an agricultural monitoring and management platform are obtained to obtain sensor types used to collect agricultural data and the number of sensors corresponding to each type of sensor, including:

[0084] S101, agricultural data collected by agricultural sensors obtained by scanning the agricultural monitoring and management platform;

[0085] S102, acquiring agricultural data types corresponding to the agricultural data according to the agricultural data, wherein the agricultural data types include temperature data, humidity data, light data and soil pH value data;

[0086] S103, extracting agricultural sensors corresponding to the agricultural data according to the type of agricultural data;

[0087] S104, classifying the agricultural sensors according to the agricultural data type, and obtaining an agricultural sensor set based on the agricultural data type;

[0088] S105: Extract the number of agricultural sensors included in each of the agricultural sensor sets.

[0089] The working principle of the above technical solution is: first, the agricultural data collected by the agricultural sensors obtained by scanning the agricultural monitoring and management platform; then, the agricultural data type corresponding to the agricultural data is obtained according to the agricultural data, wherein the agricultural data type includes temperature data, humidity data, light data and soil pH value data; then, the agricultural sensors corresponding to the agricultural data are extracted according to the agricultural data type; then, the agricultural sensors are classified according to the agricultural data type to obtain an agricultural sensor set in units of agricultural data type; finally, the number of agricultural sensors contained in each of the agricultural sensor sets is extracted.

[0090] The effect of the above technical solution is: through sensor classification, the management efficiency of subsequent data collection and the accuracy of data collection monitoring can be effectively improved.

[0091] In one embodiment of the present invention, determining the communication protocol corresponding to each sensor according to the type of the agricultural sensor, and obtaining the type of the communication protocol in the data transmission process of the agricultural sensor includes:

[0092] S201, extracting the number of types of agricultural sensors and the number of types of communication protocols;

[0093] S202: when the number of types of the communication protocols is not less than the number of types of the agricultural sensors, obtaining the type of communication protocol corresponding to each type of agricultural sensor according to the rule that different types of agricultural sensors correspond to different types of communication protocols;

[0094] S203. When the number of types of the communication protocols is lower than the number of types of the agricultural sensors, obtain the type of communication protocol corresponding to each type of agricultural sensor according to the types of the agricultural sensors and the number of agricultural sensors corresponding to each type.

[0095] The working principle of the above technical solution is: first, extract the number of types of agricultural sensors and the number of types of communication protocols; then, when the number of types of communication protocols is not less than the number of types of agricultural sensors, obtain the communication protocol type corresponding to each type of agricultural sensor according to the rule that different types of agricultural sensors correspond to different types of communication protocols; finally, when the number of types of communication protocols is less than the number of types of agricultural sensors, obtain the communication protocol type corresponding to each type of agricultural sensor according to the type of agricultural sensor and the number of agricultural sensors of each type.

[0096] The effect of the above technical solution is: taking OPC UA as the core technology, taking advantage of its strong data transmission security, integrated address space and cross-platform, the sensor data acquisition system is designed and implemented. At the same time, the OPC UA architecture is used to realize the communication between the communication protocols of the sensors, and the collection of device data information effectively improves the efficiency of data collection and data transmission.

[0097] In one embodiment of the present invention, when the number of types of the communication protocols is less than the number of types of the agricultural sensors, obtaining the type of communication protocol corresponding to each type of agricultural sensor according to the type of the agricultural sensor and the number of agricultural sensors corresponding to each type includes:

[0098] S2031, corresponding to a type of agricultural sensor whose number of agricultural sensors is less than a first preset number threshold, to a communication protocol;

[0099] S2032, completely allocating the agricultural sensor types whose number of agricultural sensors is not less than the first preset number threshold but less than the second preset number threshold to the two different communication protocols in units of complete types;

[0100] S2033. Allocate the corresponding agricultural sensor types whose number of agricultural sensors is not less than the second preset number threshold to the remaining unactivated multiple communication protocols in units of complete types.

[0101] The working principle of the above technical solution is: first, the corresponding agricultural sensor types whose number of agricultural sensors is less than a first preset number threshold are assigned to one communication protocol; then, the corresponding agricultural sensor types whose number of agricultural sensors is not less than the first preset number threshold but less than the second preset number threshold are completely allocated to two different communication protocols in units of complete types; finally, the corresponding agricultural sensor types whose number of agricultural sensors is not less than the second preset number threshold are completely allocated to the remaining multiple communication protocols that have not been enabled in units of complete types.

[0102] The effect of the above technical solution is: through the above method, the accuracy and efficiency of agricultural sensor communication protocol classification can be effectively improved, thereby effectively improving the rationality of communication protocol management.

[0103] In one embodiment of the present invention, the communication protocol type corresponding to the agricultural sensor is sent to the OPC UA server. After the OPC UA server establishes a communication port corresponding to the communication protocol type, the OPC UA server first uses the established communication port to collect multiple data from each sensor, and detects whether the currently established communication port is accurate and reliable based on the multiple data collected from each sensor. The specific steps include:

[0104] Step A1: The OPC UA server uses formula (1) to perform a data check based on the length of the multiple data collected from each sensor, the header and the tail of the data frame.

[0105]

[0106] Where Y1(a_i) represents the first test value of the i-th data collected from the a-th sensor; Q 16 (a_i) represents the hexadecimal form of the frame header data of the i-th data extracted from the a-th sensor; 16 (a_i) represents the hexadecimal form of the frame tail data of the i-th data extracted from the a-th sensor; q 16 (a) represents the hexadecimal format of the standard data frame header of the ath sensor; p 16 (a) represents the hexadecimal format of the standard data frame tail of the a-th sensor; | | represents the absolute value; [C(a_i)] 16 Indicates the hexadecimal form of the i-th data collected from the a-th sensor; len{[C(a_i)] 16} represents the data length of the i-th data collected from the a-th sensor in hexadecimal format; >> represents right shift; << represents left shift;

[0107] If Y1(a_i)=0, it means that the i-th data collected from the a-th sensor has been successfully verified once;

[0108] If Y1(a_i)≠0, it means that the i-th data collected from the a-th sensor failed the first test;

[0109] Step A2: Use formula (2) to perform a second check on the data based on the data checksum of multiple data collected from each sensor.

[0110]

[0111] Where Y2(a_i) represents the secondary inspection value of the i-th data collected from the a-th sensor; J 16 (a_i) represents the hexadecimal form of the data checksum of the i-th data extracted from the a-th sensor; [C(a_i)] 16 (k) represents data [C(a_i)] 16 The value at the kth position in ;

[0112] If Y2(a_i)=0, it means that the i-th data collected from the a-th sensor has been successfully verified;

[0113] If Y2(a_i)≠0, it means that the i-th data collected from the a-th sensor has failed the secondary inspection;

[0114] Step A3: Using formula (3), control whether the communication port corresponding to the communication protocol type needs to be re-established according to the verification status of the primary and secondary verification of multiple data of each sensor.

[0115]

[0116] Where E[X(r)] represents the control value for re-establishing the communication port corresponding to the r-th communication protocol type; X(r) represents the set of sensor numbers corresponding to the r-th communication protocol type; a∈X(r) represents finding all a values ​​belonging to X(r); n(a) represents the total number of data collected from the a-th sensor; G[ ] represents a normalization function, if the value in the brackets is not equal to 0, the function value is 1, if the value in the brackets is equal to 0, the function value is 0;

[0117] If E[X(r)]=1, it means that the check fails, and the communication port corresponding to the r-th communication protocol type is controlled to be re-established;

[0118] If E[X(r)]=0, it means that the check is passed and there is no need to re-establish the communication port corresponding to the r-th communication protocol type.

[0119] The beneficial effect of the above technical solution is: using the formula (1) of step A1 to perform a data check once at the data frame header and tail according to the data length of the multiple data collected from each sensor, thereby checking the data in data form to ensure the accuracy of the data form; then using the formula (2) of step A2 to perform a secondary check on the data according to the data checksum in the multiple data collected from each sensor, thereby checking according to the internal characteristics of the data to ensure the accuracy of the data content; finally, using the formula (3) of step A3 to control whether the communication port corresponding to the communication protocol type needs to be re-established according to the verification status of the primary check and secondary check of the multiple data of each sensor, thereby preventing the problem of large amounts of data disorder caused by the establishment of an erroneous communication port.

[0120] The embodiment of the present invention proposes an agricultural sensor data acquisition system based on OPC UA, such as Figure 2 As shown, the agricultural sensor data acquisition system includes:

[0121] A scanning module is used to obtain the agricultural data collected by agricultural sensors acquired through the agricultural monitoring and management platform by scanning, and obtain the sensor types used to collect agricultural data and the number of sensors corresponding to each type of sensor;

[0122] A protocol determination module, used to determine the communication protocol corresponding to each sensor according to the type of the agricultural sensor, and obtain the communication protocol type in the data transmission process of the agricultural sensor;

[0123] An establishing module is used to send the communication protocol type corresponding to the agricultural sensor to the OPC UA server, and establish a communication port corresponding to the communication protocol type through the OPC UA server.

[0124] The working principle of the above technical solution is: first, the scanning module is used to scan the agricultural data collected by the agricultural sensors obtained by the agricultural monitoring and management platform to obtain the sensor type used to collect agricultural data and the number of sensors corresponding to each type of sensor; then, the protocol determination module is used to determine the communication protocol corresponding to each sensor according to the agricultural sensor type, and the communication protocol type in the agricultural sensor data transmission process is obtained; finally, the establishment module is used to send the communication protocol type corresponding to the agricultural sensor to the OPC UA server, and a communication port corresponding to the communication protocol type is established through the OPC UA server.

[0125] The effect of the above technical solution is as follows: the agricultural sensor data acquisition system based on OPC UA proposed in this embodiment takes OPC UA as the core technology, and utilizes its advantages such as strong data transmission security, integrated address space and cross-platform, to design and implement the sensor data acquisition system. At the same time, the OPC UA architecture is used to realize the communication between the communication protocols of the sensors, and the collection of equipment data information effectively improves the efficiency of data collection and data transmission.

[0126] In one embodiment of the present invention, the scanning module comprises:

[0127] The agricultural data collection module is used to scan the agricultural data collected by agricultural sensors obtained by the agricultural monitoring and management platform;

[0128] A data type acquisition module, used for acquiring an agricultural data type corresponding to the agricultural data according to the agricultural data, wherein the agricultural data type includes temperature data, humidity data, light data and soil pH value data;

[0129] A sensor extraction module, used for extracting agricultural sensors corresponding to the agricultural data according to the agricultural data type;

[0130] A classification module, used to classify the agricultural sensors according to the agricultural data type, and obtain a set of agricultural sensors in units of the agricultural data type;

[0131] The sensor quantity extraction module is used to extract the quantity of agricultural sensors contained in each of the agricultural sensor sets.

[0132] The working principle of the above technical solution is: first, the agricultural data collected by the agricultural sensors obtained by scanning the agricultural monitoring and management platform is adopted by the agricultural data acquisition module; then, the agricultural data type corresponding to the agricultural data is obtained according to the agricultural data by using the data type acquisition module, wherein the agricultural data type includes temperature data, humidity data, light data and soil pH value data; then, the agricultural sensor corresponding to the agricultural data is extracted according to the agricultural data type by using the sensor extraction module; then, the agricultural sensor is classified according to the agricultural data type by using the classification module to obtain the agricultural sensor set in units of the agricultural data type; finally, the sensor quantity extraction module is used to extract the number of agricultural sensors contained in each of the agricultural sensor sets.

[0133] The effect of the above technical solution is: through sensor classification, the management efficiency of subsequent data collection and the accuracy of data collection monitoring can be effectively improved.

[0134] In one embodiment of the present invention, the protocol determination module includes:

[0135] A type quantity extraction module, used to extract the type quantity of the agricultural sensor type and the type quantity of the communication protocol;

[0136] A first protocol type acquisition module is used to acquire the communication protocol type corresponding to each type of agricultural sensor according to the rule that different types of agricultural sensors correspond to different types of communication protocols when the number of types of the communication protocols is not less than the number of types of the agricultural sensors;

[0137] The second protocol type acquisition module is used to acquire the communication protocol type corresponding to each type of agricultural sensor according to the type of agricultural sensor and the corresponding number of each type of agricultural sensor when the number of types of the communication protocol is lower than the number of types of the agricultural sensor.

[0138] Wherein, the first protocol type acquisition module includes:

[0139] A first protocol allocation module is used to assign a communication protocol to a type of agricultural sensor whose number of agricultural sensors is less than a first preset number threshold;

[0140] A second protocol allocation module is used to allocate the corresponding agricultural sensor types whose number of agricultural sensors is not less than a first preset number threshold but less than a second preset number threshold to two different communication protocols in units of complete types;

[0141] The third protocol allocation module is used to allocate the corresponding agricultural sensor types whose number of agricultural sensors is not less than the second preset number threshold to the remaining unactivated multiple communication protocols in units of complete types.

[0142] The working principle of the above technical solution is: first, the number of types of agricultural sensor types and the number of types of communication protocols are extracted through the type quantity extraction module; then, when the number of types of the communication protocols is not less than the number of types of agricultural sensor types, the first protocol type acquisition module is used to obtain the communication protocol type corresponding to each type of agricultural sensor according to the rule that different types of agricultural sensors correspond to different types of communication protocols; thereafter, when the number of types of the communication protocols is less than the number of types of agricultural sensor types, the second protocol type acquisition module is used to obtain the communication protocol type corresponding to each type of agricultural sensor according to the type of agricultural sensor and the corresponding number of each type of agricultural sensor.

[0143] The operation process of the first protocol type acquisition module includes:

[0144] First, the agricultural sensor types whose number is less than the first preset number threshold are assigned to one communication protocol through the first protocol allocation module; then, the agricultural sensor types whose number is not less than the first preset number threshold but less than the second preset number threshold are assigned to two different communication protocols in units of complete types through the second protocol allocation module; finally, the agricultural sensor types whose number is not less than the second preset number threshold are assigned to the remaining multiple communication protocols that have not been enabled in units of complete types through the third protocol allocation module.

[0145] The effect of the above technical solution is: taking OPC UA as the core technology, taking advantage of its strong data transmission security, integrated address space and cross-platform, the sensor data acquisition system is designed and implemented. At the same time, the OPC UA architecture is used to realize the communication between the communication protocols of the sensors, and the collection of device data information effectively improves the efficiency of data collection and data transmission.

[0146] In one embodiment of the present invention, the communication protocol type corresponding to the agricultural sensor is sent to the OPC UA server. After the OPC UA server establishes a communication port corresponding to the communication protocol type, the OPC UA server first uses the established communication port to collect multiple data from each sensor, and detects whether the currently established communication port is accurate and reliable based on the multiple data collected from each sensor. The specific steps include:

[0147] Step A1: The OPC UA server uses formula (1) to perform a data check based on the length of the multiple data collected from each sensor, the header and the tail of the data frame.

[0148]

[0149] Where Y1(a_i) represents the first test value of the i-th data collected from the a-th sensor; Q 16 (a_i) represents the hexadecimal form of the frame header data of the i-th data extracted from the a-th sensor; 16 (a_i) represents the hexadecimal form of the frame tail data of the i-th data extracted from the a-th sensor; q 16 (a) represents the hexadecimal format of the standard data frame header of the ath sensor; p 16 (a) represents the hexadecimal format of the standard data frame tail of the a-th sensor; | | represents the absolute value; [C(a_i)] 16 Indicates the hexadecimal form of the i-th data collected from the a-th sensor; len{[C(a_i)] 16} represents the data length of the i-th data collected from the a-th sensor in hexadecimal format; >> represents right shift; << represents left shift;

[0150] If Y1(a_i)=0, it means that the i-th data collected from the a-th sensor has been successfully verified once;

[0151] If Y1(a_i)≠0, it means that the i-th data collected from the a-th sensor failed the first test;

[0152] Step A2: Use formula (2) to perform a second check on the data based on the data checksum of multiple data collected from each sensor.

[0153]

[0154] Where Y2(a_i) represents the secondary inspection value of the i-th data collected from the a-th sensor; J 16 (a_i) represents the hexadecimal form of the data checksum of the i-th data extracted from the a-th sensor; [C(a_i)] 16 (k) represents data [C(a_i)] 16 The value at the kth position in ;

[0155] If Y2(a_i)=0, it means that the i-th data collected from the a-th sensor has been successfully verified;

[0156] If Y2(a_i)≠0, it means that the i-th data collected from the a-th sensor has failed the secondary inspection;

[0157] Step A3: Using formula (3), control whether the communication port corresponding to the communication protocol type needs to be re-established according to the verification status of the primary and secondary verification of multiple data of each sensor.

[0158]

[0159] Where E[X(r)] represents the control value for re-establishing the communication port corresponding to the r-th communication protocol type; X(r) represents the set of sensor numbers corresponding to the r-th communication protocol type; a∈X(r) represents finding all a values ​​belonging to X(r); n(a) represents the total number of data collected from the a-th sensor; G[] represents a normalization function, if the value in the brackets is not equal to 0, the function value is 1, if the value in the brackets is equal to 0, the function value is 0;

[0160] If E[X(r)]=1, it means that the check fails, and the communication port corresponding to the r-th communication protocol type is controlled to be re-established;

[0161] If E[X(r)]=0, it means that the check is passed and there is no need to re-establish the communication port corresponding to the r-th communication protocol type.

[0162] The beneficial effect of the above technical solution is: using the formula (1) of step A1 to perform a data check once at the data frame header and tail according to the data length of the multiple data collected from each sensor, thereby checking the data in data form to ensure the accuracy of the data form; then using the formula (2) of step A2 to perform a secondary check on the data according to the data checksum in the multiple data collected from each sensor, thereby checking according to the internal characteristics of the data to ensure the accuracy of the data content; finally, using the formula (3) of step A3 to control whether the communication port corresponding to the communication protocol type needs to be re-established according to the verification status of the primary check and secondary check of the multiple data of each sensor, thereby preventing the problem of large amounts of data disorder caused by the establishment of an erroneous communication port.

[0163] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. An agricultural sensor data acquisition method based on OPC UA, characterized in that: The agricultural sensor data collection method comprises: By scanning the agricultural data collected by agricultural sensors obtained by the agricultural monitoring and management platform, the types of sensors used to collect agricultural data and the number of sensors corresponding to each type of sensor are obtained; Determine the communication protocol corresponding to each sensor according to the type and quantity of the agricultural sensors, and obtain the communication protocol type during the data transmission of the agricultural sensors; Sending the communication protocol type corresponding to the agricultural sensor to the OPC UA server, and establishing a communication port corresponding to the communication protocol type through the OPC UA server; Wherein, determining the communication protocol corresponding to each sensor according to the type of the agricultural sensor, and obtaining the type of the communication protocol in the data transmission process of the agricultural sensor, includes: Extracting the number of types of agricultural sensors and the number of types of communication protocols; When the number of types of the communication protocols is not less than the number of types of the agricultural sensors, the communication protocol type corresponding to each type of agricultural sensor is obtained according to the rule that different types of agricultural sensors correspond to different types of communication protocols; When the number of types of the communication protocols is less than the number of types of the agricultural sensors, obtaining the type of communication protocol corresponding to each type of agricultural sensor according to the types of the agricultural sensors and the number of agricultural sensors corresponding to each type; When the number of types of the communication protocols is less than the number of types of the agricultural sensors, the type of communication protocol corresponding to each type of agricultural sensor is obtained according to the types of the agricultural sensors and the number of agricultural sensors corresponding to each type, including: Corresponding a communication protocol to the agricultural sensor type whose number of agricultural sensors is less than a first preset number threshold; Allocate the corresponding agricultural sensor types whose number of agricultural sensors is not less than a first preset number threshold but less than a second preset number threshold to two different communication protocols in units of complete types; The corresponding agricultural sensor types whose number of agricultural sensors is not less than the second preset number threshold are completely allocated to the remaining unactivated multiple communication protocols in units of complete types.

2. The agricultural sensor data collection method according to claim 1, characterized in that: By scanning the agricultural data collected by agricultural sensors obtained by the agricultural monitoring and management platform, the types of sensors used to collect agricultural data and the number of sensors corresponding to each type of sensor are obtained, including: Agricultural data collected by agricultural sensors obtained through scanning agricultural monitoring and management platforms; Acquire an agricultural data type corresponding to the agricultural data according to the agricultural data, wherein the agricultural data type includes temperature data, humidity data, light data and soil pH value data; Extracting the agricultural sensor corresponding to the agricultural data according to the agricultural data type; Classifying the agricultural sensors according to the agricultural data type to obtain an agricultural sensor set based on the agricultural data type; The number of agricultural sensors included in each of the agricultural sensor sets is extracted.

3. The agricultural sensor data collection method according to claim 1, characterized in that: The communication protocol type corresponding to the agricultural sensor is sent to the OPC UA server. After the communication port corresponding to the communication protocol type is established by the OPC UA server, the OPC UA server first uses the established communication port to collect multiple data from each sensor, and detects whether the currently established communication port is accurate and reliable based on the multiple data collected from each sensor. The specific steps include: Step A1: The OPC UA server uses formula (1) to perform a data check on the data frame header and tail according to the data length of multiple data collected from each sensor; (1) in Indicates the collected The sensor A test value of the data; Indicates the extracted The sensor The hexadecimal format of the frame header data of the secondary data; Indicates the extracted The sensor The hexadecimal format of the frame tail data of the secondary data; Indicates The hexadecimal format of the standard data frame header of each sensor; Indicates The hexadecimal format of the standard data frame tail of each sensor; It means to find the absolute value; Indicates the collected The sensor The hexadecimal format of the secondary data; Indicates the collected The sensor The data length of the secondary data in hexadecimal format; Indicates right shift; Indicates left shift; like , it means the collected The sensor The data was successfully verified once; like , it means the collected The sensor The data failed to be verified once; Step A2: perform a second check on the data according to the data checksum in the multiple data collected from each sensor using formula (2); (2) in Indicates the collected The sensor Secondary test value of the data; Indicates the extracted The sensor The hexadecimal format of the data checksum of the secondary data; Representation data Middle The value of the bit; like , it means the collected The sensor The secondary inspection of the data was successful; like , it means the collected The sensor The secondary data inspection failed; Step A3: using formula (3) to control whether the communication port corresponding to the communication protocol type needs to be re-established according to the verification conditions of the primary verification and the secondary verification of multiple data of each sensor; (3) in Indicates The control value for re-establishing the communication port corresponding to each communication protocol type; Indicates the A set of sensor numbers corresponding to each communication protocol type; Indicates that belong All All values ​​found; Indicates that the collection The total number of sensor data; Represents a normalized function. If the value in the brackets is not equal to 0, the function value is 1. If the value in the brackets is equal to 0, the function value is 0. like , it means the check fails, and the control Re-establish the communication port corresponding to each communication protocol type; like , it means the check is passed and there is no need to The communication port corresponding to each communication protocol type is re-established.

4. An agricultural sensor data acquisition system based on OPC UA, characterized in that: The agricultural sensor data acquisition system comprises: A scanning module is used to obtain the agricultural data collected by agricultural sensors acquired through the agricultural monitoring and management platform by scanning, and obtain the sensor types used to collect agricultural data and the number of sensors corresponding to each type of sensor; A protocol determination module, used to determine the communication protocol corresponding to each sensor according to the type and quantity of the agricultural sensors, and obtain the communication protocol type in the data transmission process of the agricultural sensors; An establishing module, used for sending the communication protocol type corresponding to the agricultural sensor to the OPC UA server, and establishing a communication port corresponding to the communication protocol type through the OPC UA server; Wherein, the protocol determination module includes: A type quantity extraction module, used to extract the type quantity of the agricultural sensor type and the type quantity of the communication protocol; A first protocol type acquisition module is used to acquire the communication protocol type corresponding to each type of agricultural sensor according to the rule that different types of agricultural sensors correspond to different types of communication protocols when the number of types of the communication protocols is not less than the number of types of the agricultural sensors; A second protocol type acquisition module is used to acquire the communication protocol type corresponding to each type of agricultural sensor according to the type of agricultural sensor and the number of agricultural sensors of each type when the number of types of the communication protocol is lower than the number of types of the agricultural sensor; Wherein, the first protocol type acquisition module includes: A first protocol allocation module is used to assign a communication protocol to a type of agricultural sensor whose number of agricultural sensors is less than a first preset number threshold; A second protocol allocation module is used to allocate the corresponding agricultural sensor types whose number of agricultural sensors is not less than a first preset number threshold but less than a second preset number threshold to two different communication protocols in units of complete types; The third protocol allocation module is used to allocate the corresponding agricultural sensor types whose number of agricultural sensors is not less than the second preset number threshold to the remaining unactivated multiple communication protocols in units of complete types.

5. The agricultural sensor data acquisition system according to claim 4, characterized in that: The scanning module comprises: The agricultural data collection module is used to scan the agricultural data collected by agricultural sensors obtained by the agricultural monitoring and management platform; A data type acquisition module, used for acquiring an agricultural data type corresponding to the agricultural data according to the agricultural data, wherein the agricultural data type includes temperature data, humidity data, light data and soil pH value data; A sensor extraction module, used for extracting agricultural sensors corresponding to the agricultural data according to the agricultural data type; A classification module, used to classify the agricultural sensors according to the agricultural data type, and obtain a set of agricultural sensors in units of the agricultural data type; The sensor quantity extraction module is used to extract the quantity of agricultural sensors contained in each of the agricultural sensor sets.

6. The agricultural sensor data acquisition system according to claim 4, characterized in that: The communication protocol type corresponding to the agricultural sensor is sent to the OPC UA server. After the communication port corresponding to the communication protocol type is established by the OPC UA server, the OPC UA server first uses the established communication port to collect multiple data from each sensor, and detects whether the currently established communication port is accurate and reliable based on the multiple data collected from each sensor. The specific steps include: Step A1: The OPC UA server uses formula (1) to perform a data check on the data frame header and tail according to the data length of multiple data collected from each sensor; (1) in Indicates the collected The sensor A test value of the data; Indicates the extracted The sensor The hexadecimal format of the frame header data of the secondary data; Indicates the extracted The sensor The hexadecimal format of the frame tail data of the secondary data; Indicates The hexadecimal format of the standard data frame header of each sensor; Indicates The hexadecimal format of the standard data frame tail of each sensor; It means to find the absolute value; Indicates the collected The sensor The hexadecimal format of the secondary data; Indicates the collected The sensor The data length of the secondary data in hexadecimal format; Indicates right shift; Indicates left shift; like , it means the collected The sensor The data was successfully verified once; like , it means the collected The sensor The data failed to be verified once; Step A2: perform a second check on the data according to the data checksum in the multiple data collected from each sensor using formula (2); (2) in Indicates the collected The sensor Secondary test value of the data; Indicates the extracted The sensor The hexadecimal format of the data checksum of the secondary data; Representation data Middle The value of the bit; like , it means the collected The sensor The secondary inspection of the data was successful; like , it means the collected The sensor The secondary data inspection failed; Step A3: using formula (3) to control whether the communication port corresponding to the communication protocol type needs to be re-established according to the verification conditions of the primary verification and the secondary verification of multiple data of each sensor; (3) in Indicates The control value for re-establishing the communication port corresponding to each communication protocol type; Indicates the A set of sensor numbers corresponding to each communication protocol type; Indicates that belong All All values ​​found; Indicates that the collection The total number of data from each sensor; Represents a normalized function. If the value in the brackets is not equal to 0, the function value is 1. If the value in the brackets is equal to 0, the function value is 0. like , it means the check fails, and the control Re-establish the communication port corresponding to each communication protocol type; like , it means the check is passed and there is no need to The communication port corresponding to each communication protocol type is re-established.