- 1School of Electrical Engineering and Information, Southwest Petroleum University, Chengdu, China
- 2Power Internet of Things Key Laboratory of Sichuan Province, State Grid Sichuan Electric Power Research Institute, Chengdu, China
Temperature compensation is the main measure to solve the problem that the detection accuracy of non-dispersive infrared CO2 gas sensor is affected by temperature. As the measurement accuracy of the non-dispersive infrared CO2 gas sensor is easily affected by the ambient temperature, this article analyzes the reasons why the sensor is affected by temperature, and proposes a temperature compensation method that integrates the Whale Algorithm (WOA) and BP neural network. The whale algorithm is used to optimize the weights and thresholds of the BP neural network to build a temperature compensation model for the non-dispersive infrared CO2 gas sensor and compare the superiority with the traditional BP neural network model and particle swarm optimization (PSO) BP neural network model. The experimental results show that the temperature compensation model error of WOA-BP algorithm is lower than 30 ppm, and the average absolute error percentage is 3.86%, which is far better than BP neural network and PSO-BP neural network, and effectively reduces the influence of temperature on the accuracy of the sensor.
1 Introduction
In recent years, global climate change caused by the massive consumption of fossil fuels such as oil and coal has seriously threatened the sustainable development of human society (Qin et al., 2020; Jiang et al., 2020; Wang et al., 2022; Xiao et al., 2023a). In order to cope with global climate change, China, as a responsible big country, has committed to achieve carbon peak by 2030 and carbon neutrality by 2060. Therefore, in order to achieve the dual-carbon goal and promote sustainable low-carbon development, real-time and accurate CO2 concentration monitoring is of great significance.
At present, non-dispersive infrared (NDIR) technology is the main CO2 concentration monitoring method, and the sensors made by using NDIR technology have the advantages of wide measurement range, high sensitivity, high accuracy, fast response speed, and long lifetime (Zhang et al., 2021; Fu et al., 2023). However, relevant theories and experiments have found that the working environment temperature has a significant impact on the measurement accuracy of NDIR gas sensors. Therefore, it is important to take measures to reduce the effect of temperature on sensor performance (Moumen et al., 2016; Yasuda et al., 2012). In the existing research, the two main methods of temperature compensation commonly used are hardware compensation and software compensation (Wang et al., 2013). Hardware compensation is to reduce temperature interference by adding hardware circuits and related components. Pei et al. (2021) carried out hardware compensation for infrared CO2 gas sensor through the constant temperature control module, which effectively suppressed the temperature drift phenomenon. However, due to the high production cost and poor versatility of the hardware compensation method, the software compensation method is often chosen in practical applications. Software compensation is the fusion of data through segmented linear interpolation, multi-parameter regression analysis, artificial intelligence algorithms and so on. Tian et al. (2017) used the least square method to get the compensation results at different temperatures. Zhang et al. (2009) used radial basis function (RBF) neural networks to compensate the temperature of carbon monoxide gas sensors. The gas sensor developed by Liu et al. (2017) used a BP neural network temperature compensation model. By combing through the literature, it is found that BP neural network is a common software temperature compensation method with powerful nonlinear mapping and learning ability. However, it also has some drawbacks, such as easily falling into local optimal solutions and being sensitive to initial weights and threshold settings. To overcome these shortcomings, a number of intelligent algorithms have been proposed in recent years to optimize BP neural networks: Li et al. (2018) proposed an adaptive artificial bee colony optimization BP neural network method for temperature compensation of infrared gas sensors. Gu et al. (2021) used GA-BP neural network for humidity compensation of sensors. Chen et al. (2017) proposed a hybrid particle swarm optimization error backpropagation (PSO-BP) neural network prediction algorithm for temperature and pressure compensation of SF6 gas sensors. Mao et al. (2016) introduced an improved particle swarm optimization algorithm based on particle survival value and simulated annealing to optimize the BP neural network for temperature compensation of methane gas sensors. The above optimization algorithms have improved the performance of the BP neural network to a certain extent while reducing the impact of temperature on gas sensors. However, there are also disadvantages such as low temperature compensation accuracy and poor stability.
In summary, this paper proposes a model based on the fusion of whale algorithm and BP neural network for temperature compensation of non-dispersive infrared CO2 gas sensor. The whale algorithm is used to optimize the initial weights and thresholds of BP neural network with advantages such as fast convergence speed, ability to avoid falling into the local optimal solution, strong robustness, few adjustment parameters, and easy operation (Zheng et al., 2019), which can effectively avoid BP neural network falling into the local optimal solution and thus improve the global search ability. The experimental results verify the feasibility and superiority of the proposed algorithm, and show that WOA-BP algorithm has a good temperature compensation effect.
2 Effect of temperature on detection accuracy of non-dispersive infrared CO2 gas sensors
2.1 Effect of temperature on absorption coefficient
The principle of operation of non-dispersive infrared gas sensors is based on the fact that gas molecules selectively absorb specific wavelengths of infrared light as it passes through them. After being absorbed by a certain concentration of carbon dioxide gas, the light intensity emitted by an infrared light source will be weaken, and its attenuation relationship follows the Lambert Beer law (Hernán R.,2021). According to this law, the concentration C of CO2 can be derived as:
In Eq. 1, I0 and I respectively represent the light intensity of infrared rays before and after passing through the gas to be measured, C represents the concentration value of the gas to be measured, L is defined as the length of interaction between infrared light and gas from the infrared light source to the detector, and K is the absorption coefficient.
The CO2 gas absorption coefficient at standard atmospheric pressure can be expressed by the following equation:
In Eq. 2, VCO2 = 2.706 × 1,019 cm−3, S(T) is the molecular line intensity of gas, fL(λ) is the Lorentz line, fG(λ) is the Doppler broadening, where both spectral line intensity and Doppler broadening are affected by temperature.
When the temperature rises, the activity of CO2 gas molecules increases, which leads to an increase in its ability to absorb infrared light, that is, the absorption coefficient becomes larger (Zhu et al., 2017). Therefore, an increase in temperature leads to a decrease in the light intensity received by the sensor’s measurement channel. This weakened light intensity can cause the sensor to overestimate the concentration of CO2 gas, which can lead to large measurement results.
2.2 Effect of temperature on infrared light source
Infrared light source is one of the core components of non-dispersive infrared CO2 gas sensor, and its performance can also affect the detection accuracy of the sensor. Considering the light source as an approximate blackbody, according to Planck’s law, the emissivity of the light source is a function of wavelength and temperature, and its relationship can be described by the following equation:
In Eq. 3, λ is the wavelength; T is the temperature; h is the Planck constant; C is the speed of light; k is the Boltzmann constant.
According to the Stefan-Boltzmann law, the relationship between the total emission of a light source and the temperature is as follows:
In the formula, σ is the Stefan-Boltzmann constant. According to Formulas 3, 4, temperature will affect the peak wavelength and total irradiance of the light source. When the temperature rises, the peak wavelength will move towards the short wavelength, and the total irradiance will increase.
2.3 Effect of temperature on filter
The central wavelength of the filter will shift as the temperature changes. The temperature change will make the filter material expand or contract, resulting in the filter center wavelength offset, which affects its selective performance and thus triggers an error in the detector’s received signal.
2.4 Effect of temperature on electronic components
The change of temperature will cause the temperature drift of electronic components, which will change the various parameters of electronic components (especially semiconductor components) and bring noise, thus affecting the measurement accuracy.
3 Temperature compensation model based on WOA-BP algorithm
3.1 BP neural network
BP neural network is composed of input layer, hidden layer and output layer, and each layer consists of multiple neuron nodes (Xiao et al., 2022). The principle is: after the sample data input, the weight connection and activation function between the layers are calculated to get the output results; then according to the error between the actual output value and the theoretical value, the weights and thresholds are adjusted by reverse calculation to gradually reduce the error and improve the fitting ability of the network until the predetermined stopping condition is reached. The topology of the BP neural network is shown in Figure 1.
BP neural network has the advantages of solving nonlinear problems and strong adaptability. However, its performance and stability are affected by the initial weight setting, there is a risk of falling into local optimal solutions, and its convergence speed is slow, making it unsuitable for scenarios that require fast feedback. These issues are difficulties that need to be solved in the current research.
3.2 WOA algorithm
The WOA algorithm is a new optimization algorithm based on the migration and hunting behaviors of whales in nature, which constructs mathematical models by simulating the whales’ behaviors such as searching, rounding up prey and feeding with bubble nets.
The main mathematical model of the algorithm is as follows:
In Eq. 5,
The first and second parts of the model simulate the encircling predation method and the spiral bubble net predation method, respectively. In the process of approaching the prey, the whale optimization algorithm randomly selects one of the above two predation behaviors based on the probability p and the probability of selecting each behavior is 50%.
During the whales’ food search phase, the system randomly selects an individual whale and updates the positions of other whales. This updating mechanism increases the randomness of the exploration process and also strengthens the search ability of the global optimal solution of the WOA algorithm.
3.3 Construction of WOA-BP temperature compensation model
Aiming at the problem that a single BP neural network is sensitive to the setting of initial weights and thresholds, and easy to fall into the local optimal solution, which leads to low accuracy, this paper proposes an optimization model combining WOA algorithm and BP neural network for temperature compensation of non-dispersive infrared CO2 sensors. This method can reduce the impact of initial weights and thresholds on the performance of BP neural networks, thus improving the prediction accuracy and stability of BP neural networks. The specific flow of WOA optimized BP neural network to establish the temperature compensation model is shown in Figure 2.
4 Experiment and analysis of temperature compensation model for non-dispersive infrared CO2 gas sensor
4.1 Experimental device
The self-developed non-dispersive infrared CO2 gas sensor was chosen as the object of the experiment. The sensor chooses STM32 as the microprocessor, the infrared light source uses EMIRS 200 and the detector chooses HTS-E21-F3.91/F4.26 thermopile infrared detector. The structure of the experimental device is shown in Figure 3.
As shown in Figure 3, the infrared light is absorbed by a certain concentration of CO2 gas and transmitted to the detector, and the detector will output the corresponding electrical signal. Since the signal is very weak, it needs to be processed by the weak signal circuit to meet the requirements. Then, the signal is input to the microprocessor after A/D conversion circuit, at the same time, the temperature sensor also needs to collect the signal and transmit to the MCU. Finally, a more accurate CO2 concentration can be obtained after the received CO2 concentration and temperature are passed through the WOA-BP temperature compensation model.
4.2 Sample data collection and processing
The measured concentration Ct is obtained by passing CO2 gas with a standard concentration of C into the gas sensor, and the temperature measurement value is T. Ct and T are used as inputs to the WOA-BP model, and the corrected gas concentration C is obtained after model temperature compensation. The principle of gas sensor temperature compensation is shown in Figure 4.
Five temperature points within the range of [5, 45]°C were selected for the experiment, and the experiment was conducted in a high-low temperature and humidity chamber. The atmospheric pressure was set as standard atmospheric pressure and the humidity was constant at 60%. The temperature of the experiment chamber was adjusted to test points at 5, 15, 25, 35°C, and 45°C successively. At these 5 temperature test points, the non-dispersive infrared CO2 gas sensor is passed into the concentration of 100, 300, 500, 700, 900, 1,100, 1,500, and 2,000 ppm CO2 gas configured by the gas diluter, and 40 sets of sample data will be obtained, of which 30 sets of data are used as the training set and the rest as the test set. The experimental data are shown in Table 1. In order to speed up the convergence of the model and avoid local optimal solutions, mapminmax method is first used to normalize the sample data in the range [−1, 1]. The formula is as follows:
In Eq. 6, x is the sample data or temperature, xmim is the sample data and temperature minimum, and xmax is the sample data and temperature maximum.
4.3 Parameter setting of WOA-BP temperature compensation model
The maximum number of training times of the BP neural network is set to be 1,000, and the expected minimum error is 0.000001; the network adopts a 3-layer structure, and due to the fact that the input values are gas sensor concentration measurement values and temperature values, and the output values are concentration prediction values, the number of nodes in the input and output layers is 2 and 1, respectively. Usually, the number of nodes in the hidden layer is not unique, and the range of the number of nodes can be determined by the Eq. 7, and the optimal number of nodes can be selected by training the mean square error.
In Eq. 7, l is the number of nodes, m is the number of nodes in the input layer, n is the number of nodes in the output layer, α is the coefficient, which can be 1 to 10. Through the formula calculation, the value range of l is 2–11, and the following results are obtained by inputting it into the model calculation:
As shown in Figure 5, the minimum mean square error is 0.00143, and the corresponding number of hidden layer nodes is 9. Therefore, 9 is chosen as the number of hidden layer nodes in this experiment. In addition to the above settings, the parameter settings of WOA algorithm in this experiment are shown in Table 2.
4.4 Compensation results and error analysis
After setting the parameters of the WOA-BP model, the data were brought into the model for training, while the PSO-BP algorithm and a single BP neural network were introduced for comparative analysis in order to verify the superiority of the WOA-BP algorithm. Figures 5, 6; Table 3 show the results of temperature compensation after training of these three models.
According to the analysis of Figure 6, the temperature compensation effect of WOA-BP model is the best, and the compensation value basically coincides with the standard value. Compared with the single BP neural network, the accuracy has been greatly improved, and it is better than the PSO-BP temperature compensation model.
As can be seen from Table 3; Figure 7, the traditional BP neural network has the worst compensation effect, the maximum error reaches 717.42 ppm, the minimum error also reaches 126.44 ppm, and the average error is the largest; the PSO-BP model improves the accuracy compared to the BP model, but the error is still larger, in the range of ±494 ppm; compared to the BP model and PSO-BP model, the WOA-BP model has the smallest error, which is only in the range of 30 ppm. Compared with the BP model and PSO-BP model, the WOA-BP model has the smallest error, only in the range of 30 ppm, which is much smaller than the compensation error of the previous two models, and the error fluctuation is the smallest.
Therefore, the above results show that the accuracy and stability of the WOA-BP temperature compensation model are much higher than the traditional BP neural network and PSO-BP algorithm, which greatly reduces the influence of temperature on the non-dispersive infrared CO2 gas sensor and improves the performance of the sensor.
5 Conclusion
This paper analyzes the reasons why the non-dispersive infrared CO2 gas sensor is affected by temperature and proposes a temperature compensation method based on the optimization of BP neural network by WOA algorithm, and verifies that the proposed algorithm has higher compensation accuracy by comparing it with the traditional BP neural network and PSO-BP algorithm. The experimental results show that after the temperature compensation by WOA-BP algorithm, the measurement error of the sensor is within 30 ppm, which effectively reduces the influence of the sensor by temperature and improves the sensor accuracy. This study provides a new method for the temperature compensation of non-dispersive infrared CO2 gas sensor.
Data availability statement
The original contributions presented in the study are included in the article/Supplementary material, further inquiries can be directed to the corresponding author.
Author contributions
MS: Writing–original draft, Investigation, Validation. YC: Data curation, Writing–review and editing. QL: Writing–review and editing. YW: Software, Writing–review and editing. JL: Writing–review and editing. ZC: Writing–review and editing. XL: Writing–review and editing. AZ: Writing–review and editing.
Funding
The author(s) declare that financial support was received for the research, authorship, and/or publication of this article. This study was supported by the Opening Fund of Power Internet of Things Key Laboratory of Sichuan Province (No. PIT-F-202207).
Acknowledgments
This research thanks for the comments from reviewers. The authors would like to take this opportunity to thank the data collection assistants and the respondents who responded to the questionnaire.
Conflict of interest
The authors declare that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.
Publisher’s note
All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article, or claim that may be made by its manufacturer, is not guaranteed or endorsed by the publisher.
References
Chen, Y., Chang, J., Shen, W., Pei, Y., and Bian, X. (2017). SF6 gas sensor based on improved BP neural network. J. Electron. Meas. Instrum. 31, 1582–1588. doi:10.13382/j.jemi.2017.10.008
Fu, L., You, S., Li, G., and Fan, Z. (2023). Enhancing methane sensing with NDIR technology: current trends and future prospects. Rev. Anal. Chem. 42, 6–15. doi:10.1515/revac-2023-0062
Gu, F., Xing, J., Li, L., Pei, Y., Huang, Y., and Zhang, J. (2021). Research on humidity compensation of infrared CO2 sensors based on GA-BP neural network. J. Sens. Technol. 34, 720–727. doi:10.3969/j.issn.1004-1699.2021.06.002
Hernán, R. (2021). Seven derivations of the Beer-Lambert law. Spectrosc. Lett. 54, 133–139. doi:10.1080/00387010.2021.1873149
Jiang, L., Liu, X., Ge, Q., Cui, L., and Du, X. (2020). Research on the trend and countermeasures of Energy structure transformation in China. Energy China 42, 15–19. doi:10.3969/j.issn.1003-2355.2020.09.003
Li, C., and Mao, X. (2018). Temperature compensation of infrared gas sensors based on AABC-BP algorithm. J. Sens. Technol. 31, 1472–1477. doi:10.3969/j.issn.1004-1699.2018.010.003
Liu, Z., and Yang, L. (2017). Gas sensor temperature compensation based on BP artificial neural network. Instrum. Technol. Sensors 4, 10–12.
Mao, Q., Yu, Z., and Wang, X. (2016). Temperature compensation of infrared gas sensors based on improved PSO algorithm. Infrared Technol. 38, 499–504.
Moumen, S., Raible, I., Kraub, A., and Wollenstein, J. (2016). Infrared investigation of CO2 sorption by amine based materials for the development of a NDIR CO2 sensor. Sensors Actuators B:Chemical. 236, 1083–1090. doi:10.1016/j.snb.2016.06.014
Pei, Y. (2021) Research on an infrared CO2 gas sensor system with constant temperature and low humidity control function [master's thesis]. Nanjing(JS): Nanjing University of Information Technology.
Qin, P., Xu, H., Liu, M., Xiao, C., Forrest, K., Samuelsen, S., et al. (2020). Assessing concurrent effects of climate change on hydropower supply,electricity demand,and greenhouse gas emissions in the Upper Yangtze River Basin of China. Appl. Energy 279, 115694. doi:10.1016/j.apenergy.2020.115694
Tian, L. (2017) Research on temperature and humidity compensation algorithms for CO and O3 gas detectors [master's thesis]. Shenyang(LN): Northeastern University.
Wang, H., Zhang, W., You, L., Yuan, G., Zhao, Y., and Jiang, Z. (2013). Back propagation neural network model for temperature and humidity compensation of non dispersive infrared methane sensors. Instrum. Sci. Technol. 41, 608–618. doi:10.1080/10739149.2013.816965
Wang, L., Qi, C., Xiong, W., and Jiang, H. (2022). Recent advances in fixation of CO2 into organic carbamates through multicomponent reaction strategies. J. Catal. 43, 1598–1617. doi:10.1016/S1872-2067(21)64029-9
Xiao, H., Gan, H., Yang, P., Li, L., Li, D., Hao, Q., et al. (2023b). Robust submodule fault management in modular multilevel converters with nearest level modulation for uninterrupted power transmission. IEEE Trans. Power Deliv. 39, 931–946. doi:10.1109/TPWRD.2023.3343693
Xiao, H., He, H., Zhang, L., and Liu, T. (2023a). Adaptive grid-synchronization based grid-forming control for voltage source converters. IEEE Trans. Power Syst. 39, 4763–4766. doi:10.1109/TPWRS.2023.3338967
Xiao, R., Jin, S., Zhuang, Q., Zhou, P., and Feng, X. (2022). Research on the prediction model of liquid holdup based on WOA-BP algorithm. Chem. Eng. 50, 67–73. doi:10.3969/j.issn.1005-9954.2022.01.014
Yasuda, T., Seiichiro, Y., and Akira, T. (2012). Comparison of the characteristics of small commercial NDIR CO2sensor models and development of a portable CO2 measurement device. Sensors 12, 3641–3655. doi:10.3390/s120303641
Zhang, Q., Zhou, L., He, Y., Zhao, L., and Hu, W. (2021). Research progress of non-dispersive infrared gas sensors. Laser Infrared 51, 1272–1278. doi:10.3969/j.issn.1001-5078.2021.10.002
Zhang, X., Zhang, M., and Li, X. (2009). Temperature compensation of electrochemical CO gas sensor based on RBF neural network. J. Sens. Technol. 22, 11–14.
Zheng, Y., Li, Y., Wang, G., Chen, Y., Xu, Q., Fan, J., et al. (2019). A Novel hybrid algorithm for feature selectionbased on whale optimization algorithm. IEEE Acces 7, 14908–14923. doi:10.1109/ACCESS.2018.2879848
Keywords: CO2 gas sensor, non-dispersive infrared, WOA algorithm, BP neural network, temperature compensation
Citation: Su M, Chen Y, Li Q, Wei Y, Liu J, Chang Z, Liu X and Zhang A (2024) Temperature compensation model for non-dispersive infrared CO2 gas sensor based on WOA-BP algorithm. Front. Energy Res. 12:1407630. doi: 10.3389/fenrg.2024.1407630
Received: 27 March 2024; Accepted: 23 April 2024;
Published: 09 May 2024.
Edited by:
Wei Qiu, Hunan University, ChinaReviewed by:
Congshan Li, Zhengzhou University of Light Industry, ChinaYikui Liu, Stevens Institute of Technology, United States
Copyright © 2024 Su, Chen, Li, Wei, Liu, Chang, Liu and Zhang. This is an open-access article distributed under the terms of the Creative Commons Attribution License (CC BY). The use, distribution or reproduction in other forums is permitted, provided the original author(s) and the copyright owner(s) are credited and that the original publication in this journal is cited, in accordance with accepted academic practice. No use, distribution or reproduction is permitted which does not comply with these terms.
*Correspondence: Qian Li, c3dwdWxpcWlhbkAxNjMuY29t