Unmanned aerial vehicle temperature and humidity early warning method based on embedded optimization

By building and deploying a temperature and humidity prediction model based on a three-level lightweight optimization algorithm of Transformer on UAVs, combined with sensor change threshold configuration, interrupt triggering, and a lightweight database, the problems of insufficient prediction and high resource consumption in UAV temperature and humidity monitoring are solved, and efficient early warning and fault tracing are achieved.

CN121807000APending Publication Date: 2026-04-07CHINA ORDNANCE EQUIP GRP AUTOMATION RES INST CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610005648.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-05
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Existing drone-based temperature and humidity monitoring solutions lack an early intervention window, have insufficient prediction accuracy, consume excessive central processing unit resources, lack fault tracing capabilities, and cannot effectively deploy Transformer models on embedded platforms.

Method used

A temperature and humidity prediction model is constructed using a three-level lightweight optimization algorithm based on Transformer. The model is then deployed on a drone using a dual-strategy deployment algorithm that combines cloud training with embedded fine-tuning. Combined with sensor change threshold configuration, interrupt triggering, a lightweight database, and a three-level early warning mechanism, the model achieves data acquisition, preprocessing, and early warning.

Benefits of technology

It improves the model's generalization and prediction accuracy under different operating conditions, reduces the CPU utilization, has fault tracing capabilities, and enables rapid response and automatic flight control linkage, thus buying time for abnormal intervention.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121807000A_ABST
    Figure CN121807000A_ABST
Patent Text Reader

Abstract

The invention discloses an unmanned aerial vehicle temperature and humidity early warning method based on embedded optimization, and relates to the technical field of unmanned aerial vehicle safety, a temperature and humidity prediction model is constructed through a Transform three-level lightweight optimization algorithm, and the model is deployed on an unmanned aerial vehicle through a cloud training and embedded fine tuning dual-strategy deployment algorithm. Generalization and prediction precision of the model under different working conditions are improved, and the requirements of the unmanned aerial vehicle for model volume, reasoning speed and resource occupation are met; when the change degree of the sensing data exceeds the change threshold value of the sensor, temperature and humidity data are collected, and the occupancy rate of a central processing unit is reduced; then the temperature and humidity data are preprocessed, and the data quality is improved; and finally, a temperature and humidity prediction model is scheduled to perform multi-time-step prediction on the preprocessed temperature and humidity data, and a three-level early warning mechanism is adopted to perform unmanned aerial vehicle temperature and humidity early warning according to the predicted temperature and humidity and a temperature and humidity early warning threshold value, so that quick response is realized, and time is won for abnormal intervention.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of drone safety technology, specifically to a drone temperature and humidity early warning method based on embedded optimization. Background Technology

[0002] Currently, traditional monitoring solutions are the mainstream basic solutions in the field of drone temperature and humidity monitoring. Their core focus is on "real-time data acquisition and visualization". They are widely used in small and medium-sized drones with a takeoff weight of ≤10kg, especially in low-cost scenarios such as entry-level drones and short-duration test flights, where the proportion of this solution exceeds 80%.

[0003] From a software perspective, this solution only includes basic data processing and display functions: the data collected by the temperature and humidity sensors (such as DHT11, SHT20, BME280) on which the perception layer depends is transmitted to the main control unit via I2C or UART communication protocols. The software only performs data format conversion (converting hexadecimal data to "℃ / % RH" format) and then uploads it to the ground application via the flight control software development kit. Some solutions support displaying data on the local LCD screen, but there is no local data storage module or prediction module in the entire software system.

[0004] In terms of software workflow, the first step is initialization. After the drone is powered on, the software sends configuration information to the sensors through preset instructions, including setting a 1-second sampling interval and zero-point calibration parameters. Then, the data acquisition phase begins, where the software polls the sensors at fixed 1-second intervals and receives the 16-bit digital signals converted by the sensors. Next is data transmission, where the software controls the communication protocol to transmit the digital signals to the main controller at a rate of 100kHz. After that, real-time display is performed, where the software converts the data format and uploads it to the ground application. Some solutions can plot data curves for nearly 10 minutes. Finally, there is the passive response phase. The software only pops up an alarm in the ground application when the data exceeds a preset emergency threshold (such as battery compartment temperature > 65°C), which completely lacks the ability to predict in advance, resulting in insufficient time for staff to intervene when the alarm is triggered.

[0005] Traditional monitoring solutions suffer from significant software deficiencies: First, there is no early intervention window. The software can only complete the basic process of "real-time acquisition-upload-display," and cannot predict temperature and humidity trends. When the lithium battery compartment temperature rises at a rate of 0.5℃ / minute or the humidity of the flight control system suddenly increases, there is no buffer time before the anomaly is triggered, making it difficult to avoid thermal runaway or flight control failure. Second, the CPU resource consumption is too high. The 1Hz fixed polling acquisition method requires the CPU to continuously and periodically respond to sensor requests. Even if the temperature and humidity do not change, it still consumes computing power. During continuous operation, the CPU utilization rate exceeds 32%, severely crowding out resources for core software tasks such as flight control data processing and motor control. Third, there is no fault tracing capability. The software does not have a local data storage function and relies solely on the real-time transmission link. Once the drone crashes or the transmission is interrupted, it is impossible to retrieve the temperature and humidity change curves before the accident, making it difficult to locate the root cause of the fault. For example, it is impossible to determine whether the temperature surge preceded the humidity anomaly or the humidity anomaly preceded the temperature surge. Summary of the Invention

[0006] The purpose of this application is to provide a drone temperature and humidity early warning method based on embedded optimization, which solves the problems of existing technologies such as no buffer time, insufficient prediction accuracy, difficulty in adapting Transformer model to embedded software, and excessive software resource consumption.

[0007] This application is achieved through the following technical solution:

[0008] An embedded-optimized method for early warning of temperature and humidity in unmanned aerial vehicles (UAVs) includes:

[0009] A temperature and humidity prediction model is constructed using a three-level lightweight optimization algorithm based on Transformer, and then deployed on a drone using a dual-strategy deployment algorithm that combines cloud training with embedded fine-tuning.

[0010] Configure the sensor change threshold corresponding to the sensor on the UAV, and collect temperature and humidity data when the degree of change of the sensor data exceeds the sensor change threshold;

[0011] The temperature and humidity data are preprocessed using a mean-filling strategy, a 2σ criterion strategy for removing outliers, and a sliding window Min-Max normalization strategy to obtain preprocessed temperature and humidity data.

[0012] The temperature and humidity prediction model deployed on the UAV is scheduled to perform multi-time step predictions on the preprocessed temperature and humidity data to obtain the predicted temperature and humidity.

[0013] Read the pre-configured temperature and humidity warning thresholds, and use a three-level warning mechanism to issue temperature and humidity warnings for the UAV based on the predicted temperature and humidity and the temperature and humidity warning thresholds;

[0014] Among them, temperature and / or humidity refer to temperature and / or humidity.

[0015] In one possible implementation, a temperature and humidity prediction model is constructed using a three-level lightweight optimization algorithm of Transformer, including:

[0016] Pruning the Transformer model yields the pruned Transformer model.

[0017] The pruned Transformer model is then simplified and optimized to obtain a simplified and optimized Transformer model.

[0018] The simplified and optimized Transformer model is subjected to INT8 quantization to obtain the quantized Transformer model.

[0019] The quantized Transformer model is fused with custom operators to obtain the Transformer model after custom operator fusion, thus obtaining the temperature and humidity prediction model.

[0020] The custom operator fusion refers to encapsulating the position encoding operator, multi-head self-attention operator, and layer normalization operator in the quantized Transformer model into a single operator.

[0021] In one possible implementation, the temperature and humidity prediction model is deployed on a drone using a dual-strategy deployment algorithm that combines cloud training and embedded fine-tuning, including:

[0022] The temperature and humidity prediction model is trained in the cloud to obtain the pre-trained temperature and humidity prediction model.

[0023] The pre-trained temperature and humidity prediction model is sent to a drone equipped with an RK3588 chip, and the pre-trained temperature and humidity prediction model is fine-tuned a second time using the actual operation dataset stored on the drone to obtain the pre-tuned temperature and humidity prediction model.

[0024] The temperature and humidity prediction model after the second fine-tuning was deployed on a drone.

[0025] In one possible implementation, a sensor change threshold is configured for the sensors on the UAV, and when the change in sensor data exceeds the sensor change threshold, temperature and humidity data are collected, including:

[0026] Configure the sensor change threshold corresponding to the sensor on the UAV so that if the sensor data change exceeds the sensor change threshold, an interrupt signal is triggered.

[0027] The data acquisition thread is woken up by an interrupt signal, and then the temperature and humidity data collected by the sensor is acquired through the data acquisition thread.

[0028] In one possible implementation, after collecting temperature and humidity data, the process further includes:

[0029] A lightweight SQLite database is deployed on a drone equipped with an RK3588 chip, and the temperature and humidity data is stored through the SQLite lightweight database. After each time period, the temperature and humidity data from two time periods ago are deleted.

[0030] In one possible implementation, the temperature and humidity data are preprocessed using a mean-filling strategy, a 2σ criterion for outlier removal, and a sliding window Min-Max normalization strategy to obtain preprocessed temperature and humidity data, including:

[0031] Temperature and humidity data from two time periods are read, and the mean of the N seconds preceding the missing values ​​is used to fill in the missing values. Outliers are then removed using the 2σ criterion, resulting in cleaned temperature and humidity data. Here, N represents a constant.

[0032] A sliding window with a time period is set, and the sliding window is used to traverse the temperature and humidity data after data cleaning. The temperature and humidity data after data cleaning is normalized by Min-Max to obtain the preprocessed temperature and humidity data.

[0033] In one possible implementation, a temperature and humidity prediction model deployed on the UAV is scheduled to perform multi-time-step predictions on the preprocessed temperature and humidity data to obtain predicted temperature and humidity, including:

[0034] The preprocessed temperature and humidity data is used as input to the temperature and humidity prediction model deployed on the UAV. The predicted temperature and humidity output by the temperature and humidity prediction model are obtained, and the predicted temperature and humidity at multiple time steps are obtained repeatedly.

[0035] In one possible implementation, a pre-configured temperature and humidity warning threshold is read, and a three-level warning mechanism is used to provide temperature and humidity warnings for the UAV based on the predicted temperature and humidity and the temperature and humidity warning thresholds, including:

[0036] Read the pre-configured temperature and humidity warning thresholds; wherein, the temperature and humidity warning thresholds include a first warning ratio threshold, a second warning ratio threshold, and a third warning ratio threshold, which are arranged from smallest to largest.

[0037] Obtain the difference between the predicted temperature and humidity and the actual temperature and humidity at the current moment, and divide the difference by the actual temperature and humidity at the current moment to obtain the proportion exceeding the threshold;

[0038] If the over-threshold ratio is less than or equal to the first warning ratio threshold, a first-level warning is issued; the first-level warning includes: controlling the local interface of the UAV control terminal to display a yellow warning icon, and simultaneously calling the buzzer driver code to make the buzzer emit a warning sound at a frequency of 1 Hz.

[0039] If the over-threshold ratio is less than or equal to the second warning ratio threshold and greater than the first warning ratio threshold, a second-level warning is issued. The second-level warning includes: controlling the local interface of the drone control terminal to display a yellow warning icon, calling the buzzer driver code to make the buzzer emit a warning sound at a frequency of 2 Hz, and sending a warning SMS through the 4G module. The SMS content includes the drone's current latitude and longitude, warning location, predicted temperature and humidity, and warning level information.

[0040] If the over-threshold ratio is greater than the second warning ratio threshold, a level 3 warning will be issued. The level 3 warning includes: displaying a yellow warning icon on the local interface of the drone control terminal, continuously emitting a prompt sound through the buzzer, sending a voice notification through the 4G module, and controlling the drone to perform a return-to-home operation.

[0041] In one possible implementation, the alert event is also recorded as a log file.

[0042] Compared with the prior art, this application has the following advantages and beneficial effects:

[0043] This application discloses a UAV temperature and humidity early warning method based on embedded optimization. A temperature and humidity prediction model is constructed using a three-level lightweight optimization algorithm based on Transformer, and deployed on the UAV using a dual-strategy deployment algorithm combining cloud training and embedded fine-tuning. This improves the model's generalization and prediction accuracy under different operating conditions, meeting the UAV's requirements for model size, inference speed, and resource consumption. Then, when the sensor data changes beyond the sensor change threshold, temperature and humidity data are collected. Simultaneously, a lightweight database is used to store historical data, reducing CPU usage while providing fault tracing capabilities. The temperature and humidity data is then preprocessed to improve data quality and provide reliable input for the model. Finally, the temperature and humidity prediction model is scheduled to perform multi-time-step predictions on the preprocessed temperature and humidity data. Based on the predicted temperature and humidity and the temperature and humidity early warning threshold, a three-level early warning mechanism is used to provide temperature and humidity early warning for the UAV, achieving rapid response and automatic flight control linkage, thus buying time for abnormal intervention. Attached Figure Description

[0044] To more clearly illustrate the technical solutions of the exemplary embodiments of this application, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of this application and should not be considered as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort. In the drawings:

[0045] Figure 1 A flowchart illustrating an embedded-optimized method for early warning of temperature and humidity in unmanned aerial vehicles (UAVs) provided in this application embodiment. Detailed Implementation

[0046] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the embodiments and accompanying drawings. The illustrative embodiments and descriptions of this application are only for explaining this application and are not intended to limit this application.

[0047] Example 1

[0048] like Figure 1 As shown in the figure, this application provides an embedded-optimized method for early warning of temperature and humidity in unmanned aerial vehicles (UAVs), including:

[0049] S101. A temperature and humidity prediction model is constructed using the Transformer three-level lightweight optimization algorithm, and the temperature and humidity prediction model is deployed on a drone using a dual-strategy deployment algorithm of cloud training and embedded fine-tuning.

[0050] The Transformer three-level lightweight optimization algorithm addresses the issue of standard Transformer models being undeployable on embedded platforms through three software optimization levels: structural pruning, INT8 quantization, and custom operator fusion. This enables efficient model operation on development boards supporting the RK3588 chip, meeting the requirements of UAVs regarding model size, inference speed, and resource consumption. Existing model training schemes only train on a single platform, failing to adapt to the complex and varied operational scenarios of UAVs. This algorithm improves the model's generalization and prediction accuracy under different operating conditions through a software strategy combining large-scale cloud-based pre-training with embedded local scene fine-tuning.

[0051] S102. Configure the sensor change threshold corresponding to the sensor on the UAV, and collect temperature and humidity data when the degree of change of the sensor data exceeds the sensor change threshold.

[0052] An improvement on the traditional fixed-polling algorithm. Traditional fixed-polling methods result in excessive CPU usage. This algorithm, through software-level sensor threshold configuration and interrupt triggering logic, only initiates data collection when there is a valid change in temperature and humidity data. It can also be combined with a lightweight database for historical data storage, reducing CPU usage while providing fault tracing capabilities.

[0053] S103. The temperature and humidity data are preprocessed using a mean-filling strategy, a 2σ criterion strategy for removing outliers, and a sliding window Min-Max normalization strategy to obtain preprocessed temperature and humidity data.

[0054] Traditional algorithms can only perform basic data cleaning and cannot cope with problems such as sensor interference and missing data under the complex operating conditions of drones. This algorithm integrates software processing logic of "filling missing data with the mean of the first 5 seconds, removing outliers by the 2σ criterion, and 1-hour sliding window Min-Max normalization" to improve data quality and provide reliable input for the model.

[0055] S104. The temperature and humidity prediction model deployed on the UAV is scheduled to perform multi-time step prediction on the preprocessed temperature and humidity data to obtain the predicted temperature and humidity.

[0056] S105. Read the pre-configured temperature and humidity warning thresholds, and use a three-level warning mechanism to issue temperature and humidity warnings for the UAV based on the predicted temperature and humidity and the temperature and humidity warning thresholds.

[0057] In this context, temperature and humidity refer to temperature and / or humidity. Therefore, those skilled in the art can perform temperature warning, humidity warning, or simultaneous temperature and humidity warning based on the embedded optimization UAV temperature and humidity warning method provided in the embodiments of this application.

[0058] Traditional solutions rely on software polling for early warning judgment, which has a slow response speed and no flight control linkage capability. This algorithm uses software-level task priority division to design a three-level early warning mechanism to achieve rapid response and automatic flight control linkage. It also supports remote threshold configuration to buy time for abnormal intervention.

[0059] In one possible implementation, a temperature and humidity prediction model is constructed using a three-level lightweight optimization algorithm of Transformer, including:

[0060] Pruning is performed on the Transformer model to obtain the pruned Transformer model.

[0061] For example, first, install the deep learning model optimization tool on the Ubuntu 20.04 Long Term Support operating system and import the software library for model pruning. Next, configure the pruning parameters, setting the L1 regularization coefficient to 1e-5, the pruning strategy to polynomial decay, the initial sparsity to 0.0 (no parameter removal), the final sparsity to 0.6 (removing 60% redundant parameters), the pruning start step to 1000, and the end step to 10000. Simultaneously, set the pruning block size to (1,1) and the block pooling type to average pooling. Then, apply the configured pruning parameters to the initial Transformer model, which contains 6 encoder layers, 8 attention heads, and 2048 feedforward neurons. Prune the encoder and feedforward layers of the model using the pruning tool.

[0062] The pruned Transformer model is then simplified and optimized to obtain a simplified and optimized Transformer model.

[0063] For example, after pruning, the model is streamlined and optimized: the contribution of each attention head is calculated using software code (using model layer weight data), and attention heads with a contribution of ≥5% are retained; at the same time, redundant neurons with activation values ​​<0.1 are removed by detecting neuron activation values. The final pruned model contains 4 encoder layers, 4 attention heads, and 1024 feedforward neurons, with the total number of parameters reduced from 10.2 million to 3.8 million, and the model size compressed from 520 megabytes to 120 megabytes.

[0064] The simplified and optimized Transformer model is then subjected to INT8 quantization to obtain the quantized Transformer model.

[0065] For example, firstly, a quantization calibration dataset is prepared, selecting 5000 actual UAV flight data points. The data covers typical scenarios such as high temperature (35℃), high humidity (90% RH), and high altitude (1000 meters). The data format is "temperature, humidity," and it is saved as a text file. Then, the pruned model is loaded using a model quantization optimization tool. Next, quantization parameters are configured, selecting channel-level quantization (which results in less accuracy loss than layer-by-layer quantization), setting the quantization mean to [0.0, 0.0] and the quantization standard deviation to [1.0, 1.0]. The target platform is set to an embedded environment supporting the RK3588 chip. Then, quantization and error calibration are performed, converting the 32-bit floating-point model to an 8-bit integer model. During quantization, the mean squared error (MSE) is calculated using software code to verify quantization accuracy, ensuring the error is <2%. Finally, an embedded model is generated, and the quantized model is saved as a model file adapted to the embedded platform. At this point, the model size is further compressed from 120 megabytes to 65 megabytes. The model is then pushed to a specified directory on a development board that supports the RK3588 chip via a data transfer tool.

[0066] The quantized Transformer model is fused using custom operators to obtain the fused Transformer model, thus obtaining the temperature and humidity prediction model.

[0067] The custom operator fusion refers to encapsulating the position encoding operator, multi-head self-attention operator, and layer normalization operator in the quantized Transformer model into a single operator.

[0068] For example, the software bottleneck of the standard Transformer model is first identified: the "position encoding - multi-head self-attention - layer normalization" in the model are three independent operators. The software needs to control the data to be transferred three times between the central processing unit and the neural network processor, resulting in a high idle rate of the neural network processor. Next, a fusion operator is designed, and the operator source code file is written to encapsulate the computational logic of the three independent operators into a fusion operator. The core design is to reduce the number of data copies by sharing the input tensor. Then, the operator is compiled using a 64-bit ARM architecture cross-compilation toolchain (version 9.4.0) to compile the operator source code into a dynamic library file. After that, the operator is imported, and the compiled operator dynamic library is loaded through the interface of the model quantization optimization tool, integrating the fusion operator into the model optimization process. Finally, the model is refactored, and the forward propagation code logic of the Transformer model is modified to replace the original three calls to the three independent operators with a single call to the fusion operator. Verified by performance testing software, the number of data transfers after fusion was reduced from 3 to 1, the inference time was shortened from 95 milliseconds to ≤35 milliseconds, and the neural network processor utilization was increased from 28% to 72%.

[0069] The core formulas and parameters involved in the Transformer three-level lightweight optimization algorithm are explained below:

[0070] 1. Sparsity calculation formula:

[0071]

[0072] Sparsity represents the sparsity of the pruned model, i.e., the proportion of redundant parameters removed. In this application, the final sparsity is 60%. This indicates the number of effective parameters in the model after pruning. This indicates the total number of parameters in the model before pruning.

[0073] 2. Quantization Error (MSE) Calculation Formula:

[0074]

[0075] Where MSE represents mean squared error, which is used to measure the difference between the output of the 32-bit floating-point (FP32) model and the output of the 8-bit integer (INT8) model. This application requires that the error be <2%; n represents the number of samples used to calculate the error. This represents the output value of the 32-bit floating-point model for the i-th sample; This represents the output value of the 8-bit integer model for the i-th sample.

[0076] 3. Formula for calculating the improvement rate of inference time:

[0077]

[0078] in, Indicates the rate of improvement in reasoning time; This indicates the inference time of the model before optimization (the standard Transformer model takes more than 200 milliseconds). This indicates the inference time of the optimized model (≤35 milliseconds in this application), and the inference time improvement rate in this application is ≥82.5%.

[0079] Compared to the standard Transformer deployment scheme in existing technologies, the core difference lies in the software optimization logic. The software of the standard Transformer deployment scheme is not adapted for embedded platforms. The model adopts a complex structure of "6-layer encoder + 8 attention heads + 2048 feedforward neurons" without any lightweight pruning operations. The weight quantization is still in 32-bit floating-point format, resulting in a model size of over 500 megabytes, which cannot be adapted to the storage resources of embedded platforms. At the same time, the "position encoding - multi-head self-attention - layer normalization" in the model are independent operators. The software needs to control the data to be transferred between the central processing unit and the neural network processor three times, resulting in a high idle rate of the neural network processor and a utilization rate of less than 30%. In addition, this scheme does not consider the resource scheduling of embedded platforms. When the central processing unit is running at full load, there is no task priority division, which causes the power consumption of the development board to rise to more than 12 watts.

[0080] The Transformer three-level lightweight optimization algorithm in this application comprehensively improves upon the aforementioned software defects. At the structural pruning level, through a multinomial decay pruning strategy and attention head contribution analysis, the model encoder is reduced from 6 layers to 4 layers, the number of attention heads from 8 to 4, and the number of feedforward neurons from 2048 to 1024, reducing the total number of parameters from 10.2 million to 3.8 million. At the quantization level, channel-level INT8 quantization is adopted to convert the model from 32-bit floating-point to 8-bit integer, with quantization error controlled within 2%. At the operator fusion level, a custom "position encoding-multi-head self-attention-layer normalization" fusion operator is used to reduce the number of data transfer operations.

[0081] Through these software optimizations, the Transformer three-level lightweight optimization algorithm has achieved significant technical results: the model size has been compressed from over 500 megabytes to 65 megabytes, only 13% of the standard model, fully adapting to the storage resources of development boards supporting the RK3588 chip; inference time has been reduced from over 200 milliseconds to ≤35 milliseconds, meeting the real-time requirement of "5-minute interval prediction"; neural network processor utilization has increased from less than 30% to 72%, significantly improving computing power utilization efficiency; at the same time, combined with software-level resource scheduling strategies, the typical power consumption of the development board is controlled at 5-8 watts, avoiding the impact of high power consumption on the drone's battery life and ensuring the stable operation of the model on the embedded platform.

[0082] In one possible implementation, the temperature and humidity prediction model is deployed on a drone using a dual-strategy deployment algorithm that combines cloud training and embedded fine-tuning, including:

[0083] The temperature and humidity prediction model is trained in the cloud to obtain the pre-trained temperature and humidity prediction model.

[0084] The pre-trained temperature and humidity prediction model is sent to a drone equipped with an RK3588 chip, and the pre-trained temperature and humidity prediction model is fine-tuned a second time using the actual operation dataset stored on the drone to obtain the pre-tuned temperature and humidity prediction model.

[0085] The temperature and humidity prediction model after the second fine-tuning was deployed on a drone.

[0086] This dual-strategy deployment algorithm achieves model training through software collaboration between the cloud and embedded platforms. The specific steps are as follows:

[0087] The first step is cloud-based pre-training. A large-scale training dataset is prepared, collecting 100,000 data points related to drone temperature and humidity. This data covers temperature and humidity under different operational scenarios (power line inspection, agricultural plant protection) and environmental conditions (high temperature, high humidity, high altitude, dusty conditions), and also includes auxiliary features such as flight altitude and motor speed. The data format is "timestamp-location ID-temperature-humidity-altitude-speed". The dataset is divided into training, validation, and test sets in a 7:2:1 ratio. Then, a training environment is set up on a server equipped with an RTX 3090 GPU, and the TensorFlow 2.8 deep learning framework is installed. Based on this framework, an initial Transformer model (containing a 6-layer encoder, 8 attention heads, and 2048 feedforward neurons) is built. Training parameters are configured, with a batch size of 64, 200 training epochs, and Adam selected as the optimizer. The optimizer parameters are set to β1=0.9, β2=0.999, and a weight decay coefficient of 1e-5. The learning rate adopted the ReduceLROnPlateau strategy, with an initial learning rate of 1e-4. When the mean squared error of the validation set did not decrease for 20 consecutive training epochs, the learning rate was halved, with the minimum learning rate reduced to 1e-6. During training, the goal was to minimize the prediction mean squared error, and the model performance was periodically evaluated on the validation set. After training, the mean squared error of the validation set reached 8.2e-6, indicating that the model possessed preliminary long-sequence prediction capabilities and multi-dimensional data fitting capabilities.

[0088] The second step is embedded fine-tuning. First, a fine-tuning environment is set up on a development board supporting the RK3588 chip, installing software tools such as Python 3 and TensorFlow Lite, and preparing a local fine-tuning dataset. This dataset contains 5000 real-world drone operation data points, primarily from local low-altitude (100-300 meters) complex terrain and 500-meter high-altitude power line inspection scenarios, ensuring a high degree of data matching with the actual operational environment deployed on the development board, and that the data format is consistent with the cloud-based pre-trained dataset. Then, the pre-trained model is migrated to the development board. To avoid overfitting, 90% of the model's parameters are frozen via software code, only unfreezing the output layer and the last two encoder layers, as these layers are more sensitive to scene adaptation. Fine-tuning parameters are configured, using AdamW as the optimizer, with an initial learning rate of 5e-5, a weight decay coefficient of 5e-6, a batch size of 32, and 50 training epochs. During the fine-tuning process, the goal was to minimize the mean square error of the test set. The prediction accuracy of the model on local data was monitored regularly. After the fine-tuning was completed, the mean square error of the test set was reduced to 3.1e-6, the temperature prediction error was ≤0.3℃, and the humidity prediction error was ≤1.2% RH. The model can well adapt to the temperature and humidity variation patterns of the local working scenario.

[0089] The core formulas and parameters involved in this dual-strategy deployment algorithm are explained below:

[0090] 1. Formula for calculating the mean squared error (MSE) of a model:

[0091]

[0092] Where MSE represents the mean squared error between the model's predicted values ​​and the actual values, and is used to evaluate the model's prediction accuracy; m represents the number of samples in the test set or validation set. This represents the model's predicted value for the i-th sample; Let represent the true temperature and humidity value of the i-th sample. During the cloud pre-training phase, the target mean square error of the validation set was ≤1e-5, and it actually reached 8.2e-6 after training. During the embedded fine-tuning phase, the target mean square error of the test set was ≤5e-6, and it actually reached 3.1e-6 after fine-tuning.

[0093] The "cloud pre-training + embedded fine-tuning" algorithm in this application is optimized through a two-stage training strategy at the software level: the cloud pre-trains the model with 100,000 multi-dimensional data (including temperature, humidity, altitude, and rotation speed) to enable the model to have preliminary generalization ability; the embedded platform fine-tunes the model with 5,000 local scene data, freezing 90% of the parameters and optimizing only the key layers to adapt the model to local working conditions.

[0094] The technical effects of this dual-strategy deployment algorithm mainly include: significantly improved model generalization, adapting to different scenarios such as multi-rotor power line inspection (500 meters high) and fixed-wing agricultural plant protection (100-300 meters low); for every 100-meter change in altitude and every 1000 rpm change in rotation speed, the prediction error increase is ≤0.1℃, far superior to the error increase of more than 5% for the LSTM model; improved model training efficiency, with embedded fine-tuning time reduced by 50% compared to full training, eliminating the need for a graphics processor and reducing deployment costs; and significantly improved model prediction accuracy, with temperature error ≤0.3℃ and humidity error ≤1.2% RH, representing an accuracy improvement of more than 90% compared to the LSTM model and more than 93% compared to the ARIMA model. It can accurately identify early anomalies such as "minor temperature rise of 0.1℃ / minute", providing reliable data support for safety early warning.

[0095] In one possible implementation, a sensor change threshold is configured for the sensors on the UAV, and when the change in sensor data exceeds the sensor change threshold, temperature and humidity data are collected, including:

[0096] Configure the sensor change threshold corresponding to the sensor on the UAV so that if the sensor data change exceeds the sensor change threshold, an interrupt signal is triggered.

[0097] The data acquisition thread is woken up by an interrupt signal, and then the temperature and humidity data collected by the sensor is acquired through the data acquisition thread.

[0098] This process implements interrupt-triggered data acquisition and storage through software configuration and code logic. The specific steps are as follows:

[0099] The first step is sensor threshold configuration. First, software configuration code is written to send threshold configuration commands to sensors in four key locations via the I2C communication protocol: the SHT30 sensor in the battery compartment is configured to trigger an alarm when the temperature change is greater than 0.1℃ or the humidity change is greater than 1% RH; the AHT21 sensor in the motor control module is configured to enable interrupt functionality and set the same trigger threshold as the SHT30; the BME280 sensor in the flight control system is configured with its sampling rate and threshold; and the SHT21 sensor in the power interface is configured to calibrate humidity and configure its trigger threshold. Next, GPIO interrupt configuration code is written to configure the four GPIO pins of the development board supporting the RK3588 chip as rising-edge triggered interrupts, and a corresponding interrupt handling function is bound to each pin.

[0100] The second step is interrupt triggering and data acquisition. When the sensor detects a temperature and humidity change exceeding a set threshold, its alarm pin outputs a high level, triggering a corresponding GPIO rising edge interrupt. Upon receiving the interrupt signal, the interrupt controller wakes up a pre-created acquisition thread via software code. This acquisition thread has a priority of 50, higher than the priority of ordinary processes, to ensure a fast response. After being woken up, the acquisition thread sends a data read command to the corresponding sensor via the I2C communication protocol, for example, sending a read command to the SHT30 sensor. It receives the digital signal returned by the sensor and then converts the digital signal into actual temperature (°C) and humidity (%RH) physical quantities via software code.

[0101] In one possible implementation, after collecting temperature and humidity data, the process further includes:

[0102] A lightweight SQLite database is deployed on a drone equipped with an RK3588 chip, and the temperature and humidity data is stored through the SQLite lightweight database. After each time period, the temperature and humidity data from two time periods ago are deleted.

[0103] The third step is data storage and scheduled cleanup. First, install and initialize the SQLite lightweight database on the development board that supports the RK3588 chip. Create a database file named "uhv_data.db" through software code, and create a "sensor_data" table in the database. The table structure includes four fields: "timestamp" (integer type), "pos_id" (location ID, integer type), "temp" (temperature, floating-point type), and "humidity" (humidity, floating-point type). The acquisition thread inserts the converted temperature and humidity data into the "sensor_data" table in the format of "timestamp-location ID-temperature-humidity" through the SQLite software interface. The timestamp is obtained through the real-time clock of the development board with millisecond-level accuracy. The location IDs correspond to the battery compartment (1), motor control module (2), flight control system (3), and power interface (4), respectively. Meanwhile, a scheduled task is created through software code to perform a data cleanup operation once per hour, deleting data with timestamps earlier than the current time by 2 hours (7200 seconds), ensuring that the database only retains historical data from the most recent 2 hours, avoiding storage resource overflow. Actual measurements show that the data storage usage per hour is ≤1 kilobyte.

[0104] The core formulas and parameters involved in this interrupt-driven data acquisition and lightweight storage algorithm are explained below:

[0105] 1. Interrupt trigger condition formula:

[0106]

[0107] in, This indicates the temperature and humidity values ​​currently collected by the sensor; This indicates the temperature and humidity values ​​that were last collected and stored; Threshold indicates the preset trigger threshold, with a temperature threshold of 0.1℃ and a humidity threshold of 1% RH. An interrupt is triggered when the absolute value of the temperature and humidity change exceeds the corresponding threshold.

[0108] 2. Data retention condition formula:

[0109]

[0110] in, The timestamp (in milliseconds) representing the data record; This represents the current timestamp (in milliseconds) when the data cleanup operation was performed; 7200000 represents the number of milliseconds corresponding to 2 hours (2 × 3600 × 1000). When the timestamp of the data is less than "current timestamp - 7200000", the data will be deleted.

[0111] Traditional monitoring solutions in the current technology use a fixed 1 Hz polling method for data acquisition. Regardless of whether the temperature and humidity data change, the central processing unit (CPU) needs to continuously and periodically respond to sensor requests, resulting in a CPU utilization rate of over 32%, which squeezes the computing power of the core flight control task. At the same time, the software of this solution does not have a local data storage module and relies solely on the real-time transmission link. Once the transmission is interrupted or the drone crashes, the data will be lost, and fault tracing will be impossible.

[0112] This application's interrupt-driven data acquisition and lightweight storage algorithm improves upon both the software acquisition mechanism and storage design. Regarding the acquisition mechanism, sensor thresholds and interrupt triggering logic are configured in software, waking the acquisition thread only when temperature and humidity changes exceed the thresholds (temperature > 0.1℃, humidity > 1% RH), thus avoiding unnecessary CPU usage. In terms of storage design, the software integrates a lightweight SQLite database, storing data in the format of "timestamp-location ID-temperature and humidity," and uses scheduled tasks to clean up historical data older than 2 hours, ensuring controllable storage resources.

[0113] The technical effects of this interrupt-driven data acquisition and lightweight storage algorithm are mainly reflected in three aspects: the CPU utilization rate is reduced from 32% to 8%, reducing CPU resource consumption by 75%, and the freed computing power can ensure the normal operation of core tasks such as flight control data processing and motor control; the data acquisition integrity is significantly improved, with 1200 data points collected continuously for 1 hour without loss, avoiding the problem of sudden data loss that may be caused by fixed polling; at the same time, the local data storage function allows the temperature and humidity change curves before the accident to be reviewed through the database after the drone crashes, and the fault tracing accuracy rate is increased from 0 to 100%, which can quickly locate the root cause of the fault, such as determining whether the temperature rise or the humidity abnormality occurred first.

[0114] In one possible implementation, the temperature and humidity data are preprocessed using a mean-filling strategy, a 2σ criterion for outlier removal, and a sliding window Min-Max normalization strategy to obtain preprocessed temperature and humidity data, including:

[0115] Temperature and humidity data from two time periods are read, and the mean of the N seconds preceding the missing values ​​is used to fill in the missing values. Outliers are then removed using the 2σ criterion, resulting in cleaned temperature and humidity data. Here, N represents a constant.

[0116] A sliding window with a time period is set, and the sliding window is used to traverse the temperature and humidity data after data cleaning. The temperature and humidity data after data cleaning is normalized by Min-Max to obtain the preprocessed temperature and humidity data.

[0117] This preprocessing algorithm implements data cleaning and standardization through software code. The specific steps are as follows:

[0118] The first step is data cleaning. First, the software connects to an SQLite database and reads the temperature and humidity data from the past two hours, totaling 120 records (30 records from each of the four monitoring locations). For missing values, a 5-second mean imputation method is used: a sliding window function is used to calculate the average of the five consecutive valid data points preceding the missing data point, and this average is assigned to the missing data location to avoid errors caused by single-value imputation. For outliers, the 2σ criterion is used for removal: a 5-second sliding window is used, and the software calculates the mean (μ) and standard deviation (σ) of the data within each window. It is determined whether each data point falls within the range of "μ-2σ" to "μ+2σ". If the data exceeds this range, it is considered an outlier (caused by dust adhesion, vibration interference, etc.) and is removed.

[0119] The second step is data standardization. A 1-hour sliding window Min-Max normalization method is used to standardize the cleaned data to the [0,1] interval to adapt to the low-precision computational requirements of the embedded platform's neural network processor and improve model inference efficiency. First, software code iterates through all the cleaned data in 1-hour sliding windows, calculating the minimum values ​​of temperature and humidity data within each window. With the maximum value Then, each data point within the window is processed according to the normalization formula to obtain standardized values. Finally, the standardized data is reorganized according to monitoring location and time step to form a tensor with dimensions "4×120×2" (4 represents 4 monitoring locations, 120 represents the time step corresponding to 2 hours, and 2 represents the two features of temperature and humidity). This tensor serves as the input data for the Transformer model. Actual measurements show that the entire data preprocessing process takes ≤8 milliseconds, and the model inference speed after standardization is 40% faster than that without standardization.

[0120] The core formulas and parameters involved in this preprocessing algorithm are explained below:

[0121] 1. Formula for filling the average of the first 5 seconds:

[0122]

[0123] in, This represents the mean used to fill in missing values; These represent the valid temperature and humidity data for the 1 second, 2 seconds, 3 seconds, 4 seconds, and 5 seconds prior to the time of missing data, respectively.

[0124] 3. Formulas for calculating the mean (μ) and standard deviation (σ):

[0125]

[0126] in, This represents the mean of the data within a 5-second sliding window, reflecting the central tendency of the data. The standard deviation of the data within the window represents the degree of dispersion of the data; k represents the number of data points within the window (here). ; This represents the j-th data item within the window.

[0127] 4. Min-Max Normalization Formula:

[0128]

[0129] in, The value represents the standardized value; x represents the original data. This represents the minimum value of the data within a 1-hour sliding window; This represents the maximum value of the data within the window. This formula maps the original data to the [0,1] interval, eliminating the influence of different units on the model.

[0130] Existing LSTM / ARIMA time series prediction schemes employ simple data preprocessing methods. For missing data, they typically fill in the missing data from the previous iteration or delete it directly, resulting in poor data continuity and large errors. For outlier data, they use fixed thresholds for removal, which cannot adapt to data distributions in different scenarios and are prone to accidental or missed deletions. In addition, the standardization process uses global normalization, which does not consider the temporal characteristics of temperature and humidity data and cannot adapt to dynamic changes in data, thus affecting the model's prediction accuracy.

[0131] The multi-dimensional data preprocessing algorithm in this application is optimized to address these software shortcomings. Missing values ​​are filled using the mean of the first 5 seconds. By calculating the mean of local data through software, the local trend of the data can be better reflected, reducing the filling error. Outlier removal adopts the 2σ criterion, which determines the range of outliers based on the dynamic distribution of the data, and the false deletion rate is controlled within 1%. Standardization adopts 1-hour sliding window Min-Max normalization to adapt to the temporal changes of the data and to meet the low-precision calculation requirements of neural network processors.

[0132] The technical effects of this preprocessing algorithm are very significant: data quality is significantly improved, with an outlier removal rate of 98%, effectively filtering out abnormal data caused by dust adhesion, vibration interference, etc., providing reliable input for the model; data preprocessing time is ≤8 milliseconds, which is 60% shorter than the traditional solution of 20 milliseconds, improving the real-time performance of the overall process; the inference speed of the model after standardization is 40% faster than that without standardization, and the stability of model prediction is greatly improved, with the mean squared error decreasing from 1.2e-5 in the traditional solution to 3.1e-6, laying the foundation for subsequent high-precision prediction.

[0133] In one possible implementation, a temperature and humidity prediction model deployed on the UAV is scheduled to perform multi-time-step predictions on the preprocessed temperature and humidity data to obtain predicted temperature and humidity, including:

[0134] The preprocessed temperature and humidity data is used as input to the temperature and humidity prediction model deployed on the UAV. The predicted temperature and humidity output by the temperature and humidity prediction model are obtained, and the predicted temperature and humidity at multiple time steps are obtained repeatedly.

[0135] In one possible implementation, a pre-configured temperature and humidity warning threshold is read, and a three-level warning mechanism is used to provide temperature and humidity warnings for the UAV based on the predicted temperature and humidity and the temperature and humidity warning thresholds, including:

[0136] Read the pre-configured temperature and humidity warning thresholds; wherein, the temperature and humidity warning thresholds include a first warning ratio threshold, a second warning ratio threshold, and a third warning ratio threshold, which are arranged from smallest to largest.

[0137] Obtain the difference between the predicted temperature and humidity and the actual temperature and humidity at the current moment, and divide the difference by the actual temperature and humidity at the current moment to obtain the proportion exceeding the threshold;

[0138] If the over-threshold ratio is less than or equal to the first warning ratio threshold, a first-level warning is issued; the first-level warning includes: controlling the local interface of the UAV control terminal to display a yellow warning icon, and simultaneously calling the buzzer driver code to make the buzzer emit a warning sound at a frequency of 1 Hz.

[0139] If the over-threshold ratio is less than or equal to the second warning ratio threshold and greater than the first warning ratio threshold, a second-level warning is issued. The second-level warning includes: controlling the local interface of the drone control terminal to display a yellow warning icon, calling the buzzer driver code to make the buzzer emit a warning sound at a frequency of 2 Hz, and sending a warning SMS through the 4G module. The SMS content includes the drone's current latitude and longitude, warning location, predicted temperature and humidity, and warning level information.

[0140] If the over-threshold ratio is greater than the second warning ratio threshold, a level 3 warning will be issued. The level 3 warning includes: displaying a yellow warning icon on the local interface of the drone control terminal, continuously emitting a prompt sound through the buzzer, sending a voice notification through the 4G module, and controlling the drone to perform a return-to-home operation.

[0141] This three-level early warning mechanism implements threshold configuration, early warning judgment, and response through software code. The specific steps are as follows:

[0142] The first step is configuring and retrieving warning thresholds. First, a warning threshold configuration file is created on a development board supporting the RK3588 chip. This file stores the temperature and humidity safety thresholds for four monitoring locations, such as a battery compartment temperature threshold of 60℃ and a humidity threshold of 85% RH, and a motor control module temperature threshold of 65℃ and a humidity threshold of 80% RH. These thresholds can be adjusted according to the drone model and operational scenario. Upon system startup, the warning software loads the threshold parameters from the configuration file via a file reading interface and stores them in memory variables for subsequent judgment. Simultaneously, a web service based on the Flask framework is built on the development board, and a threshold configuration interface is developed. Ground personnel can access this web interface via a 4G network to modify the warning thresholds for each location in real time. The modified thresholds are saved to the configuration file via the web service. The warning software periodically reads this file to update the threshold parameters in memory, and the changes take effect without requiring a system restart.

[0143] The second step is to determine the warning level. After the Transformer model completes its inference, it outputs predicted temperature and humidity values ​​for the next 30 minutes, with a prediction interval of 5 minutes per step, for a total of 6 time steps. Each time step contains predicted temperature and humidity values ​​for 4 monitoring locations. The warning software receives these predicted values ​​and compares the predicted value for each location and each time step with the corresponding safety threshold, calculating the percentage exceeding the threshold. The percentage exceeding the threshold is calculated as follows: the difference between the predicted value and the threshold is divided by the threshold, then multiplied by 100%. Based on the percentage exceeding the threshold, the warning level is divided into three levels: Level 1 warning when the percentage exceeding the threshold is ≤5%; Level 2 warning when 5% < percentage exceeding the threshold is ≤10%; and Level 3 warning when the percentage exceeding the threshold is >10%.

[0144] The third step is tiered early warning response and log recording. The early warning software triggers corresponding early warning response actions based on the determined early warning level. The response process is based on software-level task priority scheduling, ensuring that higher-level early warnings receive priority. For a Level 1 early warning, with a task priority of 100, the early warning software controls the local Qt interface to display a yellow warning icon and simultaneously calls the buzzer driver code to make the buzzer emit a warning sound at a frequency of 1 Hz. The entire response process takes ≤30 milliseconds. For a Level 2 early warning, with a task priority of 50, in addition to displaying an orange warning icon on the Qt interface and emitting a buzzer sound at a frequency of 2 Hz, an early warning SMS is sent via the 4G module. The SMS content includes the drone's current latitude and longitude, warning location, predicted temperature and humidity values, and warning level. The SMS is sent via AT commands, and the entire response process takes ≤90 milliseconds. For Level 3 warnings, with a task priority set to 10, a red warning icon is displayed on the Qt interface, a continuous beeping sound is emitted, the 4G module sends a voice notification, and the warning software sends a "decelerate / return to home" command to the flight controller via the UART interface. Upon receiving the command, the flight controller responds within ≤50 milliseconds, controlling the drone to perform the return-to-home operation. Furthermore, all warning events are recorded in detail in a log file, including the warning timestamp, monitoring location ID, warning level, predicted value, threshold, response action, and processing result, facilitating subsequent fault review and tracing.

[0145] The core formulas and parameters involved in this three-level early warning mechanism are explained below:

[0146] 1. Formula for calculating the proportion exceeding the threshold:

[0147]

[0148] Where R represents the percentage exceeding the threshold, used to measure the degree to which the predicted value exceeds the safety threshold; P represents the temperature and humidity predicted value output by the Transformer model; and T represents the temperature and humidity safety threshold read from the configuration file for the corresponding location. Warning levels are determined based on the range of R values: Corresponding to Level 1 warning, Corresponding to Level II warning, This corresponds to a Level 3 warning.

[0149] In one possible implementation, the alert event is also recorded as a log file.

[0150] Traditional monitoring solutions in the current technology rely on software polling to determine anomalies, with early warning response times exceeding 200 milliseconds. Moreover, they can only display pop-ups in ground-based applications, lacking automatic intervention capabilities. Delayed manual intervention can easily lead to increased risks. LSTM / ARIMA time series prediction solutions can only output prediction results on personal computers, lacking software-level early warning mechanisms and unable to link with flight control, resulting in untimely transmission of early warning information. Standard Transformer deployment solutions also lack effective early warning linkage design, failing to meet the rapid intervention requirements in UAV operations.

[0151] The hierarchical early warning decision algorithm of this application designs a three-level early warning mechanism by dividing the task priority at the software level. Different levels correspond to different response priorities and actions. It also supports 4G remote notification and automatic linkage with flight control. The threshold can be modified in real time through the Web interface without restarting the system.

[0152] The hierarchical early warning decision-making algorithm exhibits remarkable technical advantages: Early warning response speed is significantly improved, with Level 1 early warning response ≤30 milliseconds, Level 2 ≤90 milliseconds, and Level 3 flight control response ≤50 milliseconds, representing an improvement of over 50% compared to traditional software polling solutions. This provides an intervention window of ≥30 minutes for risks such as lithium battery thermal runaway. Early warning linkage capabilities are significantly enhanced; Level 3 early warnings can automatically trigger flight control return-to-home, preventing crashes caused by untimely manual intervention. Furthermore, the remote threshold configuration function improves the flexibility of the solution, allowing for rapid adjustment of early warning strategies based on different operational scenarios. Actual testing shows that the drone crash rate caused by abnormal temperature and humidity has decreased from 35% to below 14%, reducing the risk by over 60%.

[0153] Existing LSTM / ARIMA time series prediction solutions use only up to 70,000 single-dimensional data points (temperature and humidity) for training on a personal computer, without embedded fine-tuning. This results in poor model generalization, with prediction errors exceeding 25% under complex conditions such as high altitude and high humidity. Standard Transformer model solutions are trained only on GPU servers and are not adapted for embedded drone scenarios. The accuracy of the model degrades significantly in local operating environments, failing to meet practical needs.

[0154] Example 2

[0155] Based on the technical solution described in Embodiment 1 above, this embodiment provides a detailed example to help those skilled in the art to more easily understand this embedded optimization-based UAV temperature and humidity early warning method, as follows.

[0156] This embodiment is described in two parts: hardware and software. The hardware architecture uses an embedded development board as the core, connecting four temperature and humidity sensors. These sensors can be deployed at any location on the drone that needs monitoring. The software architecture consists of six functional modules: data acquisition, data processing, data prediction, data transmission, data display, and early warning control. The hardware and software work together to realize a drone temperature and humidity early warning function based on Transformer embedded optimization, which is compatible with mainstream drone embedded operating environments.

[0157] 1. Software deployment and functional verification;

[0158] 1.1 Host environment configuration;

[0159] The host machine was a computer running Ubuntu 20.04 Long Term Support Edition. First, the model optimization tools and training framework were installed. The model quantization optimization tool (version 1.5.2) was installed using the tool installation command; this tool is used for subsequent quantization and optimization operations of the Transformer model. Next, the 64-bit ARM architecture cross-compilation toolchain (version 9.4.0) was configured. The toolchain's installation path was added to the system environment variables to ensure that cross-compilation commands could be directly invoked in the terminal for subsequent compilation of operator dynamic libraries. Then, the TensorFlow 2.8 deep learning framework was installed using the tool installation command. This framework is used for Transformer model pruning and cloud pre-training.

[0160] 1.2 Target-side (development board supporting RK3588 chip) environment configuration;

[0161] Install the Linux 5.10 kernel system on the development board that supports the RK3588 chip, ensuring that the neural network processor driver and I2C controller driver are enabled. First, install the SQLite lightweight database. Install SQLite version 3.37.2 using the system package manager command. After installation, create a database file using the database command, and execute SQL statements in the database to create data tables to store historical temperature and humidity data.

[0162] Next, install the local visualization and web configuration tools. Install the PyQt5 library for Python 3 using the system package management command to develop the local Qt warning interface. Install the Flask framework for Python 3 using the system package management command. Write web service code based on this framework to implement the remote configuration function of the warning threshold. The code must include the logic for reading, modifying, and saving the threshold, ensuring that the ground terminal can modify the threshold by accessing the specified web address and save the modified threshold to the configuration file.

[0163] Then, install the data transmission and dialing tools. Install the PPP dialing tool through the system package management command for dialing up the Internet on the 4G module. Write a dialing script, in which the access point name is configured as "cmnet" and the dialing command specifies the corresponding script file. Set the PPP service to start automatically on boot through the system service command to ensure that the 4G network connection can be automatically established after the development board is powered on. The actual measured 4G signal strength is ≥-80 dBmW, which meets the needs of remote communication.

[0164] 1.3 Three-level optimization and deployment of the Transformer model;

[0165] (1) Structural pruning;

[0166] This document describes a model pruning implementation based on a pruning library built on the TensorFlow 2.8 framework. First, the pruning tool is imported into a Python script using code. Then, pruning parameters are configured: the L1 regularization coefficient is set to 1e-5, the pruning scheduling strategy is polynomial decay, the initial sparsity is 0.0, the final sparsity is 0.6, the start pruning step count is 1000, the end pruning step count is 10000, the pruning block size is (1,1), and the block pooling type is average pooling. These parameters are configured using a dictionary in the code.

[0167] The configured pruning parameters were applied to the initial Transformer model, which contained 6 encoder layers, 8 attention heads, and 2048 feedforward neurons. The encoder and feedforward layers were pruned using a pruning function to obtain the pruned model. After pruning, the contribution of each attention head was calculated by obtaining the attention head weight data, calculating the contribution of each attention head, and retaining attention heads with a contribution ≥5%. Simultaneously, neuron activation values ​​were detected by the code, and neurons with activation values ​​<0.1 were removed. The final pruned model contained 4 encoder layers, 4 attention heads, and 1024 feedforward neurons. The total number of parameters was reduced from 10.2 million to 3.8 million, and the model size was compressed from 520 megabytes to 120 megabytes. The pruned model was saved as a specified format file using a model saving function.

[0168] (2) RKNN quantization;

[0169] Open the model quantization optimization tool, create a tool instance, and load the pruned model file using the model loading function. Then configure the quantization parameters by calling the tool's configuration function, setting the quantization method to channel-level quantization, the quantized image mean to [0.0, 0.0], and the quantized image standard deviation to [1.0, 1.0]. Set the target platform to an embedded environment that supports the RK3588 chip, ensuring that the quantization parameters match the hardware characteristics of the development board.

[0170] A quantization calibration dataset was prepared, consisting of 5000 actual UAV flight data points. The data covered scenarios including high temperature (35℃), high humidity (90% RH), and high altitude (1000 meters). The data format was "temperature, humidity," and saved as a text file. The tool's constructor function was called to enable quantization, and the calibration dataset was imported. During quantization, the tool automatically calculated the mean square error between the 32-bit floating-point output and the 8-bit integer output, ensuring the error was less than 2%. If the error exceeded this range, the calibration dataset or quantization parameters were adjusted, and quantization was performed again.

[0171] After quantization, the quantized model is saved as a file in the specified format using the tool's save function. At this point, the model size is further compressed from 120 megabytes to 65 megabytes. The quantized model is then pushed to the specified directory on the development board using a data transfer tool, completing the model deployment preparation.

[0172] (3) Operator fusion;

[0173] Write the source code file for the fusion operator, defining the computational logic of the "position encoding-multi-head self-attention-layer normalization" fusion operator. The core is to share the input and output tensors of the three independent operators, reducing data copying operations. For example, the output tensor of position encoding is directly used as the input tensor of multi-head self-attention, and the output tensor of multi-head self-attention does not need to be transmitted to the central processing unit, but is directly used as the input tensor of layer normalization. In this way, three data transfers are simplified to one.

[0174] The operator source code is compiled using a 64-bit ARM architecture cross-compilation toolchain to generate a dynamic library file. The compilation command must specify the target architecture and dependent libraries to ensure that the dynamic library can run on the development board. The compiled dynamic library is loaded through the interface of the model quantization optimization tool, the operator name is specified, and the fusion operator is integrated into the model optimization tool.

[0175] The forward propagation code of the Transformer model was modified, replacing the original three calls to the "position encoding," "multi-head self-attention," and "layer normalization" operators with a single call to the fusion operator. This ensures that the model uses the fusion operator for computation during inference. Performance testing was conducted using a tool's performance benchmark function. Real-world data shows that before fusion, data was moved between the CPU and the neural network processor three times, with an inference time of 95 milliseconds and a neural network processor utilization of 28%. After fusion, the number of data moves decreased to one, the inference time was reduced to 35 milliseconds, and the neural network processor utilization increased to 72%, meeting real-time inference requirements.

[0176] 1.4 Data Acquisition and Preprocessing;

[0177] (1) Interruption triggers data acquisition;

[0178] The data acquisition program, written in C++, first initializes the GPIO pins and I2C bus. It then opens the GPIO device file using a system call to obtain the device descriptor; next, it configures a specified GPIO pin to trigger an interrupt on the rising edge using a system call, and binds an interrupt handler function. Finally, it sets the corresponding slave device address for each sensor using the I2C slave address setting command, ensuring normal communication with each sensor.

[0179] In the interrupt handler, the acquisition thread is woken up using a thread wake-up function, and its priority is set to 50 using a thread priority setting function. After being woken up, the acquisition thread sends a data read command to the corresponding sensor via the I2C bus, reads the 16-bit digital signal returned by the sensor, and then converts the digital signal into actual temperature and humidity values ​​according to the sensor's datasheet using code.

[0180] After data conversion, the data is inserted into a data table using SQLite's C interface functions. The SQL statement format includes the current timestamp, location ID, temperature value, and humidity value. The current timestamp is obtained using a high-precision clock function with millisecond-level accuracy. The location ID is set to 1 (battery compartment), 2 (motor control module), 3 (flight control system), and 4 (power interface) based on the sensor deployment location. Simultaneously, a timer creation function is used to create a scheduled task that performs data cleanup every hour, calling SQLite interface functions to execute SQL statements deleting data older than 2 hours, ensuring controllable database storage resources.

[0181] The data collection program was compiled into an executable file using a cross-compilation tool, pushed to the specified directory on the development board, granted execution permissions via command, and then started via command. In actual testing, 1200 data points were collected continuously for 1 hour without loss, and the CPU utilization rate remained stable at around 8%.

[0182] (2) Data preprocessing;

[0183] A data preprocessing script was written using Python. First, the database was connected through the SQLite Python interface. Then, SQL statements were executed to read the temperature and humidity data for the most recent 2 hours and store the data in a Pandas data frame.

[0184] To fill missing data in the data frame, the missing temperature and humidity data are filled using the mean of the previous 5 seconds through the sliding window mean fill function of the data frame. Then, outlier removal is performed by calculating the mean and standard deviation of the data within the sliding window every 5 seconds, and using data filtering statements to remove outliers that exceed the range of "mean - 2 standard deviations" to "mean + 2 standard deviations".

[0185] After data cleaning, sliding window normalization is performed. Using a 1-hour sliding window, the minimum and maximum values ​​of temperature and humidity are calculated within each window. Then, the temperature and humidity data are normalized to the [0,1] interval using a normalization formula.

[0186] Finally, the normalized data is reorganized according to monitoring location and time step to form a tensor with dimensions "4×120×2", where 4 represents 4 monitoring locations, 120 represents 120 time steps corresponding to 2 hours, and 2 represents the two features of temperature and humidity. The tensor is saved as a specified format file using a data saving function for subsequent model inference. The script execution time was tested using a timing module, and the actual preprocessing time was ≤8 milliseconds, meeting the real-time requirements.

[0187] 1.5. Tiered early warning and model training;

[0188] (1) Tiered early warning;

[0189] A tiered early warning program was developed using Python, PyQt5, and the Flask framework. First, a threshold reading module was written. This module reads threshold parameters from a configuration file using a file reading function, parses them, and stores them in a dictionary. Simultaneously, a timer is set to reread the configuration file every 10 seconds to ensure that threshold changes take effect immediately.

[0190] Then, the FlaskWeb service module was written, defining the threshold modification route, receiving threshold modification requests sent from the ground terminal, parsing the location ID and new threshold in the request, updating the corresponding parameters in the configuration file, and updating the threshold dictionary in memory, thus realizing the remote threshold modification function.

[0191] The model inference module loads the quantized model through the Python interface of the model quantization optimization tool, reads the input data from the input tensor file, calls the inference function to perform inference, obtains the predicted values ​​for 6 time steps in the next 30 minutes, and performs de-standardization on the predicted values ​​(calculate the actual temperature and humidity values ​​based on the window maximum and minimum values ​​during preprocessing).

[0192] The warning judgment module compares the destandardized predicted value with the threshold in memory, calculates the proportion exceeding the threshold, classifies the warning level according to the proportion, and triggers the corresponding warning response. For a level 1 warning, a yellow icon is displayed through the PyQt5 interface control, and the system command is called to execute the buzzer driver, causing the buzzer to sound at a frequency of 1 Hz. For a level 2 warning, an orange icon is displayed, the buzzer sounds at a frequency of 2 Hz, and AT commands containing warning information are sent to the 4G module through the serial communication library. For a level 3 warning, a red icon is displayed, the buzzer sounds continuously, and a "decelerate / return to home" command is sent to the flight controller through the UART interface.

[0193] In addition, the program includes a logging module that writes alert events to log files via a logging library for easy tracing later. The alert program can be pushed to the development board and started via a background command to ensure continuous operation.

[0194] (2) Model training strategy;

[0195] The cloud-based pre-training script is written based on TensorFlow 2.8. First, it loads 100,000 multi-dimensional datasets, reads the data file through the data reading function, cleans and standardizes the data, and then reorganizes it into an input tensor according to the format of "number of samples × time step × number of features", where the time step is 120 and the number of features is 3 (temperature, humidity, motor speed).

[0196] An initial Transformer model was constructed with 6 encoder layers, 8 attention heads, and 2048 feedforward neurons. The model's input and output were defined using a model definition function. Training parameters were configured with a batch size of 64, 200 training epochs, and the Adam optimizer with parameters β1=0.9, β2=0.999, weight decay of 1e-5, and a ReduceLROnPlateau learning rate strategy with an initial learning rate of 1e-4. The learning rate was halved if the mean squared error of the validation set did not decrease for 20 consecutive epochs.

[0197] Training begins by calling the model training function. During training, model performance is periodically evaluated on the validation set, and the model weights with the smallest mean squared error on the validation set are saved. After training, the model accuracy is evaluated on the test set using the model evaluation function to ensure that the mean squared error on the validation set is ≤1e-5. The measured mean squared error on the validation set is 8.2e-6, which meets the pre-training requirements.

[0198] The embedded fine-tuning script is also written based on TensorFlow 2.8. It loads pre-trained model weights from the cloud and freezes 90% of the model's parameters through code, only unfreezing the output layer and the last two encoder layers. It loads a local scene dataset of 5000 data points, with the data format consistent with the pre-trained dataset, and reassembles the data into an input tensor after preprocessing.

[0199] Configure fine-tuning parameters: batch size set to 32, training epochs set to 50, AdamW optimized, initial learning rate 5e-5, weight decay 5e-6. Call the model training function for fine-tuning, monitoring the mean squared error of the test set during training. After fine-tuning, the mean squared error of the test set decreased to 3.1e-6, temperature prediction error ≤0.3℃, and humidity error ≤1.2% RH. Save the fine-tuned model weights using the weight saving function and push them to the development board for subsequent inference.

[0200] The test task was "220kV transmission line inspection" (flight altitude 500m, duration 1 hour), and the verification results are as follows:

[0201] Data acquisition: 1200 data entries were collected without loss, CPU utilization was 7.2%, and storage usage was 0.9KB / hour;

[0202] Model inference: single round time 34.8ms, temperature error 0.2℃ (actual 38.2℃ → predicted 38.4℃), humidity error 1.1%RH (actual 65.3% → predicted 66.4%), NPU utilization 71%;

[0203] Warning Response: Simulated battery compartment temperature rises to 58℃, predicted to reach 62℃ in 20 minutes (Level 2 warning), 4G SMS delivered in 92ms; temperature rises to 60℃, predicted to reach 65℃ in 25 minutes (Level 3 warning), flight control responds in 45ms, safe return to base in 10 minutes;

[0204] This application addresses the core pain points of existing UAV temperature and humidity control technologies—namely, lack of prediction, low accuracy, difficulty in embedding, high resource consumption, and lack of traceability—through "Transformer model embedded software optimization + functional module collaborative design." All effects have been verified through field testing, and the technology is fully compatible with the embedded operation requirements of small and medium-sized UAVs (takeoff weight ≤ 10kg) used for multi-rotor inspection and agricultural plant protection, as detailed below:

[0205] First, it fills the gap in "no prediction" and establishes an early warning buffer window. Existing traditional monitoring solutions only achieve "real-time acquisition-upload-display" software, lacking the function of predicting temperature and humidity change trends. When faced with risks such as lithium battery temperature rise of 0.5℃ / minute or high humidity accumulation in flight control, there is no time to intervene once an anomaly is triggered. Although LSTM / ARIMA time series prediction solutions have made prediction attempts, the processing error of 2-hour long sequences exceeds 12%, failing to identify early minor anomalies. This application, through a full-process software design of "2-hour historical data input → optimized Transformer model prediction → output of the next 30 minutes (5 minutes / interval)," achieves high-precision long-term time series prediction for the first time on an embedded UAV platform, reserving a buffer window of ≥30 minutes for fault intervention. For example, when the lithium battery compartment temperature rises from 45℃ at a rate of 0.5℃ / minute, the model can predict the thermal runaway critical value of 60℃ 28 minutes in advance, avoiding the dilemma of "detection equals loss of control" in traditional solutions.

[0206] Second, it overcomes the accuracy bottleneck, reducing prediction errors to within a safe threshold. In existing technologies, the LSTM model experiences gradient decay exceeding 60% when processing 2 hours of temperature and humidity data, resulting in a temperature prediction error of 12%-15%; the ARIMA model cannot fit the nonlinear relationships of flight altitude (decreases by 0.6℃±0.1℃ per 100 meters) and motor speed (increases by 1℃±0.2℃ per 1000 rpm), and its humidity prediction error exceeds 18%, all failing to meet the threshold control requirements of critical components. This application utilizes a three-level software optimization of the Transformer model—"structural pruning-INT8 quantization-operator fusion"—combined with a training strategy of "cloud pre-training with 100,000 multi-dimensional data points + fine-tuning with 5,000 local scene data points," significantly improving the model's ability to capture long-term temporal dependencies and adapt to nonlinear data. The actual test results show that the temperature prediction error is ≤0.3℃ (relative error ≤1.2%) and the humidity prediction error is ≤1.2%RH. The accuracy is improved by more than 90% compared with the LSTM model and by more than 93% compared with the ARIMA model. It can accurately identify early anomalies such as "small temperature increase of 0.1℃ / minute" and "slow humidification of 0.5%RH", providing reliable data support for safety early warning.

[0207] Third, it adapts to embedded requirements and significantly reduces resource consumption. In existing technologies, the standard Transformer model exceeds 500 megabytes in size, and inference time on development boards supporting the RK3588 chip exceeds 200 milliseconds, resulting in high resource consumption. Traditional fixed-polling acquisition leads to CPU utilization exceeding 32%, crowding out the computing power of the flight control core task and failing to meet the needs of embedded deployment. This application achieves efficient resource utilization through software-level collaborative optimization: through Transformer three-level optimization, the model size is compressed to 65 megabytes, only 13% of the standard model, and the inference time is shortened to ≤35 milliseconds, a 72.5% improvement over the standard model. Simultaneously, a "sensor threshold-triggered software interrupt" acquisition mechanism is adopted to replace the traditional 1Hz fixed-polling, reducing CPU utilization from 32% to 8%, reducing resource consumption by 75%, and fully adapting to the resource constraints of UAV embedded platforms.

[0208] Fourth, rapid early warning response to avoid intervention delays. In existing technologies, traditional monitoring schemes rely on software polling to determine anomalies, with early warning response times exceeding 200 milliseconds. Some time-series prediction schemes can only output prediction results on personal computers, lacking automatic early warning linkage capabilities, and delays in manual intervention can easily lead to increased risks. This application constructs a tiered early warning mechanism based on software-level task priority division: Level 1 early warning response time ≤ 30 milliseconds, Level 2 early warning response time ≤ 90 milliseconds (including 4G SMS sending), and Level 3 early warning flight control response time ≤ 50 milliseconds (including "deceleration / return to base" command issuance). This improves response speed by more than 50% compared to existing software polling schemes, ensuring rapid intervention when anomalies occur and preventing crashes caused by response delays.

[0209] Fifth, it adapts to long-duration operations and meets endurance requirements. In existing technologies, after deploying the standard Transformer model, the development board consumes excessive resources, reducing the drone's 11.1-volt / 10000mAh lithium battery endurance from 4 hours to 2.5 hours. This is insufficient for operational scenarios such as power line inspection and agricultural plant protection, which require more than 3 hours of continuous operation. This application addresses this by optimizing resource scheduling at the software level: employing a "task priority division (high-priority processing for prediction, low-priority processing for data acquisition) + model hibernation during non-inference periods" strategy to control development board resource consumption. This ultimately extends the drone's endurance to 4-6 hours, improving it by more than 60% compared to the standard Transformer deployment solution, fully covering the long-duration operation requirements of small and medium-sized drones.

[0210] Sixth, it enhances flight safety and provides fault tracing capabilities. Existing technologies and traditional monitoring solutions lack historical data storage software modules. When a drone crashes due to abnormal temperature and humidity, it's impossible to retrieve the temperature and humidity change curves before the accident, making it difficult to pinpoint the root cause of the fault. Furthermore, the crash rate of drones caused by abnormal temperature and humidity is as high as 35%, posing a significant safety risk. This application improves safety and tracing capabilities through two major software measures: First, it uses an SQLite database software module to store historical data from the most recent two hours in the format of "timestamp (millisecond level)-location ID-temperature-humidity," allowing for data review to pinpoint the cause of the fault after a crash. Second, based on high-precision prediction and rapid early warning, it reduces the risk of drone crashes caused by abnormal temperature and humidity from 35% to below 14%, a risk reduction of over 60%, significantly improving flight safety.

[0211] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The solutions in the embodiments of this application can be implemented in various computer languages, such as the object-oriented programming language Java and the interpreted scripting language JavaScript.

[0212] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0213] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0214] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0215] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0216] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A method for early warning of temperature and humidity in unmanned aerial vehicles (UAVs) based on embedded optimization, characterized in that, include: A temperature and humidity prediction model is constructed using a three-level lightweight optimization algorithm based on Transformer, and then deployed on a drone using a dual-strategy deployment algorithm that combines cloud training with embedded fine-tuning. Configure the sensor change threshold corresponding to the sensor on the UAV, and collect temperature and humidity data when the degree of change of the sensor data exceeds the sensor change threshold; The temperature and humidity data are preprocessed using a mean-filling strategy, a 2σ criterion strategy for removing outliers, and a sliding window Min-Max normalization strategy to obtain preprocessed temperature and humidity data. The temperature and humidity prediction model deployed on the UAV is scheduled to perform multi-time step predictions on the preprocessed temperature and humidity data to obtain the predicted temperature and humidity. Read the pre-configured temperature and humidity warning thresholds, and use a three-level warning mechanism to issue temperature and humidity warnings for the UAV based on the predicted temperature and humidity and the temperature and humidity warning thresholds; Among them, temperature and / or humidity refer to temperature and / or humidity.

2. The UAV temperature and humidity early warning method based on embedded optimization according to claim 1, characterized in that, A temperature and humidity prediction model is constructed using a three-level lightweight optimization algorithm based on Transformer, including: Pruning the Transformer model yields the pruned Transformer model. The pruned Transformer model is then simplified and optimized to obtain a simplified and optimized Transformer model. The simplified and optimized Transformer model is subjected to INT8 quantization to obtain the quantized Transformer model. The quantized Transformer model is fused with custom operators to obtain the Transformer model after custom operator fusion, thus obtaining the temperature and humidity prediction model. The custom operator fusion refers to encapsulating the position encoding operator, multi-head self-attention operator, and layer normalization operator in the quantized Transformer model into a single operator.

3. The UAV temperature and humidity early warning method based on embedded optimization according to claim 1, characterized in that, The temperature and humidity prediction model is deployed on a drone using a dual-strategy deployment algorithm that combines cloud training and embedded fine-tuning, including: The temperature and humidity prediction model is trained in the cloud to obtain the pre-trained temperature and humidity prediction model. The pre-trained temperature and humidity prediction model is sent to a drone equipped with an RK3588 chip, and the pre-trained temperature and humidity prediction model is fine-tuned a second time using the actual operation dataset stored on the drone to obtain the pre-tuned temperature and humidity prediction model. The temperature and humidity prediction model after the second fine-tuning was deployed on a drone.

4. The UAV temperature and humidity early warning method based on embedded optimization according to claim 1, characterized in that, Configure sensor change thresholds for the sensors on the drone, and collect temperature and humidity data when the sensor data change exceeds the sensor change thresholds, including: Configure the sensor change threshold corresponding to the sensor on the UAV so that if the sensor data change exceeds the sensor change threshold, an interrupt signal is triggered. The data acquisition thread is woken up by an interrupt signal, and then the temperature and humidity data collected by the sensor is acquired through the data acquisition thread.

5. The UAV temperature and humidity early warning method based on embedded optimization according to claim 3, characterized in that, After collecting temperature and humidity data, the following is also included: A lightweight SQLite database is deployed on a drone equipped with an RK3588 chip, and the temperature and humidity data is stored through the SQLite lightweight database. After each time period, the temperature and humidity data from two time periods ago are deleted.

6. The UAV temperature and humidity early warning method based on embedded optimization according to claim 1, characterized in that, The temperature and humidity data are preprocessed using a mean-filling strategy, a 2σ criterion for outlier removal, and a sliding window Min-Max normalization strategy to obtain preprocessed temperature and humidity data, including: Temperature and humidity data from two time periods are read, and the mean of the N seconds preceding the missing values ​​is used to fill in the missing values. Outliers are then removed using the 2σ criterion, resulting in cleaned temperature and humidity data. Here, N represents a constant. A sliding window with a time period is set, and the sliding window is used to traverse the temperature and humidity data after data cleaning. The temperature and humidity data after data cleaning is normalized by Min-Max to obtain the preprocessed temperature and humidity data.

7. The UAV temperature and humidity early warning method based on embedded optimization according to claim 1, characterized in that, The temperature and humidity prediction model deployed on the UAV is scheduled to perform multi-time-step predictions on the preprocessed temperature and humidity data to obtain predicted temperature and humidity, including: The preprocessed temperature and humidity data is used as input to the temperature and humidity prediction model deployed on the UAV. The predicted temperature and humidity output by the temperature and humidity prediction model are obtained, and the predicted temperature and humidity at multiple time steps are obtained repeatedly.

8. The UAV temperature and humidity early warning method based on embedded optimization according to claim 1, characterized in that, Read the pre-configured temperature and humidity warning thresholds, and based on the predicted temperature and humidity and the temperature and humidity warning thresholds, use a three-level warning mechanism to provide temperature and humidity warnings for the drone, including: Read the pre-configured temperature and humidity warning thresholds; wherein, the temperature and humidity warning thresholds include a first warning ratio threshold, a second warning ratio threshold, and a third warning ratio threshold, which are arranged from smallest to largest. Obtain the difference between the predicted temperature and humidity and the actual temperature and humidity at the current moment, and divide the difference by the actual temperature and humidity at the current moment to obtain the proportion exceeding the threshold; If the over-threshold ratio is less than or equal to the first warning ratio threshold, a first-level warning is issued; the first-level warning includes: controlling the local interface of the UAV control terminal to display a yellow warning icon, and simultaneously calling the buzzer driver code to make the buzzer emit a warning sound at a frequency of 1 Hz. If the over-threshold ratio is less than or equal to the second warning ratio threshold and greater than the first warning ratio threshold, a second-level warning is issued. The second-level warning includes: controlling the local interface of the drone control terminal to display a yellow warning icon, calling the buzzer driver code to make the buzzer emit a warning sound at a frequency of 2 Hz, and sending a warning SMS through the 4G module. The SMS content includes the drone's current latitude and longitude, warning location, predicted temperature and humidity, and warning level information. If the over-threshold ratio is greater than the second warning ratio threshold, a level 3 warning will be issued. The level 3 warning includes: displaying a yellow warning icon on the local interface of the drone control terminal, continuously emitting a prompt sound through the buzzer, sending a voice notification through the 4G module, and controlling the drone to perform a return-to-home operation.

9. The UAV temperature and humidity early warning method based on embedded optimization according to claim 8, characterized in that, Also includes: Record warning events as log files.