Variable-granularity real-time environment data acquisition method for Internet of thingsThe technical field is as follows:
the invention relates to a variable-granularity real-time environment data acquisition method for the Internet of things.
Background
The collection, processing and transmission of environmental data are one of the most important targets for the application of the internet of things, and limited hardware, network and computing resources are the main bottlenecks limiting the development of the internet of things: therefore, efficient and low-power-consumption environmental data collection becomes one of the most popular research directions in the field of internet of things, and the prediction model scheme is concerned about reducing the communication quantity between nodes to a certain extent.
Many error-based prediction model schemes now perform error estimation after performing complex mathematical prediction operations to obtain a value that satisfies the error. In fact, since the actual environmental data changes slightly and slowly, and the data changes within the error interval in a long time, performing the complicated mathematical prediction operation without deviating from the error interval consumes some unnecessary system resources. And many prediction model schemes do not encode data, actual data are directly transmitted, and communication bandwidth resources are wasted. Therefore, the scheme for acquiring the variable-granularity real-time environment data facing to the Internet of things is provided.
Disclosure of Invention
The invention designs an internet of things real-time data collection method, which is used for saving limited storage resources and operation resources of sensor nodes and reasonably utilizing limited communication capacity between the sensor nodes and sink nodes.
The hardware main body of the invention is a sensor node and a sink node, wherein the sensor node is responsible for collecting, processing and sending data, and the sink node is responsible for receiving and processing data and is a final data collection place. The deployment is detailed in fig. 1.
The prediction model scheme can effectively reduce the communication times between the sensor nodes and the sink nodes, so that the communication energy consumption between the nodes is reduced. The prediction model scheme is realized by running the same prediction algorithm on the sensor node and the sink node, meanwhile, the sensor node and the sink node have the same acquisition period, the sensor node collects and codes real environment data at a preset acquisition time, and then the real environment data is compared with prediction data generated by the prediction model, if the prediction is satisfied, the communication behavior is inhibited, and if the prediction is not satisfied, the coded data needs to be sent out. Meanwhile, the sink node at the other end updates the data pool by using the received data as data or by using the data generated by the prediction model as data, as shown in fig. 2 and 3. And at the preset acquisition time, the prediction algorithm is operated at the sensor node and the sink node to generate the same prediction result.
Real environmental data is often a collection of limited data spaces, in (U)min,Umax) Now, the data space set is divided into a plurality of intervals with the length of 2 δ, and δ is the error allowed by the prediction model. According to equation (1), n segments will be generated.
Now, a fixed-length coding mode is adopted, and each interval segment corresponds to a binary code with the length of L. The length L is obtained by equation (2).
L=log2n (2)
Now, assuming that there is a set of humidity environment data, the unit is%, the distribution range is 0.00% to 7.99%, and the error tolerance is 0.25%, after processing, the limited data space can be divided into a plurality of binary codes, as shown in fig. 4.
Here a simple monitoring mechanism is used to build a prediction model, as shown in fig. 5, which predicts the overall trend of the change by periodic change monitoring for each bit of the encoded data. For each bit, a bit space is created, in which a queue of n cycles of historical data is stored, and only the most recently occurring n cycles of historical data are stored, the queue being denoted by tn,tn-1,tn-2,…,t1]The historical data period refers to the time for which the data retention state is unchanged. The next variation period T of each bit is predicted according to equation (3), as shown in fig. 6.
At each acquisition moment, the prediction model judges whether each digit needs to change at the current sampling moment according to the latest change moment of each digit and the change period T obtained by averaging the latest n times of historical data periods, and the final overall prediction is generated through local prediction of each digit.
The data message is sent to the sink node by the sensor node. The message format adopts UTF-8 coding.
| Start symbol | Source of message | Message sequence number | Message body | Check code | Ending symbol |
| 1 byte | 2 bytes | 1 byte | N byte | 2 bytes | 1 byte |
The start character: 0x23 (#);
the source of the message: sensor ID, the entire network can accommodate 256 × 256 sensor nodes.
Message sequence number: the sequence used for marking the message, for the same node message, the message counts from 0x00 to 0xFF according to the sending sequence, and counts again every 256 messages;
message body: all information in the message is contained;
checking: the check is performed from the start symbol to the end of the message body. CRC-16/IBM is adopted for checking;
an end symbol: 0x25 (%);
for example, the sink node receives a piece of information 0x23FF0403646C0925, the content of the message is start symbol 0x23, message source 0xFF04, message sequence 0x03, message body 0x64, check code 0x6C09, and end symbol 0x 25.
Advantageous effects
1. Based on the sensor binary number processing, floating point number conversion is not needed, the calculation is based on binary codes from beginning to end, the calculation is faster, and the cost is smaller;
2. the tolerance of the user to the error is put to the beginning instead of the end, so that the data volume is reduced at the beginning, and all subsequent calculations are convenient;
3. and the coded data is predicted and transmitted, so that the energy consumption is reduced.
Drawings
FIG. 1 is a schematic diagram of a device deployment;
FIG. 2 is a flow chart of sink node work;
FIG. 3 is a sensor node workflow diagram;
FIG. 4 is a schematic view of a process of converting data collected by a sensor into corresponding encoded data;
FIG. 5 is a schematic diagram of a monitoring mechanism;
FIG. 6 is a state update flow chart;
Detailed Description
How this model works is described below with specific cases: at a predetermined acquisition time, the sensor node converts the collected environmental data into its corresponding code, which is then compared with the predictive data generated by the contemporaneous predictive model. If the data is the same, the send operation is suppressed and instead the data needs to be sent and then the queue holding the historical data period is updated. Meanwhile, at the other end, the sink node needs to judge whether the sink node collects data at a preset time, if the sink node receives the data, the received data is used as a real-time data record, if the sink node does not receive the data, a data is generated according to a self prediction model and used as a real-time data record, and the data is the same as the data generated by a prediction model operated at the sensor end, and a queue storing a historical data period is updated. Finally, the encoded data is stored in the data pool, so that the encoded data needs to be restored into a data interval according to a preset encoding rule when the data pool is used at last.
Suppose that data encoded as 0011 is collected in real time at the sensor node side, and the prediction model also generates data encoded as 0011. At this time, the sensor node considers that the prediction is successful and suppresses the data uploading behavior. Since the sensor node prediction model and the sink node prediction model are the same, at the sink node, the prediction model generates the same data 0011. After the preset collection period is finished, the sink node does not receive any data, the data 0011 generated by the model is considered to be correct, and the data 0011 is stored in the data pool. After the preset acquisition period is finished, the sensor nodes and the sink nodes update the prediction model according to the data 0011.
Suppose that 0100 encoded data is collected at the sensor node end in real time, and 0011 encoded data is generated by the prediction model. At this time, the sensor node regards the prediction as failed and uploads the data. At the sink node at the other end, the predictive model produces prediction data 0011. In a preset acquisition period, as the sink node receives the data 0100, the sink node considers that the prediction fails, discards the predicted data 0011, and stores the data 0100 in the data pool. After the predetermined acquisition period is finished, the sensor nodes and the sink nodes update the prediction model according to the data 0100.
0-1 state machine:
after the acquisition period is finished, it is assumed that the prediction model is updated by 0100 data, and the specific process is as follows: the 0100 data is sequentially decomposed into four bit state values of 0, 1, 0 and 0, and then the related information value of each bit state is updated. Taking a firstbit state value 0 as an example, thestate value 0 is input into a first bit space corresponding to a model, a cycle queue [2, 2,3,4] of which the latest n is 4 state changes, a state identifier (0 or 1) of the bit, namely the previous data state and the time point of the latest state change, are stored in the first bit space of the model, the first 2 in [2, 2,3,4] is the latest encoded data change cycle, and the last 4 is the farthest data change cycle. If in this update it is found that theinput value 0 is different from the current bit identifier, i.e. the current bit identifier is 1, then the update cycle queue is required to be [1,2,2,3], update the current bit identifier to 0, update the latest state change time point. If the current bit identifier is found to be 0, i.e., the state has not changed, then the current bit identifier and the most recent state change time point are not changed, and only the periodic alignment is changed to [3,2,3,4 ].
Assuming that a prediction model is needed to generate data, for each bit, the prediction model takes the average value of the change period queue as the change period of the prediction model, further estimates whether the prediction model changes at the current time point, outputs the prediction state of each bit, and generates the final overall prediction by locally predicting each bit.