A management method
Through LoRa spread spectrum and edge monitoring technology, the problem of low data transmission efficiency in traditional greenhouse environmental monitoring systems is solved, efficient, low-latency data transmission and intelligent environmental control are achieved, reducing energy consumption and network pressure.
Patent Information
- Application Number
- CN202410479539.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-22
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-04-22
AI Technical Summary
Traditional greenhouse environmental monitoring systems have problems such as low data transmission efficiency, high latency, and high energy consumption. Especially in large-scale battery pack monitoring scenarios, the concurrent upload of massive monitoring data may cause network congestion and delays.
LoRa spread spectrum and edge monitoring technology are used to collect data through wireless temperature and humidity recorders and wireless CO2 concentration recorders, and use LoRa WAN wireless channels to transmit to LoRa WAN gateways. Channel quality indicators are used to evaluate channel quality and select the optimal spreading factor. Perform CSS spread spectrum modulation, combine with edge computing nodes for anomaly detection, reduce network transmission pressure, and perform data analysis and prediction through machine learning algorithms.
It improves data transmission efficiency, reduces network congestion and delay, reduces the transmission power and energy consumption of terminal equipment, ensures the continuity and integrity of data, and provides an optimization strategy for intelligent control of the greenhouse environment.
Smart Images

Figure CN118264997B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of environmental monitoring, and in particular to a management method. Background Art
[0002] Real-time monitoring of environmental parameters such as temperature, humidity, and carbon dioxide concentration in the greenhouse can provide reliable data support for intelligent environmental control, thereby promoting crop growth, improving yield quality, and saving energy resources. With the development of new-generation information technologies such as the Internet of Things and big data, traditional greenhouse environmental monitoring systems are also facing the need for upgrading and replacement, and it is urgent to introduce more advanced sensor communication and data processing technologies to improve the intelligence level and operating efficiency of the system.
[0003] In traditional greenhouse environment monitoring systems, the massive amount of monitoring data collected by various sensors needs to be uploaded to the cloud server in a timely manner through wireless communication networks for aggregation and processing. However, due to the limitations of the deployment environment and application characteristics, existing monitoring systems generally have problems such as low data transmission efficiency, high latency, and high energy consumption.
[0004] In the related art, for example, Chinese patent document CN117192416A provides a battery monitoring system and method based on a BMS system. It first obtains the temperature values of the monitored battery at multiple predetermined time points within a predetermined time period and the discharge current signal of the predetermined time period, then performs a time series analysis on the temperature values at the multiple predetermined time points to obtain the temperature time series characteristics, then performs a waveform time series characteristic analysis on the discharge current signal to obtain the discharge current waveform characteristics, then performs feature interactive correlation encoding on the temperature time series characteristics and the discharge current waveform characteristics to obtain the discharge current-temperature time series interactive characteristics, and finally, based on the discharge current-temperature time series interactive characteristics, determines whether the monitored battery has an abnormality. However, in this solution, the temperature value and discharge current signal collected by the battery monitoring device are reported to the BMS system in real time for subsequent feature extraction and abnormality diagnosis. This continuous real-time data reporting method will occupy a large amount of communication bandwidth, especially in the scenario of large-scale battery group monitoring, the concurrent upload of massive monitoring data may cause network congestion and delay. Summary of the invention
[0005] 1. Technical issues to be solved
[0006] In view of the problem of low efficiency of monitoring data transmission in the prior art, the present application provides a management method, which improves the data transmission efficiency through LoRa spread spectrum and edge monitoring.
[0007] 2. Technical solution
[0008] The purpose of this application is achieved through the following technical solutions.
[0009] One aspect of the embodiments of this specification provides a management method, including: data collection: a wireless temperature and humidity recorder and a wireless CO2 concentration recorder respectively collect temperature, humidity and CO2 concentration data of the target space. Data transmission: the collected data is transmitted to the LoRa WAN wireless gateway through the LoRa WAN wireless channel. During the transmission process: the channel quality indicator CQI is used to evaluate the channel quality, and the optimal spreading factor is selected based on the machine learning algorithm. The physical layer adjusts the CSS spreading modulation mechanism according to the optimal spreading factor, generates the adjusted radio frequency configuration parameters, and uses the adjusted CSS spreading modulation mechanism to spread spectrum modulate the data and send it to the LoRa WAN gateway. When the communication is interrupted, the local storage module of the recorder saves the collected data: the collected data is converted into digital quantities and stored in the data buffer, combined into data frames and written into the FIFO circular queue of the local storage module, and the circular queue manages the circular storage of the data frames. Data reception and detection: The LoRa WAN gateway receives the data and forwards it to the edge computing node for anomaly detection. The data after anomaly detection is uploaded to the server via Ethernet. Data upload after communication recovery: After communication is restored, the recorder verifies the downlink control message, stops the circular queue storage, generates a data upload task table, reads local data in the order of the task address interval, and sub-packets the read data. It transmits it to the server through the random access method of the LoRa WAN gateway ALOHA. After the upload task is completed, the uploaded data of the local storage module is cleared. Server data processing: The server receives the data sub-packetization, splices the original data frame according to the sequence number cache, deserializes and parses the data frame, extracts the temperature and humidity, CO2 concentration data and timestamp, and converts it into JSON format and stores it in a relational database. Data analysis and display: The Apriori algorithm is used to mine the association rules between data, and the K-means clustering algorithm is used to cluster and analyze the time series data, predict the room temperature environment state, visualize the analysis results, and manage the equipment. Two-way communication: Two-way communication is established between the LoRaWAN gateway and the server based on the MQTT protocol. This application constitutes a complete end-to-end IoT data management system architecture from front-end sensor data collection, wireless transmission, anomaly detection, local storage, data recovery and upload, server reception and processing, to back-end data analysis, mining and visualization, which can realize intelligent monitoring and equipment management of the indoor environment of buildings.
[0010] In this application, the edge computing node uses anomaly detection algorithms to analyze environmental data collected by sensors, implement data preprocessing and initial screening, and reduce the pressure of network transmission and server storage. The anomaly detection algorithms that can be used include: statistical-based methods (such as Gaussian distribution model), distance-based methods (such as K-nearest neighbor algorithm), clustering-based methods (such as K-means algorithm), classification-based methods (such as support vector machine), etc.
[0011] Among them, MQTT (Message Queuing Telemetry Transport) is a lightweight IoT communication protocol based on the publish / subscribe model. It runs on top of the TCP / IP protocol and supports QoS to ensure reliable transmission of messages. In the MQTT architecture, there are three roles: publisher, broker, and subscriber. The publisher publishes messages to a specific topic, the broker is responsible for filtering and distributing messages, and the subscriber receives messages from the topics to which it subscribes. The MQTT protocol has a simple message structure and low overhead, making it very suitable for resource-constrained IoT devices.
[0012] In this application, after the server receives the environmental monitoring data from the LoRa WAN gateway, it can use a variety of advanced machine learning algorithms to analyze and mine the data, obtain valuable association rules and trends, and provide intelligent decision-making basis for equipment management. In this application, the machine learning algorithms that can be used are: Association rule mining algorithm: Apriori algorithm: Through the recursive generation and pruning of candidate item sets, frequent item sets are mined to discover the association rules between monitoring indicators such as temperature, humidity, and CO2 concentration. FP-Growth algorithm: Utilizes the FP tree structure to store and retrieve frequent items, and generates frequent item sets and association rules more efficiently than Apriori. Eclat algorithm: Uses longitudinal data format and intersection calculation to quickly discover frequent item sets. Time series prediction algorithm: ARIMA model: A time series prediction model based on autoregression, difference, and moving average that captures the trend, periodicity, and randomness of data. Prophet model: A time series prediction algorithm open sourced by Facebook, suitable for nonlinear time series with multiple seasonal and holiday effects. LSTM neural network: Long short-term memory network is good at processing long sequence data and learns the long-term dependencies of data through gating mechanisms. Anomaly detection algorithm: One-Class SVM: Single-class support vector machine distinguishes abnormal points by learning the compact boundaries of normal data. Isolation Forest: Isolation forest uses the principle that abnormal points are more easily isolated to quickly detect anomalies through random binary trees. LOF local anomaly factor: By calculating the ratio of the sample point to its neighborhood density, find the local outliers that are abnormal relative to the neighboring points. Cluster analysis algorithm: K-means clustering: Data is divided by iteratively optimizing the distance from the sample point to the cluster center. It can be used to analyze power load curves, etc. DBSCAN density clustering: A clustering algorithm based on the local density connectivity of samples can find cluster structures of any shape. Spectral clustering: The Laplace matrix spectral decomposition of the sample is used to obtain the optimal partitioning of data. Deep learning algorithm: Autoencoder: Through the combination of encoder and decoder, the high-order features of data are learned under unsupervised conditions. Convolutional neural network CNN: Good at processing grid topology data, can be applied to feature extraction and classification of equipment images. Recurrent neural network RNN: Suitable for processing time series data and exploring the regularity of the evolution of equipment operating parameters over time. Multivariate statistical analysis: Principal component analysis PCA: Project multiple indicators to a low-dimensional subspace with the largest variance through orthogonal transformation to reveal the inherent structure between variables. Partial least squares regression PLS: Perform variable screening and dimensionality reduction regression while maximizing the covariance between independent and dependent variables. Bayesian network: Use directed acyclic graphs to represent the dependency relationship between variables and characterize the strength with conditional probability. It can be used for fault diagnosis, risk assessment, etc.
[0013] Furthermore, the transmission performance of the LoRa WAN wireless channel is optimized and the channel conditions are dynamically adapted to improve the reliability and efficiency of data transmission. Including: Channel quality assessment: The LoRa WAN wireless channel is evaluated using the Channel Quality Indicator (CQI). CQI comprehensively considers indicators such as signal-to-noise ratio (SNR), channel gain, and packet error rate (PER). By monitoring the channel quality in real time, the quantitative evaluation results of the current channel state are obtained. Machine learning algorithm selects the spreading factor: Construct a neural network model to establish a nonlinear mapping relationship between the CQI evaluation result and the optimal spreading factor (SF). Use Quantile regression as the loss function to train and optimize the neural network. Quantile regression can characterize the overall distribution of the response variable by estimating the conditional quantile and is robust. According to the current CQI, the trained neural network model is used to select the optimal SF that can maximize the throughput and minimize the packet loss rate. Physical layer RF parameter adjustment: The optimal SF parameters selected by the neural network are sent to the physical layer (PHY) of LoRa WAN. PHY dynamically adjusts the Chirp Spread Spectrum (CSS) spread spectrum modulation mechanism according to the received SF. Specifically, it changes the duration of a single Chirp signal and the frequency offset gradient. PHY generates RF configuration parameters that match the optimal SF, such as carrier frequency, bandwidth, and transmit power. Data spread spectrum modulation and transmission: The adjusted physical layer RF configuration is loaded to the PHY interface of LoRa WAN. Through the PHY interface, the collected temperature, humidity, and CO2 concentration data are processed using the optimized CSS spread spectrum modulation mechanism. After spread spectrum modulation, the data frame is sent to the gateway through the LoRaWAN wireless channel.
[0014] This application introduces a machine learning algorithm to dynamically select the optimal spreading factor through a neural network model and adjust the physical layer RF parameters accordingly. Traditional LoRa WAN solutions usually use a fixed SF configuration, which is difficult to adapt to dynamically changing channel environments and has limited transmission performance. By using real-time channel quality feedback, the modulation mechanism is adaptively optimized to improve data throughput while ensuring link quality. At the same time, the introduction of Quantile regression improves the robustness of SF selection and reduces the probability of misjudgment under abnormal channel conditions.
[0015] Among them, CQI (Channel Quality Indicator) is an indicator used to evaluate the quality of wireless communication links. In wireless communication systems, the quality of channels will continue to change due to the influence of factors such as noise, interference, and fading. CQI quantitatively evaluates the real-time status of the channel by measuring specific parameters of the signal, such as signal-to-noise ratio (SNR), channel gain, bit error rate (BER), etc. Among them, Quantile regression is a statistical learning method used to estimate the conditional quantile function. Unlike the traditional least squares regression that estimates the conditional mean function, Quantile regression can estimate the conditional quantile function at any quantile point, characterizing the comprehensive distribution characteristics of the response variable under given covariates.
[0016] The goal of Quantile regression is to minimize the loss function, which is defined as:
[0017] Among them, y is the true value, is the predicted value, T is the quantile parameter, and its value range is (0, 1). When T = 0.5, Quantile regression degenerates into median regression. By minimizing the loss function of different quantiles, Quantile regression can fit the conditional quantile function and reveal the nonlinear relationship and heteroscedasticity characteristics between variables.
[0018] Among them, the spreading factor (SF) is a key parameter of the LoRa physical layer, which determines the rate and sensitivity of data transmission. The value range of SF is 7 to 12. The larger the SF value, the more bits each symbol carries, the lower the data rate, but the higher the receiving sensitivity and the longer the transmission distance. Conversely, the smaller the SF value, the higher the data rate, but the receiving sensitivity decreases and the anti-interference ability becomes worse. Among them, CSS (Chirp Spread Spectrum) is a spread spectrum modulation technology adopted by the LoRa physical layer. It uses a linear frequency modulation swept frequency signal (Chirp Signal) as a carrier to modulate the baseband data onto the spread spectrum signal to achieve the integration of spread spectrum and modulation.
[0019] Further, the LoRaWAN physical layer generates adjusted RF configuration parameters according to the optimal spreading factor (SF) and performs CSS spread spectrum modulation on the data. Including: Generate a Chirp baseband signal matching the optimal SF: The physical layer adjusts the rate and frequency offset parameters of the Chirp signal according to the optimal SF selected by the neural network. Adapt to different SFs by extending or shortening the duration of a single Chirp signal. The larger the SF, the longer the Chirp duration, and the more bits each symbol carries. Match the bandwidth and spectrum utilization under different SFs by increasing or decreasing the frequency offset gradient. The larger the SF, the smaller the frequency offset gradient, and the narrower the Chirp signal bandwidth. Generate a Chirp baseband signal matching the optimal SF as the basis for spread spectrum modulation. Spread spectrum modulation of data: The physical layer performs spread spectrum modulation on the input temperature, humidity, and CO2 concentration data. Copy and generate multiple copies of spread spectrum data with different frequency offsets, and the frequency offset depends on the SF and bandwidth. The number of spread spectrum copies is related to the SF. The larger the SF, the more copies, the higher the redundancy, and the stronger the anti-noise ability. Perform an orthogonal transform on the spread spectrum data replica: The physical layer uses a set of orthogonal Chirp bases corresponding to different SFs to perform an orthogonal transform on the spread spectrum data replica. Through the orthogonal transform, the original Chirp signal is mapped from the time domain to the transform domain subspace composed of the orthogonal Chirp base. After the transform, the original signal is decomposed into a set of orthogonal components corresponding to different SFs, and each component corresponds to an orthogonal Chirp basis. The orthogonal transform can decouple the Chirp signals under different SFs, improve the orthogonality between different SF signals, and reduce mutual interference.
[0020] Preferably, the orthogonal transformation scheme: adopts the fast Fourier transform (FFT) algorithm to accelerate the orthogonal transformation process. FFT reduces the computational complexity of DFT from O(N^2) to O(NlogN) through the divide-and-conquer strategy. The Zadoff-Chu sequence is used as the orthogonal Chirp basis to construct the transformation matrix. The Zadoff-Chu sequence has good autocorrelation and cross-correlation characteristics, which can minimize the interference between different SF signals. In terms of hardware implementation, the FPGA parallel computing architecture is adopted, and the pipeline and parallel processing units are used to improve the real-time performance of the orthogonal transformation.
[0021] Modulation output: The physical layer outputs the multiple orthogonal components of the spread spectrum data after orthogonal transformation to two orthogonal branches, I (in-phase) and Q (orthogonal). I and Q correspond to the Chirp basis under different SFs, respectively, to achieve parallel modulation of different SF signals. The modulated I and Q signals are processed by digital-to-analog conversion (DAC) and RF front-end (RFFront-end), and finally sent out through the antenna.
[0022] This application can significantly improve the spectrum utilization of CSS spread spectrum modulation, enhance the orthogonality between different SF signals, and reduce mutual interference by optimizing Chirp signal parameters and optimal SF matching, combined with orthogonal transformation and parallel modulation. At the same time, the introduction of FFT and Zadoff-Chu sequence improves the computational efficiency and performance of orthogonal transformation. The application of FPGA parallel computing architecture ensures the real-time performance of the modulation process.
[0023] Among them, the chirp signal is a signal whose frequency changes linearly with time, also known as a linear frequency modulated signal (Linear Frequency Modulated Signal). The instantaneous frequency of the chirp signal can be expressed as: f(t) = f 0 +k×t. Among them, f 0 is the starting frequency, k is the chirp rate, which determines how fast the frequency changes. When k>0, the frequency of the chirp signal increases over time, which is called an up-chirp; when k<0, the frequency of the chirp signal decreases over time, which is called a down-chirp.
[0024] Among them, I-Phase and Q-Phase refer to the two orthogonal components in quadrature modulation. On the complex plane, I-Phase is located on the real axis and Q-Phase is located on the imaginary axis, and the phase difference between the two is 90 degrees. The digital baseband signal is modulated onto the high-frequency carrier through I-Phase and Q-Phase to achieve quadrature amplitude modulation (QAM). The transmitter divides the baseband signal into two parts, I-Phase and Q-Phase, and multiplies them with the same frequency and orthogonal carriers respectively, and then adds the two signals to form a QAM signal. The receiver multiplies the received QAM signal with the I-Phase and Q-Phase carriers respectively, and then restores the original I-Phase and Q-Phase baseband signals through low-pass filtering. The physical layer performs an orthogonal transform on the spread data copy and maps it to a transform domain subspace composed of orthogonal Chirp bases corresponding to different spreading factors. The transformed spread data has different projection coefficients on different orthogonal Chirp bases, forming a set of orthogonal components.
[0025] Furthermore, the LoRaWAN physical layer generates adjusted RF configuration parameters according to the optimal spreading factor (SF), and performs orthogonal modulation and RF frequency conversion on the spread spectrum baseband signal. Including: I / Q branch generates spread spectrum baseband signal: The physical layer I / Q branch maps the spread spectrum data component after orthogonal transformation to I channel (in phase) and Q channel (orthogonal). I channel and Q channel correspond to the orthogonal Chirp basis under different SFs, respectively, to generate I channel spread spectrum baseband signal and Q channel spread spectrum baseband signal. Orthogonal phase rotation: The I channel spread spectrum baseband signal is phase rotated with a rotation angle of θ1; the Q channel spread spectrum baseband signal is phase rotated with a rotation angle of θ2. By adjusting the phase rotation angles of I channel and Q channel, the power allocation ratio of I channel and Q channel is changed. The purpose of phase rotation is to optimize the orthogonality of I channel and Q channel signals, reduce mutual interference, and improve system capacity. The phase rotation angle can be dynamically adjusted according to channel conditions and SF to adapt to different transmission environments. Quadrature amplitude modulation: The I-channel spread spectrum baseband signal and the Q-channel spread spectrum baseband signal that have undergone orthogonal phase rotation are subjected to orthogonal amplitude modulation. The I-channel and Q-channel signals are orthogonally superimposed to generate a QPSK (quadrature phase shift keying) modulation signal. QPSK modulation can provide good noise and fading resistance while ensuring spectrum efficiency. RF frequency conversion: The generated QPSK signal is mixed with the RF carrier signal, and the baseband QPSK signal is up-converted to the RF carrier frequency. The RF carrier frequency is determined by the channel frequency parameters of the LoRa WAN physical layer, usually in the ISM band (such as 868MHz, 915MHz, etc.). The RF signal after frequency conversion has higher penetration and transmission distance, which is suitable for wide-area coverage scenarios. RF attenuation control: The optimal SF is converted into RF attenuation control parameters, including the transmit power and receive gain of the RF signal. The larger the SF, the higher the sensitivity, but the transmit power needs to be reduced accordingly to reduce power consumption and interference. The smaller the SF, the transmit power can be appropriately increased to expand the coverage range, but the receive gain needs to be reduced accordingly to avoid saturation distortion. The purpose of RF attenuation control is to optimize power consumption and interference levels while ensuring the link budget.
[0026] Preferably, the RF attenuation control parameters: adopt a closed-loop automatic gain control (AGC) algorithm to dynamically adjust the transmit power and receive gain. AGC adaptively optimizes the RF attenuation parameters by real-time monitoring of the received signal strength indication (RSSI) and signal quality indication (SQI). Introduce machine learning algorithms, such as reinforcement learning, to learn the optimal RF attenuation strategy by continuously interacting with the environment. Construct a nonlinear mapping model between RF attenuation parameters and factors such as SF, channel conditions, and power consumption constraints, such as a neural network, to accurately predict the optimal RF attenuation combination. Adjust the physical layer RF configuration parameters: adjust the physical layer RF configuration according to the obtained phase rotation angle (θ1, θ2), channel frequency parameters, and RF attenuation control parameters. RF configuration parameters include the amplitude and phase of the I / Q branch, the local oscillator frequency, the power amplifier gain, etc. Through software defined radio (SDR) technology, using digital signal processors (DSPs) and field programmable gate arrays (FPGAs), flexible configuration and real-time adjustment of RF parameters are achieved.
[0027] This application, based on CSS modulation, introduces orthogonal phase rotation and amplitude modulation to optimize the orthogonality and power allocation of I / Q branch signals, improve spectrum utilization and anti-interference capabilities. The optimization of RF frequency conversion and attenuation control enhances the penetration and transmission distance of the signal while taking into account power consumption and interference levels. In particular, the application of AGC and machine learning algorithms realizes adaptive optimization and precise configuration of RF attenuation parameters. The introduction of SDR, DSP, FPGA and other technologies gives the physical layer RF parameters greater flexibility and real-time performance.
[0028] In the present application, the rotation angle of the I-path signal is θ, and the rotation angle of the Q-path signal is θ+90°, which differ by 90 degrees and maintain orthogonality. By adjusting the value of θ, the power distribution of the I-path and Q-path can be changed, the QPSK constellation diagram can be optimized, and the anti-noise and anti-fading performance can be improved. Among them, QPSK (Quadrature Phase Shift Keying) is a commonly used orthogonal modulation method that maps two bits of information to four carrier signals with different phases. In QPSK, the I-path and Q-path baseband signals are modulated with two orthogonal carriers respectively, and then the modulated signals are added to form a QPSK signal. The constellation diagram of the QPSK signal presents four signal points with equal angles on the complex plane, and each point corresponds to a binary symbol.
[0029] Among them, the channel frequency parameter refers to the center frequency of the wireless communication channel. In the LoRa WAN network, different channels occupy different frequency resources, and nodes and gateways communicate by selecting specific channels. The channel frequency is defined by the physical layer parameters and needs to be configured according to the frequency planning and regulatory requirements of the area. Among them, the RF attenuation control parameter refers to the transmit power and receive gain of the RF signal. The transmit power determines the strength and coverage of the RF signal, and the receive gain determines the sensitivity and dynamic range of the receiver. The RF attenuation control parameters need to be optimized based on factors such as the spreading factor and channel conditions, while meeting the link budget and regulatory restrictions, to seek a balance between power consumption, rate, and coverage.
[0030] Furthermore, the recorder uses a local storage module to save the collected environmental monitoring data when the communication is interrupted to ensure the integrity and recoverability of the data. Including: Data acquisition and digitization: The recorder collects environmental parameters such as temperature, humidity and CO2 concentration and converts them into digital quantities. The analog-to-digital converter (ADC) converts the analog signal collected by the sensor into digital code, such as binary or Gray code. The digitized data carries a timestamp and sensor type identifier for subsequent data frame assembly and parsing. Data buffering: The digitized data is sent to the data buffer, which plays the role of data temporary storage and flow control. The buffer adopts a first-in-first-out (FIFO) data structure, such as a ring buffer or a queue. When the buffer reaches a preset threshold or times out, the data frame assembly and storage operation is triggered. Data frame assembly: Read a certain number of digital quantities from the data buffer, add a timestamp and data type identifier. According to the time order of data acquisition, the digital quantities are combined into data frames, and each data frame represents the environmental monitoring data within a time window. The format of the data frame can be defined according to application requirements and communication protocols, such as JSON, XML or a custom binary format. Local storage management: The local storage module manages the received data frames based on the FIFO circular queue, which can efficiently utilize the limited storage space. The storage space is divided into several fixed-size storage pages, each of which stores one frame of data. The size of the storage page is determined by the maximum length of the data frame and the characteristics of the storage medium (such as the erase block size). The storage pages are organized into a circular queue in the order of increasing physical addresses. The circular queue contains a read pointer pointing to the head storage page and a write pointer pointing to the tail storage page. Initially, both the read pointer and the write pointer point to the starting position of the circular queue. Data storage: The assembled data frame is written to the tail of the circular queue, that is, the storage page currently pointed to by the write pointer. After writing is completed, the write pointer is moved to the next storage page. If it has reached the end of the circular queue, it wraps around to the starting position. If the write pointer catches up with the read pointer, it indicates that the circular queue is full and the oldest data needs to be overwritten. By moving the read pointer, a part of the expired data is discarded to make room for further writing. Data recovery: After communication is restored, the recorder uploads the data frames in the local storage module to the server in chronological order. Starting from the read pointer of the circular queue, read the data frames in the storage page in sequence until the read pointer catches up with the write pointer. After reading each frame of data, move the read pointer to the next storage page until all data frames are read and uploaded. After the upload is completed, clear the circular queue, reset the read pointer and write pointer to the starting position, and wait for the next communication interruption.
[0031] This application uses the data structure of a circular queue to efficiently manage local storage space and avoid data overwriting and fragmentation problems. The assembly and timestamp mechanism of data frames ensures the timing and integrity of data. The modular design idea decouples steps such as data acquisition, buffering, storage and uploading, improving the maintainability and scalability of the system. Preferably, data compression, encryption and other technologies can also be introduced to further optimize storage space utilization and data security. At the same time, according to different application scenarios and requirements, suitable storage media such as EEPROM, FLASH, SD card, etc. can be selected to balance cost, capacity and read-write performance.
[0032] Among them, the FIFO (First Input First Output) circular queue is a commonly used data buffering and management mechanism. It organizes a continuous storage space into a ring structure connected head to tail, and data is written and read out in sequence in a first-in-first-out order. In this application, the local storage module uses a FIFO circular queue to manage the storage of data frames. The storage space is divided into storage pages of fixed size, and each frame of data occupies one page. The storage pages are organized into a circular queue in the order of increasing physical addresses, with the read pointer pointing to the earliest written data frame and the write pointer pointing to the next free storage page. When a new data frame arrives, the recorder writes it to the end of the queue and moves the write pointer backward; when data needs to be uploaded, the recorder reads the data frame from the head of the queue and moves the read pointer backward.
[0033] Furthermore, based on the original local storage module, a multi-buffer page mechanism is introduced to further optimize the data cache and batch writing strategy. Including: multi-buffer page mechanism: N buffer pages are set in the buffer of the recorder, N is a positive integer greater than 2, such as 4, 8 or 16. The size of each buffer page is the same as the size of the storage page in the circular queue, which is used to temporarily store a certain number of data frames. The purpose of introducing multiple buffer pages is to realize batch writing of data, reduce frequent access to the local storage module, and improve data throughput and energy efficiency. Buffer page cyclic writing: The data frame is first written to the first buffer page of the buffer. When the buffer page is full, it is written to the next buffer page, and so on. When all N buffer pages are full of data frames, the batch transfer operation from the buffer page to the storage page is triggered. After the batch transfer is completed, the earliest written buffer page is cleared and released for the next round of data frame writing to realize the recycling of buffer pages. By recycling the buffer pages, the frequent allocation and release of memory is avoided, and the memory management overhead is reduced. Batch transfer to the circular queue: When the N buffer pages of the buffer are full of data frames, the data frames in the earliest written buffer page are batch transferred to the circular queue. The transmission target is the storage page currently pointed to by the write pointer in the circular queue, that is, the tail storage page. During the transmission process, the data frames in the buffer page are written to the storage page in sequence until the storage page is filled or all the data frames in the buffer page are written. Batch transmission can reduce the number of read and write operations and improve the efficiency of data writing, especially for local storage modules based on block storage (such as FLASH). Update the write pointer of the circular queue: After the batch transmission is completed, update the write pointer of the circular queue to the next storage page. If the write pointer has reached the end of the circular queue, it wraps around to the starting position to achieve circular writing. By updating the write pointer in time, it is ensured that subsequent data frames can be written continuously and the orderliness of the circular queue is maintained.
[0034] Clearing and reuse of buffer pages: After the batch transfer is completed, the earliest written buffer page is cleared and the data in it is marked as invalid or directly overwritten. The cleared buffer page can be used for the next round of data frame writing to achieve the recycling of buffer pages. By recycling the buffer page, the memory fragmentation problem is reduced and the memory utilization rate is improved. Synchronization of buffer and storage module: In practical applications, it is necessary to balance the size of the buffer and the frequency of batch transfer to avoid buffer overflow or storage module idleness. Reasonable thresholds can be set, such as buffer page utilization or time interval, to dynamically trigger batch transfer operations. At the same time, it is necessary to monitor the remaining space of the circular queue. When the remaining space is insufficient, upload data in time or expand storage capacity to ensure data continuity.
[0035] This application, by introducing a multi-buffer page mechanism and a batch transmission strategy, significantly improves the efficiency and throughput of data writing while ensuring data integrity. The recycling of buffer pages reduces memory management overhead and fragmentation problems. At the same time, by balancing the capacity and transmission frequency of the buffer and storage module, smooth storage and timely upload of data are achieved. Preferably, the buffer pages and storage pages can also be hierarchically managed in combination with the priority, timeliness and other characteristics of the data frame, such as allocating different buffer pages and storage pages for real-time data and historical data, to further optimize the utilization of storage resources and the efficiency of data access.
[0036] Furthermore, after the communication is restored, the recorder transmits the data in the local storage module to the server efficiently and reliably through the LoRa WAN wireless gateway. Including: XOR check of downlink control message: the recorder receives the downlink control message sent by the LoRa WAN wireless gateway and performs integrity check on the message. The XOR check algorithm is used to perform XOR operation on the data part of the message by byte to generate a check result. The XOR check can detect whether an odd number of bit errors have occurred in the message during transmission, and has low calculation and storage overhead. Determination of communication recovery status: the result of the XOR check is compared with the preset error-free value. If the check result is equal to the error-free value, it is determined that the LoRa WAN wireless communication has changed from the interruption state to the recovery state. The preset error-free value can be a fixed constant, such as 0x00 or 0xFF, or a specific value dynamically generated according to the application protocol. By introducing the check mechanism of the downlink control message, the reliability of the communication recovery state determination is improved, and misjudgment or missed judgment is avoided. Generate data upload control instructions: When it is confirmed that the communication has been restored, the recorder generates a data upload control instruction to instruct the local storage module to start the data upload task. The data upload control instruction contains an upload start flag and a timestamp. The upload start flag is used to trigger the upload operation, and the timestamp is used to determine the time range of the data to be uploaded. The timestamp can be the system time when the communication is restored, or a specific time specified according to application requirements.
[0037] Determine the storage page range of the data to be uploaded: After receiving the data upload control instruction, the local storage module stops the circular queue from storing the data in a circular queue and enters the data upload mode. According to the timestamp, find the corresponding first storage page and the last storage page in the circular queue as the boundaries of the data to be uploaded. The starting address of the first storage page is used as the starting address of the data to be uploaded, and the ending address of the last storage page is used as the ending address of the data to be uploaded. The introduction of the timestamp ensures the time continuity and integrity of the data to be uploaded, and avoids data omission or duplication. Generate a data upload task table: According to the obtained starting address and ending address of the data to be uploaded, generate a data upload task table, which consists of multiple upload tasks. Each upload task corresponds to a continuous address interval, and the size of the address interval is determined according to factors such as the data frame size and communication quality of the LoRaWAN wireless link. The address intervals of adjacent upload tasks are continuous and non-overlapping, which ensures the integrity and consistency of data upload. Through the division of the task table, the block transmission and progress management of data upload are realized, which improves the efficiency and reliability of upload.
[0038] Determine the execution order of data upload: According to the starting address of the address interval of the upload task, the upload tasks are sorted in order from small to large. The sorted task order is the execution order of data upload, which ensures the time continuity and causal relationship of data upload. Through reasonable task scheduling and priority control, the priority upload of key data can be achieved, and the real-time performance of the system can be improved. Execute data upload tasks: The recorder reads the data of the corresponding address interval in the local storage module in turn according to the execution order of data upload, encapsulates it into LoRa WAN data frames and sends it to the wireless gateway. Each data frame contains the starting address, end address and identifier of the data interval, which facilitates the server to reorganize and confirm the data. During the upload process, the recorder monitors the quality of the LoRa WAN wireless link and the response of the gateway in real time, and dynamically adjusts the size and retransmission strategy of the data frame as needed. After the data upload is completed, the recorder sends an upload completion instruction to the server, and the server returns a confirmation message to complete the entire data upload process.
[0039] This application uses an XOR check algorithm to check the reliability of the downlink control message, and by introducing a timestamp and a data upload task table, it achieves accurate positioning and efficient transmission of the data to be uploaded. The division and sorting strategy of the task table ensures the integrity and timing of data upload. At the same time, by dynamically adjusting the data frame size and retransmission strategy, the reliability and real-time performance of data upload are improved. Preferably, data compression, encryption and other technologies can also be introduced to further optimize the efficiency and security of data upload. At the same time, according to the topology and load conditions of the LoRa WAN network, adaptive data upload strategies can be designed, such as decentralized upload, priority upload, etc., to improve the overall performance and scalability of the system.
[0040] Furthermore, based on the original data upload mechanism, the process of data packetization, transmission and cleaning is further refined to improve the efficiency and reliability of data upload, including: Reading the data corresponding to the upload task: The recorder processes each upload task in the task table in turn according to the execution order of data upload. For the currently executed upload task, the recorder reads the data in the corresponding address range from the local storage module. The start address and end address of the address range are provided by the upload task table, ensuring the accuracy and integrity of data reading. Data packetization: In order to adapt to the data frame size limit of the LoRa WAN wireless link, the recorder performs packetization on the read data. The data is segmented using a fixed-length data frame, and each data frame is called a data packet. The length of the data packet is optimized according to the configuration parameters of the LoRa WAN (such as SF, BW, etc.) and application requirements (such as battery life, real-time, etc.). Multiple data packets are generated in the order of increasing packet numbers, and each packet contains data content, packet number and upload task identifier. ALOHA random access transmission: The recorder uses ALOHA random access to transmit data packets to the server through the LoRa WAN wireless gateway. ALOHA is a probability-based distributed multiple access protocol that does not require centralized scheduling and is suitable for low-power, low-data-volume IoT application scenarios. Before sending each data packet, the recorder randomly selects a backoff time and sends the data packet after the backoff time. If the transmission fails (no ACK confirmation from the server), the recorder will randomly select a new backoff time and resend the data packet. The random backoff and retransmission mechanism reduces the probability of packet collision and improves the success rate of data transmission.
[0041] Data reception and reorganization on the server side: The server receives data packets from the recorder through the LoRa WAN wireless gateway. The server sorts and splices the data packets belonging to the same upload task according to the upload task identifier and packet sequence number of the data packets. Through mechanisms such as CRC check, the server detects the integrity and correctness of the data packets. If an error is found, it sends a retransmission request to the recorder. After receiving all the data packets of a certain upload task, the server restores the data to its original form and stores it in the database or file system.
[0042] Clear uploaded data: When the recorder completes an upload task, it sends an upload completion instruction to the server, and the server returns a confirmation message. The recorder clears the uploaded data in the corresponding address range in the local storage module according to the confirmation information from the server. By clearing the uploaded data in a timely manner, the local storage space is released and data redundancy and confusion are avoided. At the same time, the recorder updates the task table and the metadata of the local storage module to maintain the consistency and integrity of the data upload.
[0043] Exception handling and recovery mechanism: During the data upload process, the recorder and the server need to handle various abnormal situations, such as link interruption, equipment failure, data loss, etc. The recorder detects the transmission status of the data packet through the timer and retransmission mechanism. If the server confirmation is not received for a long time, the data packet is resent. The server detects the continuity and timeliness of the data packet through the sequence number and timestamp. If packet loss or delay is found, a retransmission request is sent to the recorder. In extreme cases (such as long-term inability to restore communication), the recorder saves the unuploaded data to the local storage module and waits for the next communication to be restored before uploading.
[0044] This application uses fixed-length data frames to packetize data, combined with the ALOHA random access method, to achieve efficient data transmission and conflict avoidance. The data reorganization and confirmation mechanism on the server side ensures the reliability and integrity of data upload. At the same time, by timely clearing uploaded data and abnormal recovery mechanism, the utilization rate of local storage space and the robustness of the system are improved. Preferably, data compression, encryption and other technologies can also be introduced to further optimize the efficiency and security of data upload. At the same time, according to the topology and load of the LoRa WAN network, the data packet size, retransmission number and backoff time are dynamically adjusted to improve the adaptability and scalability of the system. Preferably, in order to cope with complex network environments and heterogeneous devices, EdgeComputing edge computing nodes can be introduced between the recorder and the server to preprocess, compress and encrypt data locally, reducing the burden on wireless links and servers. EdgeComputing nodes can also act as data cache and forwarding to improve the real-time and reliability of data upload.
[0045] Among them, ALOHA is a probability-based distributed random access protocol, commonly used in wireless communications and media access control (MAC) of shared channels. The ALOHA protocol allows multiple nodes to randomly send data on a shared channel without pre-allocating time slots or frequencies.
[0046] Furthermore, the server receives and processes the data packets from the recorder, and uses machine learning algorithms to perform correlation analysis and trend prediction on the data, including: Receiving and splicing data packets: The server receives the data packets from the recorder through the LoRa WAN wireless gateway. The server caches and sorts the received data packets according to the packet sequence number of the data packets. After receiving the data packet with the largest packet sequence number, the server splices all the data packets in the order of the packet sequence number from small to large to obtain the original complete data frame. By introducing the packet sequence number, the integrity and order of the data frame are ensured, and the loss or dislocation of data is avoided.
[0047] Parsing and extraction of data frames: The server uses the deserialization method to parse the received data frames and identify the location and length of different data fields. According to the format definition of the data frame, the server extracts the temperature data, humidity data, CO2 concentration data and the corresponding timestamp in the data frame. Through deserialization and field extraction, the conversion of data frames to structured data is realized, which is convenient for subsequent storage and analysis. Data storage and format conversion: The server converts the extracted temperature data, humidity data, CO2 concentration data and timestamp into JSON format. JSON is a lightweight data exchange format with strong readability and cross-platform. The server stores the data in JSON format in a relational database, such as MySQL, PostgreSQL, etc. Relational databases provide efficient data management and query capabilities and support the storage and indexing of structured data.
[0048] Apriori association rule mining: The server takes the JSON format data stored in the relational database as input and uses the Apriori association rule mining algorithm for analysis. The Apriori algorithm uses an iterative search method based on support and confidence indicators to discover frequent item sets and association rules between temperature data, humidity data, and CO2 concentration data. Support indicates the frequency of item sets in the data set, and confidence indicates the strength of the association rule. The server screens out strong association rules based on the preset support and confidence thresholds, and sorts the rules in reverse order according to the confidence index to generate a list of association rules. Association rules reveal the inherent connections and mutual influences between different environmental factors, providing a basis for environmental optimization and prediction.
[0049] K-means time series clustering: The server takes the multivariate time series consisting of temperature data, humidity data and CO2 concentration data as input and uses the K-means clustering algorithm for analysis. The K-means algorithm uses Euclidean distance as the similarity measure to divide the time series data into K clusters, each cluster is represented by its cluster center. The cluster center reflects the typical characteristics and change trends under different room temperature environmental states. The server continuously updates the cluster center through iterative optimization until the optimal clustering result is reached. The clustering results reveal the evolution law and change trend of the room temperature environmental state, providing a reference for environmental prediction and regulation. Real-time prediction and decision-making: The server divides the currently collected data points into the clusters where the cluster center with the closest Euclidean distance is located. According to the cluster to which the data point belongs, the server determines the room temperature environmental state at the current moment and uses it as the prediction result. The prediction results can be used for real-time monitoring and early warning, such as triggering an alarm or regulation mechanism when the prediction results deviate from the normal range. At the same time, the server can optimize and adjust environmental parameters according to the prediction results and association rules, such as adjusting the air conditioning temperature, humidifier power, etc., to achieve intelligent environmental management.
[0050] This application adopts Apriori association rule mining and K-means time series clustering algorithm to mine the relevance and trend contained in the data from different angles, providing data support for environmental monitoring and optimization. Through data storage in JSON format and management of relational databases, structured organization and efficient access of data are achieved. At the same time, based on real-time prediction and decision-making mechanisms, the solution can respond to environmental changes in a timely manner and provide intelligent environmental regulation and early warning services. Preferably, in order to cope with massive data and complex calculations, a distributed computing framework such as Hadoop, Spark, etc. can be introduced to achieve parallel processing of data and acceleration of algorithms. Through distributed computing and storage, the scalability and fault tolerance of the system are improved to support large-scale data analysis and mining.
[0051] Among them, deserialization is the process of converting data in binary or text format into an object or data structure in memory, which is opposite to serialization. When data is transmitted and stored, it is usually necessary to convert complex data objects into a format that is easy to transmit and store (such as a binary stream or a JSON string). This process is called serialization. When the receiver receives the serialized data, it is necessary to restore it to the original data object according to certain rules and formats. This process is deserialization. Preferably, the deserialization method used: deserialization based on binary protocol: such as Protocol Buffers, MessagePack, etc., deserialization based on text protocol: such as JSON, XML, YAML, etc., deserialization based on object model: such as Java's Serializable interface, Python's Pickle module, etc. In this application, the server uses a deserialization method to parse the received data frame, indicating that the data frame is transmitted in a certain serialization format (such as binary or JSON). The server needs to select an appropriate deserialization method according to the serialization format of the data frame, restore the original data object, and extract the monitoring data such as temperature, humidity, and CO2 concentration therein.
[0052] Another aspect of the embodiments of this specification also provides a management system for executing a management method of the present application. Data acquisition module: collects data such as temperature, humidity, and CO2 concentration of the indoor environment through the LoRa WAN wireless sensor network. The sensor nodes regularly measure environmental parameters and package the data and send them to the LoRa WAN gateway. The gateway receives the data packets of the sensor nodes, caches and splices them according to the packet sequence number, and restores the original data frame. Data parsing module: receives the original data frame spliced by the gateway, parses it using the deserialization method, identifies the position and length of different fields in the data frame, extracts environmental parameter values such as temperature, humidity, and CO2 concentration, associates the parsed environmental parameter values with the corresponding timestamps, and converts them into JSON format. Data storage module: stores environmental monitoring data in JSON format in a relational database, designs a reasonable data table structure and index, optimizes data insertion, update, and query performance, and regularly backs up and restores the database to ensure data security and availability. Data analysis module: reads environmental monitoring data in JSON format from a relational database and imports it into a data analysis platform, such as a server. It uses the Apriori association rule mining algorithm to discover frequent item sets and association rules between parameters such as temperature, humidity, and CO2 concentration. It uses the K-means time series clustering algorithm to identify typical patterns and evolution trends of environmental states, and visualizes the results of data analysis (association rules, clustering results, etc.) to support interactive exploration. Prediction and decision module: builds a prediction model for environmental states based on association rules and clustering results. When new environmental monitoring data arrives, it uses the prediction model to determine the current environmental state and future change trends. Based on the prediction results and preset threshold rules, it automatically generates decision suggestions for environmental control (such as adjusting the air conditioning temperature, starting the fresh air system, etc.), and sends the decision suggestions to the system's control module to achieve adaptive adjustment of environmental parameters. Control execution module: Receives the control instructions generated by the prediction and decision module, converts them into control instructions that the system can recognize, sends the control instructions to the corresponding execution equipment (such as air conditioners, fresh air units, etc.) through the system's communication protocol (such as BACnet, Modbus), monitors the status feedback of the execution equipment, ensures that the control instructions are correctly executed, and records the log data of the control process for subsequent analysis and optimization. Human-computer interaction module: Provides a Web interface to display the real-time status and historical trends of environmental monitoring data, presents the results of data analysis in the form of dashboards, curves, heat maps, etc., to facilitate intuitive understanding by managers, provides alarm management functions, automatically issues notifications when environmental parameters exceed the threshold, and records the processing process, supports mobile terminal access, and realizes system monitoring and control anytime and anywhere.
[0053] 3. Beneficial effects
[0054] Compared with the prior art, the advantages of this application are:
[0055] An adaptive spread spectrum modulation mechanism is introduced during the data transmission process. The optimal spread spectrum factor is dynamically selected through channel quality evaluation, and the time-frequency two-dimensional characteristics of the spread spectrum data are extracted by orthogonal transformation, which reduces the correlation between data copies, reduces transmission redundancy, and improves the spectrum efficiency of data transmission. At the same time, the adaptive configuration of multi-dimensional RF parameters enhances the system's adaptability to complex wireless environments and ensures the reliability of data transmission;
[0056] By deploying edge computing nodes at the LoRa gateway, the monitoring data received by the gateway is processed locally using anomaly detection algorithms, and key data is screened out for uploading, reducing the amount of data and transmission load. In addition, local processing of data also shortens the response delay of anomaly detection, enabling the system to respond to sudden anomalies in a timely manner;
[0057] Adaptive spread spectrum modulation can dynamically reduce the spread factor according to channel conditions, reduce data packet transmission time, and reduce terminal equipment transmission power and energy consumption. In addition, transmitting only critical data also simplifies the data packet structure, reduces the length of the data packet, and further reduces transmission power consumption. Edge anomaly detection indirectly reduces communication energy consumption by reducing the amount of data uploaded. A multi-pronged approach extends the network lifetime;
[0058] A local storage module is set up in the terminal device, and a circular queue is used to cache offline data, ensuring that monitoring data is not lost during network interruptions. At the same time, the two-way communication mechanism can accurately track the network status and automatically trigger the upload of cached data after communication is restored, ensuring data continuity and integrity;
[0059] Through machine learning algorithms, we deeply analyze monitoring data, train association rule mining models and cluster prediction models, learn the association rules between different environmental parameters and the evolution trend of environmental states, and provide optimization strategies for intelligent greenhouse environment control. Confidence sorting makes association rules easier to interpret, and cluster label mapping makes prediction results more intuitive, enhancing the usability of analysis results. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 is an exemplary flow chart of a management method according to some embodiments of this specification;
[0061] Figure 2 is an exemplary flow chart of generating a spread spectrum modulated data frame according to some embodiments of this specification;
[0062] Figure 3 is an exemplary flow chart of obtaining physical layer radio frequency configuration parameters according to some embodiments of this specification;
[0063] Figure 4is an exemplary flow chart of data transmission according to some embodiments of this specification;
[0064] Figure 5 This is an exemplary flow chart for obtaining an association rule list and predicting a room temperature environment state according to some embodiments of this specification. DETAILED DESCRIPTION
[0065] The method and system provided by the embodiments of this specification are described in detail below with reference to the accompanying drawings. Figure 1 As shown in the figure, the building automatic control system includes multiple wireless temperature and humidity recorders, several wireless CO2 concentration recorders, a LoRa WAN wireless gateway, an edge computing node, a server and a system management platform. The recorders are deployed in different areas of the building to collect temperature, humidity and CO2 concentration data in the area; the LoRa WAN wireless gateway is located in the center of the building and is responsible for receiving the monitoring data sent by all recorders; the edge computing node is connected to the LoRa WAN wireless gateway to pre-process the received data; the server communicates with the LoRa WAN wireless gateway via Ethernet, summarizes all monitoring data and performs intelligent analysis; the system management platform can run on the server and provide a human-computer interaction interface.
[0066] Wireless temperature and humidity recorders and wireless CO2 concentration recorders distributed in different areas collect their own monitoring data regularly. The built-in sensor of the recorder converts the collected analog signal into digital quantity and stores it in the data buffer with the timestamp. A total of 100 wireless temperature and humidity recorders and 50 wireless CO2 concentration recorders are deployed in the building. The wireless temperature and humidity recorder collects temperature and humidity data every 5 minutes, and the wireless CO2 concentration recorder collects CO2 concentration data every 10 minutes. Taking the wireless temperature and humidity recorder as an example, its built-in SHT30 temperature and humidity sensor is connected to the STM32L073 microcontroller through the I2C interface. After each measurement, the sensor converts the analog voltage value of temperature and humidity into digital quantity and transmits it to the microcontroller through the I2C bus. The internal clock of the microcontroller obtains the current timestamp, packages the timestamp and temperature and humidity data into a structure, and stores it in a 1KB ring buffer. When the ring buffer is full or reaches a 5-minute transmission cycle, the recorder sends the data frame in the buffer through the LoRa module. Assume that the temperature data collected by the recorder is 25.6℃ and the humidity data is 63.8%RH. Before transmission, the recorder first evaluates the quality of the LoRa channel. The process is as follows: The LoRa module detects three indicators in real time, including the signal-to-noise ratio SNR, channel gain Gain, and packet error rate PER, and calculates the current channel quality index CQI. For example, if the SNR is -9dB, the Gain is 125dB, and the PER is 1%, then CQI = 0.6.
[0067] The recorder loads the pre-trained neural network model, the model input is CQI, and the output is the optimal spreading factor SF. Assume that the model structure is "3-10-5-1", the input layer has 3 neurons receiving SNR, Gain, PER, the hidden layer has 10 neurons and 5 neurons, and the output layer has 1 neuron giving SF. The model is trained based on the quantile regression loss function, the quantile rate is set to 0.7, and when CQI = 0.6, the model outputs the optimal SF = 9. The recorder sends SF = 9 to the physical layer of the LoRa module, and the physical layer adjusts the spreading factor in the CSS modulation mechanism accordingly, encodes 9 bits in the original spreading sequence into 1 symbol, and the duration of each symbol increases accordingly. The physical layer also adjusts other RF parameters, such as bandwidth BW = 125kHz, coding rate CR = 4 / 5, and transmission power Ptx = 19dBm, to form a configuration parameter set.
[0068] The physical layer loads the adjusted RF parameters to the SX1278 RF chip and controls the SX1278 to send data packets through the SPI interface. The recorder fills 25.6℃ and 63.8%RH into the payload field of the data frame, and adds the synchronization word, source address, CRC check code and other fields to form a complete frame structure. SX1278 performs spread spectrum modulation on the data frame. When SF=9, 1 symbol contains 9 bits, so the data frame is expanded to 9 times the original length. After spreading, SX1278 performs QPSK modulation on the code chip and maps the code chip to 4 constellation points in the complex plane. The modulation result is converted into an analog signal through DAC and transmitted by the RF front end with a center frequency of 470MHz. The data frame sent by the temperature and humidity recorder is transmitted to the nearby LoRa WAN gateway through the LoRa spread spectrum channel. The gateway receives the demodulated data and forwards it to other nodes in the building network for further processing. Similar to the recorder, the gateway can also dynamically adjust RF parameters such as the spreading factor to match the transmission configuration of the recorder and improve the receiving sensitivity.
[0069] The wireless CO2 concentration recorder collects CO2 concentration of 800ppm, packages it into a 32-byte data frame, and sends it out through the LoRa module. Before sending, the recorder first evaluates the quality of the LoRa channel. The process is as follows: The LoRa module wakes up every 10ms to monitor the channel. Assume that a beacon frame is received during a wake-up. According to the reference signal in the beacon frame, SNR = -11dB and Gain = 127dB are measured. The module fills SNR and Gain into the input matrix X: X = [-11127]. The input matrix X is sent to the neural network model. The model structure is: 2 neurons in the input layer, 8 neurons in the hidden layer, and 1 neuron in the output layer. The activation function is sigmoid. The model weight matrices W1, W2 and bias vectors b1, b2 are as follows: W1 = [0.10.2; 0.30.4; 0.50.6; 0.70.8; 0.91.0; 1.11.2; 1.31.4; 1.51.6], b1 = [0.01; 0.02; 0.03; 0.04; 0.05; 0.06; 0.07; 0.08], W2 = [1.7; 1.8; 1.9;
[0070] 2.0; 2.1; 2.2; 2.3; 2.4], b2 = 0.09. Multiply the input matrix X by the weight matrix W1, and add the bias vector b1 to get the hidden layer input: H_in = X*W1+b1 = [-11127]*[0.10.2; 1.51.6]+[0.01; 0.08] = [-1.125.4;
[0071] -16.5190.4]+[0.01;0.08]=[-1.0925.41;-16.43190.48]. The hidden layer input H_in is activated by sigmoid to obtain the hidden layer output H_out: H_out=sigmoid(H_in)=1 / (1+e^(-H_in))=[0.25060.9999;0.00001.0000]. Multiply the hidden layer output H_out by the weight matrix W2, add the bias b2, and then activate it through sigmoid to get the output layer result: O_in = H_out*W2+b2 = [0.25060.9999; 0.00001.0000]*[1.7; 2.4]+0.09 = 9.8395O = sigmoid(O_in) = sigmoid(9.8395) = 0.9999, the output layer result 0.9999 is close to 1, corresponding to the spreading factor SF = 10. Therefore, the neural network model gives the optimal spreading factor SF = 10 when SNR = -11dB and Gain = 127dB. The recorder sends SF=10 to the physical layer of the LoRa module, and the physical layer adjusts the chirp baseband signal parameters accordingly. The specific steps are as follows: The nominal parameters of the chirp baseband signal of the physical layer are: chirp duration T_chirp=1ms, frequency offset F_chirp=10kHz. The spreading factor SF=10 means that 1 symbol corresponds to 10 bits, so 1 chirp signal is extended to 2^(10-6)=2^4=16 symbol periods. The physical layer extends the chirp duration T_chirp by 16 times to 16ms; at the same time, it reduces the frequency offset F_chirp to 1 / 16 of the original, to 625Hz. The physical layer generates a 16ms chirp baseband signal, which is linearly swept from -10kHz to +10kHz, with a frequency-time slope of 1.25MHz / s. The sweep period is 16ms, and each period corresponds to 10bits, which is consistent with SF=10. The modulated chirp signal is a new baseband signal matching the optimal spreading factor SF=10.
[0072] The wireless temperature and humidity recorder collects the temperature of 25.6℃ and the humidity of 63.8%RH, packages them into a data frame, and sends them through the LoRa module. When the physical layer performs spread spectrum modulation, it must first preprocess the original data. The steps are as follows: The physical layer receives the temperature of 25.6℃ and the humidity of 63.8%RH and quantizes them into 16-bit fixed-point numbers. The temperature of 25.6℃ corresponds to 0011001010100000 in binary, and the humidity of 63.8%RH corresponds to 0100000001001110 in binary. The two 16-bit data are spliced head to tail to form a 32-bit payload data. For this 32-bit payload data, the physical layer must copy it 16 times to generate 16 copies with different frequency offsets. The copying process is: multiply the payload by a 16-bit frequency offset vector, and the offset vector is [0, 1, 2, ..., 15]. The product result is 16 offset payload copies, each copy is still 32 bits long, but the starting frequency is different, and the frequency difference between adjacent copies is the frequency resolution of the chirp baseband signal, that is, 625Hz. Next, the 16 payload copies are orthogonally transformed with the chirp baseband signal. The chirp baseband signal is a 16ms linear frequency modulation signal with a frequency of -10k to +10kHz, with a total of 10 symbol periods. One symbol period corresponds to one orthogonal basis, and each orthogonal basis is also a chirp signal, but the frequency range is different, which is [-10k, -8k], [-8k, -6k], ..., [8k, 10k]. The orthogonal bases are orthogonal to each other, satisfying <basis i, basis j> = 0. The physical layer performs inner products on the 16 payload copies and the 10 orthogonal bases one by one, multiplies the corresponding bits and then accumulates them to obtain a 16x10 transformation coefficient matrix. The elements of this matrix are the projection coefficients of the replicas on each orthogonal basis, indicating the size of the components of the original signal in the direction of the orthogonal basis. This process maps the payload replicas from the time domain to the transform domain based on the orthogonal basis. In the transform domain, 16 payload replicas are converted into 16x10=160 orthogonal components, each of which is a complex number and occupies 2 32-bit floating point numbers. The total amount of information is 160x2x32=10kbit, which is 10 times the original payload and coincides with the spreading factor SF=10. These 160 components form a complete subspace of the payload data in the transform domain, with a dimension of up to 32 dimensions. At this point, the physical layer has completed the spread spectrum preprocessing of the original temperature and humidity data, copied it to generate a frequency-shifted replica, and realized the mapping from the time domain to the transform domain subspace through the inner product operation with the orthogonal chirp basis. This preprocessing will significantly increase data redundancy and reduce spectrum utilization, but it will greatly improve anti-interference, so that it can still ensure reliable transmission under harsh channels.
[0073] The physical layer extracts 32 orthogonal components from the transform domain subspace, each of which is a complex number in the form of a+bj. The 32 components are split into two groups according to the real part and the imaginary part, and sent to the I path and Q path respectively. The I path contains 32 real parts, and the Q path contains 32 imaginary parts. The 32 real parts of the I path are phase rotated, and the rotation angle is θ, and the initial value θ=45°. The real part after rotation is a'=a×cosθ+b×sinθ. The 32 imaginary parts of the Q path are phase rotated, and the rotation angle is θ+90°. The imaginary part after rotation is b'=-a×sinθ+b×cosθ. Phase rotation is equivalent to coordinate transformation around the unit circle on the complex plane, and θ is the angle between the I axis and the new I' axis. When θ=45°, the I' axis and the Q' axis are 90°, indicating that the I path and the Q path are orthogonal and the power is divided in half.
[0074] Take a' for I path and multiply it by the cos function to get the baseband signal I(t) = a' × cos(2πft); take b' for Q path and multiply it by the sin function to get the baseband signal Q(t) = b' × sin(2πft). Where f is the frequency, which sweeps from -10kHz to +10kHz within the 16ms chirp signal period. I(t) and Q(t) are orthogonal, and after addition, they are the QPSK modulated signal S(t) = I(t) + Q(t) after spread spectrum, presenting 32 constellation points on the complex plane. The physical layer mixes S(t) with the RF carrier signal C(t) = cos(2πfct), and fc = 470MHz is the center frequency of the LoRa channel. The mixing result is S(t) × C(t), the spectrum is around 470MHz, and the bandwidth is the same as S(t). The signal power after mixing is the product of S(t) power and C(t) power. In order to adjust the transmission power, the signal needs to be attenuated at the RF front end. The physical layer uses a table lookup method to map SF=10 to 2dB RF attenuation. Then write the attenuation into the RF attenuation register of the SX1278 chip, and change the transmission power through the variable gain amplifier. Other RF parameters are configured as follows: channel frequency register = 470MHz, phase compensation register = 45°, receive gain register = 127dB. The physical layer uses a string of configuration instructions through the SPI port to write all the above parameters into the register group of SX1278. SX1278 starts to send, continuously modulating 32 QPSK constellation points onto the carrier, each constellation point lasts 16ms, and the total transmission time is 32x16=512ms. After the transmission is completed, SX1278 waits for the receiving window period. If the ACK confirmation frame is not received within 1s, it will retransmit twice. The SX1278 chip of the receiving node receives the signal according to the same RF parameter configuration, demodulates the QPSK signal S(t), and then uses the local chirp signal C(t) for correlation calculation to obtain 32 correlation peaks, and the peak positions correspond to 32 constellation points. According to the constellation points, 32 spread spectrum copies are determined, spliced into 16 payload copies, and then converted to the final 25.6℃ and 63.8%RH.
[0075] The wireless temperature and humidity recorder collects environmental data and reports it to the cloud platform through the LoRa module. During the reporting process, if the LoRa channel is interrupted, the recorder will temporarily store the monitoring data locally and upload it in batches after the channel is restored. The detailed process of local storage and uploading is as follows: The recorder collects temperature and humidity data once every 1 minute. The temperature sensor outputs a current signal of 420mA, and the humidity sensor outputs a voltage signal of 0.10V. The 16-bit ADC inside the recorder converts the temperature current into a digital value of 065535, corresponding to -40100℃; and converts the humidity voltage into a digital value of 065535, corresponding to 0.100%RH. The conversion result shows that the sampling temperature is 25.6℃ (64153) and the humidity is 63.8%RH (41538). The MCU adds the Unix timestamp 1654952465 of the sampling time to the temperature and humidity data, and then adds the 2-byte data type identifier 0x0002 (indicating temperature and humidity), generating a 12-byte data frame: |Timestamp (4B)|Type (2B)|Temperature (2B)|Humidity (2B)|, |1654952465|0x0002|64153|41538|. The recorder writes the data frame into the buffer. The buffer size is 4KB, which can accommodate about 340 data frames. The buffer uses sequential reading and writing to ensure the timing between frames. When the buffer is full, all data frames are written into a storage page of the Flash. The Flash reads and writes blocks in 4KB pages, and the 64MB capacity can provide 16384 storage pages.
[0076] The recorder uses a circular queue to manage the storage pages in Flash. The queue capacity is set to 16384, corresponding to the number of storage pages. The queue uses the page number as an index, and the storage structure is: struct Page{uint8_t data
[4096] ; / / 4KB page data, uint32_t time stamp; / / timestamp of the first frame in the page, bool valid; / / Is the page valid}queue
[16384] ; The recorder uses the read pointer rdPtr and the write pointer wr Ptr to maintain the synchronization of the circular queue. After writing the buffer to Flash, the recorder performs the following operations: queue[wr Ptr].data=BUFFER; / / Copy the buffer data to the current write page, queue[wr Ptr].timestamp=now(); / / Record the starting timestamp of the current page, queue[wr Ptr].valid=true; / / Mark the current page as valid, wr Ptr=(wr Ptr+1)%16384; / / The write pointer moves forward by 1 page, and overflow returns to 0. When the LoRa channel is restored, the recorder receives the upload command from the gateway and starts uploading local data in batches. The following operations are performed during uploading: while (rd Ptr! = wr Ptr) {if (queue [rdPtr]. valid) { / / Is the page where the read pointer is located valid, upload (queue [rdPtr]. data); / / Upload the current page data, queue [rd Ptr]. valid = false; / / Mark the uploaded page as invalid}, rd Ptr = (rdPtr + 1)% 16384; / / The read pointer moves forward by 1 page,}. During uploading, the recorder reads the page where the read pointer is located in a whole block, extracts multiple data frames, and assembles them into a large package for uploading. After the upload is successful, the page is marked as invalid, and the read pointer moves forward. When the read pointer catches up with the write pointer, the upload is completed. To avoid the write pointer from overwriting the unuploaded page after rewinding, the recorder sets an upload threshold. When the number of unuploaded pages exceeds the threshold (such as 1024), the loop write is stopped and the new data in the buffer is discarded until the upload is completed and normal is restored. This frame loss mechanism ensures the continuity of data timing, and older data is uploaded first.
[0077] The LoRa module of the gateway works in receiving mode and monitors the 868MHz frequency band. When a recorder sends data, the gateway receives a series of RF packets, each of which carries the source address and packet sequence number of the recorder. The gateway classifies the packets according to the source address, and the packets from different recorders are stored in different receiving buffers. For the packets of the same recorder, the gateway arranges them from small to large according to the packet sequence number and verifies the integrity of the packets one by one. After all the packets are verified, the gateway splices their payload parts according to the sequence number to restore a complete data frame. The data frame contains metadata such as the recorder ID, timestamp, data type, data length, and actual monitoring data.
[0078] The gateway forwards the restored data frame to the edge computing node in real time. The MQTT protocol is used for forwarding, and the data frame content is published as an MQTT message to the specified topic. The edge node subscribes to the relevant topic, receives the data frame, and parses and processes it according to the metadata. For example, the data type determines whether the frame carries temperature or humidity, and then extracts the actual monitoring value according to the data length. The recorder will turn off the radio frequency during the interruption, and the gateway cannot issue control commands at this time. In order to determine whether the recorder has resumed communication, the gateway broadcasts a downlink control message every 30 seconds. The control message carries the gateway's own ID, timestamp, and XOR checksum.
[0079] After receiving the control message, the recorder extracts the message content and performs an XOR operation, comparing the result with the checksum in the message. If the check is correct, the recorder considers that the communication has been restored and starts to prepare to upload the historical data stored locally. After the communication is restored, the recorder needs to upload the monitoring data stored locally during the interruption to the server. In order to avoid network congestion caused by uploading a large amount of data at one time, the recorder adopts a batch upload strategy. First, the recorder determines the data interval to be uploaded. Assuming that a total of 1000 data are stored in the Flash, each data occupies an average of 1KB, and the breakpoint of the last upload is the 300th data, then the 301st to 1000th data need to be uploaded this time, totaling 700KB. The recorder divides the 700KB data into several upload tasks, each task is responsible for uploading a continuous address interval. The task division granularity needs to balance transmission efficiency and real-time performance. Too large will result in a long single transmission time, and too small will result in excessive task management overhead. After testing, the recorder decided that each task is responsible for uploading 100 data, that is, 100KB. This way, the total upload volume of 700KB can be divided into 7 tasks. The task parameters are as follows:
[0080] Task Number Starting data number End data number Data length 1 301 400 100KB 2 401 500 100KB 3 501 600 100KB ... ... ... ... 7 901 1000 100KB
[0081] The address intervals of all tasks are connected from beginning to end, without duplication or omission. After generating the task table, the recorder sorts the tasks in order from small to large data numbers to ensure that the upload timing is consistent with the acquisition time. The recorder executes each upload task in sequence according to the task table. For the current task, the recorder reads the data of the corresponding interval from the Flash and packages it according to the frame format required by the LoRaWAN protocol. Since LoRa WAN has a limit on the size of a single frame, the recorder needs to split the 100KB task data into multiple fragments and send them in packets. The net load of each sub-packet does not exceed 51 bytes, plus a 13-byte frame header, and the total length does not exceed 64 bytes. The recorder generates all sub-packets of the current task in ascending order of sub-packet numbers.
[0082] The recorder sends the sub-packet to the gateway through the LoRa module, using the ALOHA random access method without occupying a fixed time slot. The gateway receives the sub-packet and processes it according to the process of step 1, and forwards the restored data frame to the server. After the server receives all the data frames belonging to the same task, it sorts them according to the timestamp in the frame and stores them in the database. When all the data frames of a task are uploaded, the server sends an ACK confirmation frame to the gateway, and the gateway forwards it to the recorder. After the recorder receives the ACK, it can be considered that the current task has been uploaded successfully and starts to execute the next task. If the ACK is not received for a long time, the recorder will retransmit the current task until the upload is successful or the maximum number of retries is reached. When all tasks are executed, the recorder clears the uploaded data in the Flash, releases the storage space, and frees up the buffer for subsequent data collection. At this point, all the historical data stored locally has been uploaded, and the recorder resumes normal working state. The edge node subscribes to the data forwarding topic of the gateway through the MQTT protocol. Whenever the gateway publishes a new data frame, the node will receive an MQTT message, and the message content is the original byte stream of the data frame. The node parses the various fields of the data frame according to the frame format definition:
[0083] Field Name Number of bytes illustrate Recorder ID 2 Unique ID of the recorder, used to distinguish the source of data Timestamp 4 The time when data was collected, in UNIX timestamp format Data Types 1 Indicates the type of monitoring data carried in the frame Data length 2 Indicates the number of bytes of monitoring data Monitoring data Indefinite length The actual monitoring value may contain multiple data items
[0084] The node determines whether the frame carries temperature, humidity or CO2 concentration based on the data type field. Taking temperature and humidity as an example, if the data type is 0x02, the first 2 bytes of the monitoring data field are temperature values, and the last 2 bytes are humidity values, both represented by 16-bit unsigned integers. The node arranges the parsed monitoring values in ascending order according to the acquisition time to form a data sequence. Each data point contains the recorder ID, timestamp, data type and monitoring value. The edge node performs anomaly detection on the parsed data sequence. The node presets a variety of detection algorithms, and you can choose the appropriate algorithm based on the data type and business requirements. The following are several common anomaly detection methods: Threshold method: Set a fixed upper and lower threshold, such as the normal range of temperature is -20℃ to 50℃. When the monitoring value exceeds this range, it is marked as abnormal. This method is simple and intuitive, and is suitable for monitoring indicators with clear specification limits. Change rate method: When the change rate of the monitoring value exceeds a certain threshold value, it is marked as abnormal. For example, the temperature cannot change by more than 5℃ per minute, otherwise it may be a sensor failure. This method focuses on anomalies that change dramatically in a short period of time. Trend method predicts the changing trend of monitoring values through moving average, exponential smoothing and other methods. When the difference between the actual value and the predicted value exceeds a certain range, it is marked as an anomaly. This method is good at detecting slowly accumulated anomalies. Outlier detection uses statistical or machine learning methods to establish a distribution model of normal data. When the new monitoring value deviates far from the normal model, it is marked as an anomaly. This method does not rely on a fixed threshold and has better adaptability to unknown anomalies. The node can combine multiple anomaly detection methods in series to form a complete set of anomaly judgment logic. The detection result can be attached to the original data and represented by an additional field. For example, 0 means normal, 1 means threshold anomaly, 2 means change rate anomaly, and so on.
[0085] The edge node uploads the data after anomaly detection to the server via Ethernet. The upload uses application layer protocols such as HTTP or MQTT, and the data is organized in JSON format. The upload message is as follows: {"recorder Id": 1001, "timestamp": 1654952465, "type": 2, "data": [25.6, 63.8], "anomaly": 0}. Among them, recorder Id, timestamp, type, and data correspond to the recorder ID, timestamp, data type, and monitoring data in the data frame respectively. Anomaly is a newly added anomaly mark field. After receiving the upload message, the server stores it in the time series database and indexes it according to the recorder ID and data type to facilitate subsequent query and analysis. The server can perform secondary confirmation on the abnormal data, and combine historical data and business rules to determine whether further processing is required, such as alarm notification, fault diagnosis, etc. The node uploads the cached data in batches once every certain period of time (such as 1 minute), instead of uploading it immediately every time a piece of data is generated, which can reduce the communication frequency and save network bandwidth. In the entire data processing process, the edge computing node plays a connecting role. It converts the original data stream of the LoRa gateway into structured data that is easy to understand and analyze through protocol analysis and data cleaning; at the same time, it uses the advantages of local computing to perform anomaly detection at the source of the data, filter out dirty data with obvious errors, and reduce the processing burden of the server.
[0086] The server receives monitoring data from the recorder through the LoRa WAN gateway. Due to the single frame length limit of LoRaWAN, the complete monitoring data is divided into multiple data packets and sent in sequence. The server caches the received data packets into the receiving buffer in the order of the packet sequence number. At the same time, the server records the maximum packet sequence number currently received. If no new packet is received for a certain period of time (such as 1 second) and the maximum packet sequence number does not change, it is considered that the current data frame has been received. The server sorts all the data packets in the buffer from small to large according to the packet sequence number, and splices their payload parts to restore the complete original data frame.
[0087] The server parses the received raw data frame. The data frame uses binary encoding format, and different data fields occupy different bits. For example, the temperature field occupies 16 bits, the humidity field occupies 16 bits, the CO2 concentration field occupies 32 bits, and the timestamp field occupies 32 bits. The server uses the deserialization method according to the predefined frame format to identify the starting position and length of each field in the data frame, and converts it to the corresponding data type to extract the actual monitoring value and timestamp. The server converts the extracted monitoring value and timestamp into a data record in JSON format. The JSON record is as follows: {"timestamp": 1654952465, "temperature": 25.6, "humidity": 63.8, "CO2": 834}. The server inserts the data record in JSON format into a relational database (such as MySQL), and each monitoring indicator corresponds to an independent data table. The primary key of the data table is the timestamp, and it also includes fields such as recorder ID and monitoring value.
[0088] The server exports the monitoring data in the database to the server software regularly (for example, at dawn every day), and uses its built-in machine learning algorithm library for data mining and trend analysis. The server reads historical monitoring data from the relational database and converts it into a transaction data format suitable for association rule mining. A transaction represents the combination of all monitoring indicators collected at a certain point in time. The system collects data every 10 minutes. A typical transaction is as follows:
[0089] 11654952400{temperature=25.6, humidity=63.8, CO2=834}
[0090] 21654953000{temperature=26.1, humidity=62.5, CO2=852}
[0091] 31654953600{temperature=25.9, humidity=64.1, CO2=841}
[0092] For the convenience of analysis, the server discretizes the continuous monitoring indicators and converts them into categorized data. For example, the temperature can be divided into three intervals: "low temperature (<20℃)", "normal temperature (20~30℃)", and "high temperature (>30℃)", the humidity can be divided into three intervals: "dry (<40%)", "comfortable (40%~70%)", and "humid (>70%)", and the CO2 concentration can be divided into two intervals: "normal (<1000ppm)" and "abnormal (>=1000ppm)". The discretized transaction data is as follows:
[0093] 11654952400{temperature=normal, humidity=comfortable, CO2=normal}
[0094] 21654953000{temperature=normal, humidity=comfortable, CO2=normal}
[0095] 31654953600{temperature=normal, humidity=comfortable, CO2=normal}
[0096] The core of the Apriori algorithm is to find frequent item sets, that is, combinations of monitoring indicators that often appear in transactions at the same time. First, the algorithm scans the entire data set, counts the frequency of occurrence of each indicator, and calculates its support. The support represents the probability that an indicator or a combination of indicators appears in all transactions, and its calculation formula is: support(X)=count(X) / N. Among them, X represents an indicator or a combination of indicators, count(X) represents the number of times X appears in the data set, and N represents the total number of transactions. Assuming that there are 1,000 transactions in the data set, of which 800 transactions have a normal temperature, 700 transactions have a comfortable humidity, and 900 transactions have a normal CO2 concentration, then the support of these three indicators is: support(temperature=normal)=800 / 1000=80%, support(humidity=comfortable)
[0097] =700 / 1000=70%, support(CO2=normal)=900 / 1000=90%. The Apriori algorithm sets a minimum support threshold, filters out indicators with support below the threshold, and obtains a one-dimensional frequent item set. For example, if the minimum support is 60%, the above three indicators are all frequent. Then, the algorithm uses the one-dimensional frequent item set to generate a two-dimensional candidate item set, that is, a pair of indicators that are combined in pairs. For example, temperature and humidity can be combined into {temperature=normal, humidity=comfortable}, temperature and CO2 concentration can be combined into {temperature=normal, CO2=normal}, and humidity and CO2 concentration can be combined into {humidity=comfortable, CO2=normal}. Next, the algorithm scans the data set, counts the support of each two-dimensional candidate item set, filters out infrequent item sets, and obtains a two-dimensional frequent item set. And so on, it continuously iterates to generate higher-dimensional candidate item sets and frequent item sets until no new frequent item sets can be generated. The support of {temperature=normal,humidity=comfortable} is 65%, the support of {temperature=normal,CO2=normal} is 75%, and the support of {humidity=comfortable,CO2=normal} is 68%. These three two-dimensional itemsets are all frequent. Furthermore, assuming that the support of {temperature=normal,humidity=comfortable,CO2=normal} is 60%, this three-dimensional itemset is also frequent.
[0098] After obtaining all frequent item sets, the Apriori algorithm extracts strong association rules from them. An association rule is in the form of X=>Y, where X and Y are both frequent item sets, and This rule indicates that if a transaction contains X, it is very likely to also contain Y. The strength of an association rule is measured by confidence. Confidence indicates the probability that a transaction containing X also contains Y, and its calculation formula is: confidence(X=>Y)=support(X∪Y) / support(X). For the rule {temperature=normal, humidity=comfortable}=>{CO2=normal}, its confidence is: confidence=support({temperature=normal, humidity=comfortable, CO2=normal}) / support({temperature=normal, humidity=comfortable})=60% / 65%=92.3%. This means that when the temperature is normal and the humidity is comfortable, the probability that the CO2 concentration is normal is as high as 92.3%. The Apriori algorithm sets a minimum confidence threshold and filters out association rules with confidence below the threshold. For example, if the minimum confidence is 80%, the above rule is a strong association rule. Finally, the server outputs all association rules that meet the minimum support and minimum confidence requirements, and sorts them from high to low according to confidence. These rules reveal the inherent connections and mutual influences between different monitoring indicators, providing an important reference for environmental management.
[0099] Through analysis, we found the following strong association rules:
[0100] {temperature=normal, humidity=comfortable}=>{CO2=normal}, confidence=92.3%, {temperature=normal}=>{CO2=normal}, confidence=88.9%,
[0101] {humidity=comfortable}=>{CO2=normal},confidence=85.7%. These rules show that there is a close correlation between the three indicators of temperature, humidity and CO2 concentration. In an environment with suitable temperature and comfortable humidity, the CO2 concentration is often at a normal level. This provides a new idea for formulating environmental control strategies: we can indirectly optimize the CO2 concentration by adjusting the temperature and humidity without directly controlling the ventilation system, thereby saving energy and reducing costs. In addition, if an area has an association rule such as {temperature=high,humidity=dry}=>{CO2=abnormal} for a long time, it means that high temperature and dryness may lead to an increase in CO2 concentration, which needs to be taken seriously. Managers should check air conditioning and ventilation equipment in a timely manner, eliminate hidden faults, and add green plants when necessary to improve indoor air quality.
[0102] The server reads historical monitoring data from the relational database and converts it into a data format suitable for time series clustering. In order to capture the dynamic changes of environmental conditions, the server divides the data according to fixed time windows (such as 1 hour), and each time window forms a multivariate time series segment. The system collects data every 10 minutes. A time window contains 6 consecutive sampling points. Each segment represents the changing trajectory of the indoor environment within an hour. The similarity between different segments reflects the differences in the indoor environment at different times. The K-means algorithm clusters time series segments based on similarity. The server uses Euclidean distance to measure the similarity between two segments. The smaller the distance, the more similar the two segments are, and the larger the distance, the more different the two segments are. Two time series segments X and Y, their temperature, humidity, and CO2 concentration sequences are: X: temperature = [Tx 1 ,Tx 2 ,......,Tx n ],humidity=[Hx 1 ,Hx 2 ,......,Hx n ], CO2=[Cx 1 ,Cx 2 ,......,Cx n ],Y:temperature=[Ty 1 ,Ty 2 ,......,Ty n ],humidity=[Hy 1 ,Hy 2 ,......,Hy n ], CO2=[Cy 1 ,Cy2 ,......,Cy n ]. Where n is the sequence length, that is, the number of sampling points contained in each time window. Then the Euclidean distance between X and Y is:
[0103] The goal of the K-means algorithm is to divide all time series segments into K clusters, so that the segments within the same cluster are as similar as possible, and the segments between different clusters are as different as possible. K is a pre-specified parameter indicating the number of clusters.
[0104] The algorithm first randomly selects K fragments as the initial cluster centers, and then repeats the following process until the clustering results converge: for each fragment, calculate its Euclidean distance with the K cluster centers, and divide it into the cluster with the nearest cluster center. For each cluster, recalculate its cluster center. The cluster center is the mean of all fragments in the cluster, that is, a new time series fragment obtained by taking the average value of temperature, humidity, and CO2 concentration at each sampling point. All fragments are divided into 4 clusters. After multiple rounds of iterations, the following clustering results are obtained: temperature1 = [22.3, 22.1, 22.0, 21.8, 21.9, 22.2], humidity = [33.5, 33.2], CO2 = [Fragment1082, Fragment726]. temperature2=[29.6, 29.8, 30.1, 30.3, 30.0, 29.9], humidity=[79.2, 80.5,], CO2=[Fragment935, Fragment1726,]. temperature3=[25.8, 25.6, 25.7, 25.9, 26.1, 26.0], humidity=[65.8, 66.2], CO2=[Fragment284, Fragment692,]. empire4=[24.5, 23.8, 23.2, 22.7, 23.5, 24.1], humidity=[46.3, 44.9,], CO2=[Fragment1483, Fragment2058,]. From the cluster center, we can see that the four clusters represent the following environmental modes: Cluster 1: Winter low temperature and dry type, the temperature is about 22℃, and the humidity is about 33%. Cluster 2: Summer high temperature and humid type, the temperature is about 30℃, and the humidity is about 80%. Cluster 3: Normal temperature and suitable humidity type, the temperature is about 26℃, and the humidity is about 65%. Cluster 4: Transitional seasonal fluctuation type, the temperature fluctuates between 23-25℃, and the humidity is about 45%. Different environmental modes correspond to different air conditioning control strategies. For example, for the summer high temperature and humid type, the air conditioning temperature should be set to below 26℃, and the dehumidification mode should be turned on; for the winter low temperature and dry type, the air conditioning temperature should be set to above 24℃, and the humidification mode should be turned on; for the transitional seasonal fluctuation type, natural ventilation should be used to minimize the use of air conditioning to save energy.
[0105] During real-time monitoring, the server divides the latest collected data point into the cluster with the nearest cluster center, and uses the environmental mode of the cluster as the current prediction result. The current temperature is 29.2℃, the humidity is 78.6%, and the CO2 concentration is 1012ppm, so it is most likely to be classified into Cluster2, indicating that the current environment belongs to the hot and humid summer type. The server will immediately issue an early warning on the Web interface, prompting the user to lower the air conditioning temperature in time, turn on the dehumidification function, and pay attention to heatstroke prevention and cooling. If the prediction results of multiple consecutive time windows fall into abnormal clusters, such as the temperature is above 30℃ for a long time, or the humidity is above 80% for a long time, it indicates that the indoor environment has seriously deviated from the normal state, and there may be problems such as air conditioning failure and pipeline leakage. At this time, the server will send a high-level alarm to the management personnel, suggesting that someone be sent to the site for investigation immediately. If necessary, the emergency plan can be activated to evacuate indoor personnel to prevent safety accidents.
[0106] The server uploads the mined association rules and clustering results to the system management platform. The platform presents the analysis results in an intuitive chart format. For example, it can generate temperature and humidity curves, CO2 concentration curves, energy consumption curves, etc. for each area, and mark abnormal points and key events. Managers can view the environmental status and energy consumption level of the mall at any time through the Web interface or mobile APP to grasp the dynamic trend of changes. When it is found that the energy consumption of a certain area is significantly higher than the average level, or abnormal environmental parameters appear, the platform will automatically push alarm information to prompt managers to promptly investigate the cause and optimize equipment operation. Based on the prediction results of the server, the system platform can generate equipment control plans for a period of time in the future. For example, according to the temperature trend forecast for the next week, if the maximum temperature in the next three days will exceed 35°C, the platform will lower the temperature setting value of the air conditioner by 2°C one day in advance to cope with high temperature weather. If the weather is sunny and the illumination is sufficient during the day for the next five days, the platform will delay the opening time of the lighting system by 1 hour to save energy. These control instructions are sent to each building device through the LoRa WAN gateway to achieve closed-loop control.
Claims
1. A management method comprising: Collect temperature and humidity data of the target space through a wireless temperature and humidity recorder; Collect CO2 concentration data of the target space through a wireless CO2 concentration recorder; The collected temperature data, humidity data and CO2 concentration data are transmitted to the LoRa WAN wireless gateway through the LoRaWAN wireless channel; The LoRaWAN wireless gateway receives the collected data through the LoRaWAN protocol and forwards the received data to the edge computing node deployed on the gateway side; The edge computing node uses an anomaly detection algorithm to detect anomalies in the received data; the LoRaWAN wireless gateway uploads the anomaly detected data to the server via Ethernet; The recorder contains a local storage module to save the collected data when communication is interrupted; when communication is restored, the recorder transmits the data in the local storage module to the server through the LoRa WAN wireless gateway; Two-way communication is established between the LoRaWAN wireless gateway and the server based on the MQTT protocol; The server receives data transmitted by the LoRa WAN wireless gateway and uses machine learning algorithms to analyze and visualize the received data, obtain association rules and trends in the data, and perform device management; The collected temperature data, humidity data and CO2 concentration data are transmitted to the LoRaWAN wireless gateway through the LoRaWAN wireless channel, including: The channel quality index CQI is used to evaluate the channel quality of the LoRa WAN wireless channel to obtain a channel quality evaluation result; wherein the channel quality index CQI includes signal-to-noise ratio, channel gain and data packet error rate; Based on the machine learning algorithm, a nonlinear mapping relationship between the channel quality assessment result and the optimal spreading factor is established through a neural network model, and the optimal spreading factor is selected according to the quantile regression loss function; The selected optimal spreading factor is sent to the physical layer of the LoRa WAN wireless channel. The physical layer adjusts the CSS spreading modulation mechanism according to the received optimal spreading factor and generates the adjusted physical layer RF configuration parameters. Load the adjusted physical layer RF configuration parameters to the physical layer interface of the LoRa WAN wireless channel, use the adjusted CSS spread spectrum modulation mechanism to spread spectrum modulate the collected temperature data, humidity data and CO2 concentration data through the physical layer interface, and send the modulated data frame to the LoRa WAN wireless gateway through the LoRa WAN wireless channel; Generate adjusted physical layer RF configuration parameters, including: The physical layer adjusts the rate and frequency offset parameters of the chirp signal according to the optimal spreading factor, and generates a chirp baseband signal that matches the optimal spreading factor by extending or shortening the duration of a single chirp signal and increasing or decreasing the frequency offset gradient; The physical layer performs spread spectrum adjustment on the input temperature data, humidity data and CO2 concentration data, and generates multiple copies of spread spectrum data with different frequency offsets; The physical layer uses a set of orthogonal chirp bases corresponding to different spreading factors to perform orthogonal transformation on the spread data copy. Through the orthogonal transformation operation, the original chirp signal is mapped from the time domain to the transform domain subspace composed of the orthogonal chirp bases, and the conversion generates a set of orthogonal components corresponding to the chirp signal under different spreading factors. The physical layer outputs the multiple orthogonal components of the spread spectrum data after orthogonal transformation to two orthogonal branches, I and Q, for modulation; Among them, an orthogonal transformation is performed, including: Adopt fast Fourier transform FFT algorithm to speed up the orthogonal transformation process; The transformation matrix is constructed using Zadoff-Chu sequence as the orthogonal Chirp basis to minimize the interference between signals with different spreading factors. Generate adjusted physical layer radio frequency configuration parameters, including: The physical layer I / Q branch maps the input orthogonal components to the I path and the Q path to generate an I-path spread spectrum baseband signal and a Q-path spread spectrum baseband signal; Performing phase rotation on the I-channel spread spectrum baseband signal at a rotation angle of θ; performing phase rotation on the Q-channel spread spectrum baseband signal at a rotation angle of θ+90°; changing the power allocation of the I-channel and the Q-channel by adjusting the phase rotation angles θ of the I-channel and the Q-channel; The I-channel spread spectrum baseband signal and the Q-channel spread spectrum baseband signal that have undergone orthogonal phase rotation are subjected to orthogonal amplitude modulation to generate a QPSK signal by orthogonally superposing the modulated I-channel signal and the Q-channel signal; The generated QPSK signal is mixed with the RF carrier signal, and the baseband QPSK signal is up-converted to the RF carrier frequency to generate a channel frequency parameter; wherein the RF carrier frequency is determined by the channel frequency parameter of the physical layer of the LoRaWAN wireless channel; Converting the optimal spreading factor into a radio frequency attenuation control parameter; wherein the radio frequency attenuation control parameter includes a transmission power and a receiving gain of a radio frequency signal; The conversion into the radio frequency attenuation control parameter includes: using a closed-loop automatic gain control AGC algorithm, adjusting the transmission power and receiving gain by real-time monitoring the received signal strength indicator RSSI and the signal quality indicator SQI, and dynamically adjusting the radio frequency attenuation control parameter; The physical layer radio frequency configuration parameters are adjusted according to the obtained phase rotation angle θ, channel frequency parameters and radio frequency attenuation control parameters.
2. The management method according to claim 1, characterized in that: The recorder contains a local storage module to save the collected data when communication is interrupted, including: Convert the collected temperature data, humidity data and CO2 concentration data into digital quantities respectively; and send the digital quantities to the data buffer; Read digital quantities from the data buffer, add timestamps and data type identifiers, and combine them into data frames in the order of data acquisition; write the data frames into the local storage module; The local storage module manages the received data frames based on the FIFO circular queue, divides the storage space into several fixed-size storage pages, each storage page stores one frame of data, and the storage pages are organized into a circular queue in the order of increasing physical addresses. The circular queue contains a read pointer pointing to the first storage page in the queue and a write pointer pointing to the last storage page in the queue; Write the data frame to the end of the circular queue and point the write pointer to the next storage page.
3. The management method according to claim 2, characterized in that: The recorder contains a local storage module to save the collected data in case of communication interruption, and also includes: The buffer contains N buffer pages, where N is a positive integer greater than 2; When the buffer is full of data frames, the data frame in the earliest written buffer page is transferred to the storage page currently pointed to by the write pointer in the circular queue, and the write pointer of the circular queue is updated to the next storage page; Clear the earliest written buffer page for use in the next writing of data frames, and recycle the buffer pages.
4. The management method according to claim 3, characterized in that: When communication is restored, the recorder transmits the data in the local storage module to the server through the LoRaWAN wireless gateway, including: The XOR check algorithm is used to check the received LoRaWAN wireless gateway downlink control message and generate a check result; When the verification result is equal to the preset error-free value, it is determined that the LoRaWAN wireless communication has changed from the interruption state to the recovery state, and a data upload control instruction is generated, and the data upload control instruction includes an upload start flag and a timestamp; The local storage module stops the circular queue from storing the data in a circular manner according to the data upload control instruction, and determines the first storage page and the last storage page corresponding to the data frame to be uploaded according to the timestamp; uses the starting address of the first storage page as the starting address of the data to be uploaded, and uses the ending address of the last storage page as the ending address of the data to be uploaded; Generate a data upload task table according to the obtained start address and end address of the data to be uploaded. The data upload task table consists of multiple upload tasks. Each upload task corresponds to an address interval. The address intervals of each upload task are continuous and non-overlapping. The upload tasks are organized in ascending order according to the starting addresses of the address ranges of the upload tasks to obtain the execution order of data upload.
5. The management method according to claim 4, characterized in that: When communication is restored, the recorder transmits the data in the local storage module to the server through the LoRa WAN wireless gateway, including: According to the execution order of data upload and the task table, read the data in the address range corresponding to the upload task from the local storage module; The read data is packetized using a fixed-length data frame, and multiple data packets are generated in the order of increasing packet numbers; ALOHA random access method is used to transmit data packets to the server through the LoRa WAN wireless gateway; When the upload task is completed, clear the uploaded data in the local storage module.
6. The management method according to claim 5, characterized in that: Obtain association rules and evolution trends in data, including: The server receives data packets through the LoRa WAN wireless gateway, and caches the data packets in sequence based on the packet sequence number until the data packet with the largest packet sequence number is received; the data packets are spliced in the order of the packet sequence number from small to large to obtain the original data frame; The obtained data frame is parsed using the deserialization method to identify the location and length of different data fields, and the temperature data, humidity data, CO2 concentration data, and corresponding timestamps in the data frame are extracted; Convert the extracted temperature data, humidity data, CO2 concentration data and timestamp into JSON format and store them in a relational database; The JSON format data stored in the relational database is used as input, and the Apriori association rule mining algorithm and K-means time series clustering algorithm in the machine learning algorithm are used to analyze the imported data; Among them, the Apriori association rule mining algorithm is based on support and confidence indicators, and adopts an iterative search method to obtain frequent item sets and association rules between temperature data, humidity data, and CO2 concentration data; the obtained association rules are arranged in reverse order according to the confidence index to generate an association rule list; The K-means time series clustering algorithm uses Euclidean distance as a similarity measure to perform cluster analysis on multivariate time series data consisting of temperature data, humidity data, and CO2 concentration data, and obtains K cluster centers that reflect the changing trend of room temperature environment status. The currently collected data points are divided into the clusters corresponding to the cluster centers with the closest Euclidean distance, and the room temperature environment state of the corresponding cluster is used as the prediction result at the current moment.
