# A Wireless Multisensor Node for Long-Term Environmental Parameters Monitoring

Authors: Deguang Li; Tianhao Wu; Xiaohui Li; Qiurui He; Zhanyou Cui
Journal: Journal of Electrical and Computer Engineering
 (2020)

---

## Abstract

Environmental quality is a great concern to everyone, in order to realize the collection, upload, management, and visualization of parameters of atmospheric environment in real time. We propose a cheap, low-power, and fast deployment wireless sensor node for environmental monitoring, consisting of STM32 MCU, ESP8266, light sensor, rain sensor, UV sensor, seven-in-one sensor (including temperature, humidity, PM2.5, PM10, CO2, formaldehyde, and TVOC), and solar automatic tracking module. A customized μC/OS-III runs on the node, which controls the transmission of environment parameters collected by each sensor to the cloud server through the wireless network, and then the server receives, stores, and visualizes the data. In actual test, the node collects data once an hour, and the running power of the node is low and stable. Experimental results show that the node could achieve accurate collection and transmission and display the environmental data, and solar automatic tracking module could meet long-term running of the node in the night and continuous rainy days.


---

## Body

## 1. Introduction

With the development of human society, environmental pollution has become the first problem to be solved in the process of human development. Many researches have shown that many human diseases are caused by environmental problems; for example, aerobic exercise under air pollution could increase the risk of nose, pharynx, trachea, bronchus, and lungs, and ultraviolet radiation could cause human skin aging [1]. National Aeronautics and Space Administration (NASA) [2] points out that glaciers have shrunk, ice on rivers and lakes is melting ahead of time, plant and animal habitats have changed, and trees bloom ahead of expected dates due to global climate change. The main impact on climate change is mainly caused by CO2 emissions according to the European Commission [3]. Kench et al. [4] found that if the temperature exceeds 32.2 centigrade, the infant birth rate increases by 5%, the length of the gestation period is reduced by an average of 6.1 days, and some babies are even born two weeks earlier. If climate change is ignored, global per capita (GDP) will be affected by climate and will fall by 7.22%, and it will affect human intelligence by 2100. As environmental quality is directly related to human sustainable development, real-time atmospheric environment monitoring is the top priority of environmental governance.At present, environmental monitoring has been widely concerned. According to the monitoring scenarios, it can be divided into urban environmental monitoring and outdoor environmental monitoring. Urban environmental monitoring [5] mainly consists of the following subgroups: air pollution [6], light pollution monitoring [6], structural health [7], noise monitoring [8], and waste management [9]. The scenarios of outdoor environmental monitoring are always large-scale, long-distance, typical application scenarios that include intelligent agriculture [10–12], water quality monitoring [13], forest fire [14], etc. No matter urban environmental monitoring or outdoor environmental monitoring, some key environmental parameters should be monitored. Among them, the TVOC organic compounds in the atmospheric environment are dangerous to the human central nervous system and respiratory system, urban noise also causes specific damage to the auditory system, and urban light pollution and heat island effect also have some impact on human beings. Thus, in this paper, environmental parameters such as TVOC, noise, CO2, formaldehyde, UV intensity, light intensity, PM2.5, PM10, temperature, and humidity are monitored by the wireless sensor node.Traditional fixed environmental monitoring stations are expensive in construction and management, and most of the data are recorded and entered manually, which is cumbersome and error-prone. Wireless sensor network (WSN) is an emerging key technology for future environmental monitoring, which are a low-cost, fast deployment, low maintenance and high quality service. WSN is usually made up of thousands of smart sensor nodes which monitor physical or environmental conditions; the specification and design of the platform and of all its components require cheap, scalable, and intelligent properties. The use of wireless sensor nodes had been proven to be faster in data collecting, less labor-intensive, and more cost-effective [14]. In order to conveniently and accurately monitor the atmospheric environment data, it is necessary to develop small-scale automatic environmental monitoring sensor nodes, which require miniaturization, intelligence, and scalability and can automatically connect to the Internet, automatically collect data, and send the data to the host server in intervals, so as to achieve stability and low-cost running, and can be easily deployed in batches.The node proposed in this paper is employed with customizedμC/OS-III to improve the operation efficiency and real-time data transmission. The main control chip adopts ARM STM32 chip with good expandability, which greatly improves the scalability and stability of the system. In order to meet the continuous demand of power supply, STC89C52RC is used to develop a solar energy automatic tracking module to collect solar energy and convert it into electrical energy, so as to ensure the power demand of the whole system.


## 2. Related Work

Wireless sensor network (WSN) is now widely used in environment monitoring [15, 16], which is always made up of thousands of smart sensor nodes that monitor physical or environmental conditions, such as water quality of river, soil moisture in precision agriculture, air quality, and other applications in different area. While all the application requirements of low cost, high number of sensors, fast deployment, long lifetime, low maintenance, and high quality of service are considered in the specification and design of the platform and of all its components [17], in order to fill all these requirements, many researchers put forward different sensor node design, network networking, data transmission, and node data prepossessing and data display for different application scenarios.Zhang et al. [11] presented an information monitoring node based on automatic tracking solar-powered panel for paddy field environment; the node consists of information collecting sensors, STM32 MCU, LCD, GPRS, automatic tracking solar-powered module, and monitoring interface. Joris et al. [18] proposed an autonomous Sigfox wireless sensor node for environmental monitoring, which consists of ATMEGA328P, low-power wide-area network protocols communication protocol, and a range of sensors; the characteristic of the node design is that the communication protocol has been optimized for low power consumption and offers competitive subscription prices. Maitra et al. [19] proposed a platform which was consisted by power source, sensors, microcontroller, wireless transceiver, gateway device, and cloud services, the platform that can be easily modified depending on the application and can be rapidly deployed; the main design idea enables a wide range of application specific layers to interact with other sublayers of the whole structure seamlessly, which is similar to many researches. Among the nodes listed above [11, 17, 18], the master control chip is ARM. Patil [17] also noticed that ARM microcontroller supports different features and algorithms for the development of industrial automation systems; many types of sensors using different wired or wireless technology were easily connected to the controller; also the chip is cheap and we can monitor and control the wireless sensor network remotely using Internet and web server. Also in many other scenarios, the master control chip is also based on ARM platform; thus, in this paper, we also use the chip based on ARM as the master control chip in the node.While the wireless network used in [11] is based on GPRS, although the speed of GPRS is fast and supports long transmission distance and simple networking, however, due to the limitation of the station coverage, the signal is relatively weak in poor communication conditions and there is a communication dead angle. Thus, in order to overcome these limitations, various network communication technologies are deployed for different scenarios. Low-power wide-area network (LPWAN) protocols, such as LoRa (Semtech) [12], Sigfox (Sigfox Company) [13], or NBIoT (3GPP), have been developed; these protocols address the need for a long range communication system with limited data to transmit and exhibit increased energy efficiency. Also, some wireless node was based on RFID in [20, 21]. Mois et al. [22] presented three different IoT-based wireless sensors for environmental monitoring: one employing User Datagram Protocol based Wi-Fi communication, one communicating through Wi-Fi and Hypertext Transfer Protocol (HTTP), and a third one using Bluetooth Smart; all these three systems were implemented and proved the feasibility, energy autonomy, usability, and Internet connectivity facility; the experiment result revealed that they can be good candidates for IoT-based solutions. Al Azam et al. [23] also used Wi-Fi to monitor and control the environmental; unlimited control could be exercised by electrical parameters of an interconnected network operations.Behera et al. [24] noticed that energy is a major constraint in the design of a WSN and proposed an improvement of the existing stable election protocol that implements a threshold-based cluster head selection for a heterogeneous network. Automatic tracking solar-powered module is used for consistent power supply in many researches for long-term running, which is very important for the node in WSN; thus in this paper, we also make use of automatic tracking solar-powered module for the node. Many other researches proposed different methods for efficiency routing and data secure such as Ahmad et al. [25] who presented the design and test of IEEE 802.15.4-compliant smart IoT nodes with multi-hop routing. Wu et al. [26] proposed a novel framework with dedicated combination of data prediction, compression, and recovery to simultaneously achieve accuracy and efficiency of the data processing in clustered WSNs. Bezzateev et al. [27] designed a system which allows protecting a sensor network from unauthorized topology changes keeping the property of scalability and security, which enables efficient and fast network initialization, received information processing, and handling potential topology changes.Based on previous works, we propose a low-cost, low-power, and fast deployment micro wireless sensor environment test node, which uses STM32 as the main control chip, ESP8266 module for Wi-Fi communication, light intensity sensor, raindrop sensor, UV intensity sensor, seven-in-one sensor, and solar automatic tracking module, and the node is equipped with a customizedμC/OS-III for control and management.


## 3. Overview of System Design

The system mainly consists of five parts, which are sensor node, gateway, solar power system, database server, and web server; the overall framework of the system is shown in Figure1.Figure 1
Overview of the system design.Sensor node monitors real-time environmental data information and sends the collected data to the nearby gateway through Wi-Fi. Gateway collects the received data and sends it to the database server through the external network. Database server receives the data and maintains it, and the web server visualizes the data for human interaction. In order to ensure power demand of the system and continuous power operation under the condition of poor illumination, each sensor node has a full range of solar light tracking system, which can collect solar energy and store it for continuous power supply. Data acquisition, wireless transmission, data storage, and data visualization are implemented based on the hardware.


### 3.1. Hardware Design

#### 3.1.1. The Master Control Chip

The main control chip used in the node is STM32F103ZET6, which is based on ARM Cortex-M core, and has the characteristics of high performance, low cost, small size, low power consumption, compact code density, and simplified instruction set. The embedded processor is the core part in our design. And an optimized operating systemμC/OS-III runs in the processor to drive and control the equipment and complete the collection of atmospheric environmental parameters. Also, data processing program is embedded for flexible processing, safe storage, and other functions. The chip has rich I/O interfaces, 3 12-bit AD converters, 2 12-bit DA converters, and 12 DMA channels and supports peripheral timing controller, ADC, DAC, I2S, SPI, I2C, and USART, which has good scalability and stability, enough to meet the requirements of system deployment and operation, and the physical hardware connection of the node is shown in Figure 2.Figure 2
Hardware connection of the node.


#### 3.1.2. Sensors

The nodes in this paper include five sensors; the sensors are UV sensor, GT-302 light sensor, raindrop sensor, noise sensor, and SM300D2 seven-in-one sensor (including temperature, humidity, PM2.5, PM10, formaldehyde concentration, CO2 concentration, and TVOC concentration). The node collects eleven types of environmental data, and some parameters of each sensor are shown in Table 1.Table 1
Detail parameters of each sensor.
SensorParameterVoltage (V)RangePrecisionTransmissionGY-302Light intensity3.3-50∼65535lx1lxI2CUVUV intensity3.3-50–12UV±1 UVADC1RAINRain or not3.3-5Rain/no rainUSBVOICENoise intensity3.3-520∼150 dB±1 dBADC1SM300D2eCO25400 ppm∼5000 ppm±100 ppmUSART3eCH2O51μg∼1000 μgTVOC50μg∼2000 μgPM2.555μg∼1000 μg±10%PM1055μg∼1000 μg±10%Temperature5−40°C∼125°C±0.5°CHumidity50∼100%±3% RHThe seven-in-one sensor can simultaneously monitor seven kinds of data information such as CO2, formaldehyde concentration, PM2.5, TVOC concentration, PM10, temperature, and humidity and output data through the serial port. In addition to the three datasets of CO2 concentration, formaldehyde concentration, TVOC concentration, it needs to be warmed up for about two minutes after powering on, and the other data can be displayed immediately after powering on. The collected data can be output through the digital serial port; also, they can be output through the RS485 data bus and UART serial port. We use the UART output mode in this paper, so the sensor pins are connected to the microprocessor's PB10 and PB11, where PB10 is the USART3_TX of the microprocessor and PB11 is the USART3_RX of the microprocessor.The model of ambient light intensity sensor is GY-302; we can directly get digital output by ignoring the conversion of complex electrical signals to light intensity, and its sensitivity is close to the spectral characteristics of visual sensitivity. The GY-302 light sensor uses I2C bus to receive and transmit data, which is connected to PB3 and PA15 ports of microprocessor, respectively, and writes instructions to the sensor through I2C bus to complete one single reading of light intensity data of the environment, and then the data are transmitted to the microprocessor through I2C bus.The UV sensor used in this article is specially designed for the occasions that require high reliability and accuracy to measure the ultraviolet index (UVI) and is suitable to measure the total UV intensity of sunlight. The total intensity value can be compared with the World Health Organization ultraviolet index classification standard. This sensor can detect the ultraviolet wavelength of 200–370 nm, which has the characteristics of fast response speed and full interchange ability.Both UV sensor and noise sensor output analog signals. UV sensor is connected to the PA6 port of the microprocessor and noise sensor is connected to the PA7 port of the microprocessor. The two sensors share the ADC1 digital to analog converter of microprocessor and convert the electrical signal into 12-bit digital signal through the built-in ADC sensor.The output data of rain sensor used in this paper have the advantages of clean signal, good waveform, and strong driving ability, which outputs data through the TTL level and outputs a low level when raindrops are detected and a high level when there are no raindrops, which is connected to the PD9 port of the microprocessor.


#### 3.1.3. Wi-Fi Module

As the traffic and bandwidth required by each sensor node are very small, in order to reduce the communication cost, all nodes in this paper are not equipped with separate GPRS network. Instead, all sensor nodes in a certain area are connected to a Wi-Fi gateway, which is configured in a certain area. The gateway receives data from sensor nodes in a certain range and then uploads the data to the server for permanent storage. Deploying multiple sensors in one area to collect data at the same time can ensure the accuracy and fault tolerance of the data. If a sensor fails in this area, other nodes can still collect data normally, which helps improve the overall robustness of the system.The network topology of the node is shown in Figure3. We use Wi-Fi wireless network communication to achieve data transmission between the node and the gateway. The Wi-Fi network has a wide coverage area and can cover 100 meters without obstructions. It has high reliability and no wiring, is safe for humans, and has a small impact on the environment. It can reduce the impact on the environment when it is deployed in the field, so using the Wi-Fi protocol to connect sensors and gateways is a good choice. Based on the above considerations, we use ESP8266 wireless communication module to realize the communication function.Figure 3
Network topology of sensor nodes.In this design, the module sends AT command through the serial port to initialize the esp8266 module after the node is powered on each time. Then, the sensor packs and sends the data after receiving the data. At the same time, the ESP8266 module can work in the mode of AP and STA; at this time, the node can be used not only as the STA of wireless Wi-Fi, but also as the AP of other sensor nodes to provide data forwarding services. The gateway acts as the AP access point of the sensor nodes, and all sensor nodes are connected to the gateway through the ESP8266 module. The gateway and the sensor nodes are connected via Wi-Fi, communicate through the TCP/IP protocol, and then perform data transmission in the 2.4 GHz frequency band.


#### 3.1.4. Solar Automatic Tracking Module

This module is an important module to ensure the long-term endurance of the system. In this module, STC89C52RC chip with low energy consumption and four photosensitive resistors are used. The voltage of each photosensitive sensor is read through PCF8591chip to get the angle difference between the direct sunlight angle and the current solar panel. Then, the solar panel is moved to an angle perpendicular to the light by using ULN2003 to drive the stepping motor. This module is designed to maximize the efficiency of solar energy conversion. Compared with the traditional fixed solar system, this module can make the most reasonable dynamic adjustment according to the direct angle of the sun in different seasons and times.The realization of this design is to place the four light sensors on the four edges of the solar panel outward 45 degrees, and the position of the photosensitive resistor is shown in Figure4. Through the ADC module, the voltage of the four photosensitive resistors is converted in real time to determine the deviation of the current sun and then drive the stepping motor to make adjustment. Compared with the traditional time-based automatic adjustment method, this method has higher accuracy and simple algorithm, which can be realized without complex design.Figure 4
Position of photosensitive resistor.


### 3.2. Software Design

#### 3.2.1. Software Architecture

The software flowchart of the node is shown in Figure5. First, after powering up the node, operating system and individual sensor hardware of the node are initialized, and then two main processes are created, which are the sensor working process and the Wi-Fi working process. Detailed steps of these processes are presented as follows. Firstly, the μC/OS-III is initialized; task stack size, task priority, task control block naming, task stack setting, and startup function parameters required by all processes are defined. Three process control blocks are created, which are Start_Task_TCB (operating system process), Item_Task_TCB (sensor process), and WIFI_Task_TCB (Wi-Fi process). Then, all hardware and sensors are initialized by the main function, next, all the parameters required by the operating system process are initialized, and OSTaskCreate() function is created, which creates the Start_Task_TCB process to run the UC/os-iii operating system. Finally, the sensor work process Item_Task_TCB and WiFi process WIFI_Task_TCB are continued, created by TaskCreate() function. In the Item_Task_TCB process, five functions named STOO_Get_Data(), UV_Read_Data(), VOICE_Read_Data(), RAIN_Read_Data(), and Get_Sunlight_Value() are periodically called to get environment data from the five different sensors separately; all the data are packed and sent by the process of WIFI_Task_TCB.Figure 5
Software flowchart of the system.When the program of the sensor node works correctly, each function is ready to collect data through I2C bus, ADC module, etc. And then the data collected by the sensor are sorted and encapsulated and sent to the remote server by ESP8266 module. In this way, we can observe the changes of environmental data in real time.


#### 3.2.2. Migration of Operating System

μC/OS-III is migrated to the sensor node, which is a priority-based multitasking kernel operating system that can be tailored, upgraded, solidified, and deprived; the kernel can be trimmed to a minimum size of 4 kB, which needs very small resources to run and has very high efficiency, and the tasks can be switched in real time. During the migration, the uC-CPU, uC-LIB, and UCOS-III in the project are mainly modified, and the UCOS_BSP and UCOS_CONFIG files are configured at the same time. Finally, a lighting function is created to verify the success of the system migration.μC/OS-III operating system [28] has five task states by default, which are sleep state, ready state, run state, wait state, and interrupt service state. In this system, the μC/OS-III task is created by calling the OSTaskCreate() function, and the task code is stored in ROM, but ostaskcreate() function is required to inform the operating system about the task. After the task is completed, the task will be deleted by the OSTaskDel () function. In the single-CPU system of this article, the application needs to select the highest priority task from the ready queue of the μC/OS-III operating system by calling OSStart() or OSIntExit() or OS_TASK_SW().


#### 3.2.3. Program of Each Sensor

As SM300D2 sensor outputs all data through UART serial port, this article uses the USART3 interrupt method of STM32 microcontroller to read data, and the baud rate is 9600 bps. The sensor pins are connected to PB10 and PB11 of the microprocessor, where PB10 is the USART3_TX of the microprocessor and PB11 is the USART3_RX of the microprocessor. Each time, it will send 17 groups of nine bits of data; each group contains eight data bits and one stop bit. Then, the microcontroller receives data through the interrupt mode of USART, retain eight data bits, and discard the ninth stop bit, until receiving 17 groups of data completely and calculating their checksums. Detailed steps are as follows: (1) calling the sensor interface function in the main program, waiting for the data to be finished. (2) Then, processing the raw data and generating meteorological data. (3) In the data returned by the sensor, the first set of data is a fixed sensor address and its address is 0x3c, and the second set of data is the fixed version number of the sensor and its address is 0 × 02; therefore, as long as these two groups of fixed data are received, the later data is the environmental data collected by the sensor.The ambient light intensity sensor uses I2C bus for data transmission, and certain steps should be followed for each data acquisition. In this paper, one measurement is adopted, that is, one acquisition and data transmission carried out after each power on; then, the chip automatically powers off; the steps are shown in Figure6. The execution is first to execute the code to power on the components and write instructions to the sensor; after waiting for a certain time delay, the power supply is stable. Next, selecting the acquisition precision with code, high-precision scheme is adopted in this paper and acquisition accuracy is 1LX, thus writing a high-accuracy acquisition instruction 0 × 10 (Single_Write_BH1750 (0 × 10)) to the sensor, waiting for 180 ms and the sensor acquisition to finish; then, the data is read according to the I2C communication signal. The chip then automatically powers off and waits for the next power-on execution.Figure 6
Procedure of light intensity sensor measurement.The UV sensor is connected to the PA7 port of the microprocessor; this port is a channel for the ADC1 converter built into the microprocessor. The physical signal collected by the ambient ultraviolet intensity sensor needs signal conditioning to perform analog-to-digital conversion. In this paper, we use the ADC channel built in STM32 microprocessor to process the voltage analog signal; after conversion by ADC converter of microprocessor, the data will be compared with the UV intensity comparison table, and then the corresponding UV level will be returned. In order to ensure the accuracy of the calculation of the UV intensity, the average value of 10 conversions is calculated as the final value.The rain sensor used in this article uses a wide-voltage LM393 comparator; thus, the output data has the advantages of clean signals, good waveforms, and strong driving capabilities. At the same time, it is equipped with a potentiometer to adjust the sensitivity according to demand. The digital switch output pin is connected to the PD9 pin of the microprocessor, and the microprocessor receives the relevant level signal of the pin through the interface function int8_t RAIN_Read_Bit(). The sensor board outputs high level when there are raindrops and low level when there is no water drop.When the voice sensor is powered on, the chip starts to collect the signal and output the analog signal and automatically converts the voltage signal into the analog signal through the ADC channel of the single-chip microcomputer. Then, the function GetADCValue() is called through the interface of VOICE_Read_Data(); the function reads the ADC value 10 times in a row and then averages it to get a relatively accurate value; the corresponding voice value can be calculated by the voice formula (1):(1)voice=∑i=11010∗logvalue0.001.


#### 3.2.4. Program of Solar Automatic Tracking Module

The default operation mode of solar module is manual mode after powering on; at this time, we can switch manual mode to automatic mode through mode switch button (key_state). In manual mode, stepper motor can be, respectively, controlled to rotate in different directions by four buttons, so as to achieve the corresponding up, down, left, and right rotation of the lighting panel. In this paper, we switch working mode to automatic mode after powering on. In automatic mode, the single-chip microcomputer detects the light intensity values of the four directions of the lighting board through four photosensitive resistors on the lighting board and then controls the stepper motor to make the stepper motor always rotate in the direction of strong light intensity. When the light intensity collected by the sensors in the up and down direction and in the left and right direction is the same, stop rotating, so as to ensure that the front of the lighting board moves perpendicular to the side with the largest light intensity value to receive solar energy to the maximum.


## 3.1. Hardware Design

### 3.1.1. The Master Control Chip

The main control chip used in the node is STM32F103ZET6, which is based on ARM Cortex-M core, and has the characteristics of high performance, low cost, small size, low power consumption, compact code density, and simplified instruction set. The embedded processor is the core part in our design. And an optimized operating systemμC/OS-III runs in the processor to drive and control the equipment and complete the collection of atmospheric environmental parameters. Also, data processing program is embedded for flexible processing, safe storage, and other functions. The chip has rich I/O interfaces, 3 12-bit AD converters, 2 12-bit DA converters, and 12 DMA channels and supports peripheral timing controller, ADC, DAC, I2S, SPI, I2C, and USART, which has good scalability and stability, enough to meet the requirements of system deployment and operation, and the physical hardware connection of the node is shown in Figure 2.Figure 2
Hardware connection of the node.


### 3.1.2. Sensors

The nodes in this paper include five sensors; the sensors are UV sensor, GT-302 light sensor, raindrop sensor, noise sensor, and SM300D2 seven-in-one sensor (including temperature, humidity, PM2.5, PM10, formaldehyde concentration, CO2 concentration, and TVOC concentration). The node collects eleven types of environmental data, and some parameters of each sensor are shown in Table 1.Table 1
Detail parameters of each sensor.
SensorParameterVoltage (V)RangePrecisionTransmissionGY-302Light intensity3.3-50∼65535lx1lxI2CUVUV intensity3.3-50–12UV±1 UVADC1RAINRain or not3.3-5Rain/no rainUSBVOICENoise intensity3.3-520∼150 dB±1 dBADC1SM300D2eCO25400 ppm∼5000 ppm±100 ppmUSART3eCH2O51μg∼1000 μgTVOC50μg∼2000 μgPM2.555μg∼1000 μg±10%PM1055μg∼1000 μg±10%Temperature5−40°C∼125°C±0.5°CHumidity50∼100%±3% RHThe seven-in-one sensor can simultaneously monitor seven kinds of data information such as CO2, formaldehyde concentration, PM2.5, TVOC concentration, PM10, temperature, and humidity and output data through the serial port. In addition to the three datasets of CO2 concentration, formaldehyde concentration, TVOC concentration, it needs to be warmed up for about two minutes after powering on, and the other data can be displayed immediately after powering on. The collected data can be output through the digital serial port; also, they can be output through the RS485 data bus and UART serial port. We use the UART output mode in this paper, so the sensor pins are connected to the microprocessor's PB10 and PB11, where PB10 is the USART3_TX of the microprocessor and PB11 is the USART3_RX of the microprocessor.The model of ambient light intensity sensor is GY-302; we can directly get digital output by ignoring the conversion of complex electrical signals to light intensity, and its sensitivity is close to the spectral characteristics of visual sensitivity. The GY-302 light sensor uses I2C bus to receive and transmit data, which is connected to PB3 and PA15 ports of microprocessor, respectively, and writes instructions to the sensor through I2C bus to complete one single reading of light intensity data of the environment, and then the data are transmitted to the microprocessor through I2C bus.The UV sensor used in this article is specially designed for the occasions that require high reliability and accuracy to measure the ultraviolet index (UVI) and is suitable to measure the total UV intensity of sunlight. The total intensity value can be compared with the World Health Organization ultraviolet index classification standard. This sensor can detect the ultraviolet wavelength of 200–370 nm, which has the characteristics of fast response speed and full interchange ability.Both UV sensor and noise sensor output analog signals. UV sensor is connected to the PA6 port of the microprocessor and noise sensor is connected to the PA7 port of the microprocessor. The two sensors share the ADC1 digital to analog converter of microprocessor and convert the electrical signal into 12-bit digital signal through the built-in ADC sensor.The output data of rain sensor used in this paper have the advantages of clean signal, good waveform, and strong driving ability, which outputs data through the TTL level and outputs a low level when raindrops are detected and a high level when there are no raindrops, which is connected to the PD9 port of the microprocessor.


### 3.1.3. Wi-Fi Module

As the traffic and bandwidth required by each sensor node are very small, in order to reduce the communication cost, all nodes in this paper are not equipped with separate GPRS network. Instead, all sensor nodes in a certain area are connected to a Wi-Fi gateway, which is configured in a certain area. The gateway receives data from sensor nodes in a certain range and then uploads the data to the server for permanent storage. Deploying multiple sensors in one area to collect data at the same time can ensure the accuracy and fault tolerance of the data. If a sensor fails in this area, other nodes can still collect data normally, which helps improve the overall robustness of the system.The network topology of the node is shown in Figure3. We use Wi-Fi wireless network communication to achieve data transmission between the node and the gateway. The Wi-Fi network has a wide coverage area and can cover 100 meters without obstructions. It has high reliability and no wiring, is safe for humans, and has a small impact on the environment. It can reduce the impact on the environment when it is deployed in the field, so using the Wi-Fi protocol to connect sensors and gateways is a good choice. Based on the above considerations, we use ESP8266 wireless communication module to realize the communication function.Figure 3
Network topology of sensor nodes.In this design, the module sends AT command through the serial port to initialize the esp8266 module after the node is powered on each time. Then, the sensor packs and sends the data after receiving the data. At the same time, the ESP8266 module can work in the mode of AP and STA; at this time, the node can be used not only as the STA of wireless Wi-Fi, but also as the AP of other sensor nodes to provide data forwarding services. The gateway acts as the AP access point of the sensor nodes, and all sensor nodes are connected to the gateway through the ESP8266 module. The gateway and the sensor nodes are connected via Wi-Fi, communicate through the TCP/IP protocol, and then perform data transmission in the 2.4 GHz frequency band.


### 3.1.4. Solar Automatic Tracking Module

This module is an important module to ensure the long-term endurance of the system. In this module, STC89C52RC chip with low energy consumption and four photosensitive resistors are used. The voltage of each photosensitive sensor is read through PCF8591chip to get the angle difference between the direct sunlight angle and the current solar panel. Then, the solar panel is moved to an angle perpendicular to the light by using ULN2003 to drive the stepping motor. This module is designed to maximize the efficiency of solar energy conversion. Compared with the traditional fixed solar system, this module can make the most reasonable dynamic adjustment according to the direct angle of the sun in different seasons and times.The realization of this design is to place the four light sensors on the four edges of the solar panel outward 45 degrees, and the position of the photosensitive resistor is shown in Figure4. Through the ADC module, the voltage of the four photosensitive resistors is converted in real time to determine the deviation of the current sun and then drive the stepping motor to make adjustment. Compared with the traditional time-based automatic adjustment method, this method has higher accuracy and simple algorithm, which can be realized without complex design.Figure 4
Position of photosensitive resistor.


## 3.1.1. The Master Control Chip

The main control chip used in the node is STM32F103ZET6, which is based on ARM Cortex-M core, and has the characteristics of high performance, low cost, small size, low power consumption, compact code density, and simplified instruction set. The embedded processor is the core part in our design. And an optimized operating systemμC/OS-III runs in the processor to drive and control the equipment and complete the collection of atmospheric environmental parameters. Also, data processing program is embedded for flexible processing, safe storage, and other functions. The chip has rich I/O interfaces, 3 12-bit AD converters, 2 12-bit DA converters, and 12 DMA channels and supports peripheral timing controller, ADC, DAC, I2S, SPI, I2C, and USART, which has good scalability and stability, enough to meet the requirements of system deployment and operation, and the physical hardware connection of the node is shown in Figure 2.Figure 2
Hardware connection of the node.


## 3.1.2. Sensors

The nodes in this paper include five sensors; the sensors are UV sensor, GT-302 light sensor, raindrop sensor, noise sensor, and SM300D2 seven-in-one sensor (including temperature, humidity, PM2.5, PM10, formaldehyde concentration, CO2 concentration, and TVOC concentration). The node collects eleven types of environmental data, and some parameters of each sensor are shown in Table 1.Table 1
Detail parameters of each sensor.
SensorParameterVoltage (V)RangePrecisionTransmissionGY-302Light intensity3.3-50∼65535lx1lxI2CUVUV intensity3.3-50–12UV±1 UVADC1RAINRain or not3.3-5Rain/no rainUSBVOICENoise intensity3.3-520∼150 dB±1 dBADC1SM300D2eCO25400 ppm∼5000 ppm±100 ppmUSART3eCH2O51μg∼1000 μgTVOC50μg∼2000 μgPM2.555μg∼1000 μg±10%PM1055μg∼1000 μg±10%Temperature5−40°C∼125°C±0.5°CHumidity50∼100%±3% RHThe seven-in-one sensor can simultaneously monitor seven kinds of data information such as CO2, formaldehyde concentration, PM2.5, TVOC concentration, PM10, temperature, and humidity and output data through the serial port. In addition to the three datasets of CO2 concentration, formaldehyde concentration, TVOC concentration, it needs to be warmed up for about two minutes after powering on, and the other data can be displayed immediately after powering on. The collected data can be output through the digital serial port; also, they can be output through the RS485 data bus and UART serial port. We use the UART output mode in this paper, so the sensor pins are connected to the microprocessor's PB10 and PB11, where PB10 is the USART3_TX of the microprocessor and PB11 is the USART3_RX of the microprocessor.The model of ambient light intensity sensor is GY-302; we can directly get digital output by ignoring the conversion of complex electrical signals to light intensity, and its sensitivity is close to the spectral characteristics of visual sensitivity. The GY-302 light sensor uses I2C bus to receive and transmit data, which is connected to PB3 and PA15 ports of microprocessor, respectively, and writes instructions to the sensor through I2C bus to complete one single reading of light intensity data of the environment, and then the data are transmitted to the microprocessor through I2C bus.The UV sensor used in this article is specially designed for the occasions that require high reliability and accuracy to measure the ultraviolet index (UVI) and is suitable to measure the total UV intensity of sunlight. The total intensity value can be compared with the World Health Organization ultraviolet index classification standard. This sensor can detect the ultraviolet wavelength of 200–370 nm, which has the characteristics of fast response speed and full interchange ability.Both UV sensor and noise sensor output analog signals. UV sensor is connected to the PA6 port of the microprocessor and noise sensor is connected to the PA7 port of the microprocessor. The two sensors share the ADC1 digital to analog converter of microprocessor and convert the electrical signal into 12-bit digital signal through the built-in ADC sensor.The output data of rain sensor used in this paper have the advantages of clean signal, good waveform, and strong driving ability, which outputs data through the TTL level and outputs a low level when raindrops are detected and a high level when there are no raindrops, which is connected to the PD9 port of the microprocessor.


## 3.1.3. Wi-Fi Module

As the traffic and bandwidth required by each sensor node are very small, in order to reduce the communication cost, all nodes in this paper are not equipped with separate GPRS network. Instead, all sensor nodes in a certain area are connected to a Wi-Fi gateway, which is configured in a certain area. The gateway receives data from sensor nodes in a certain range and then uploads the data to the server for permanent storage. Deploying multiple sensors in one area to collect data at the same time can ensure the accuracy and fault tolerance of the data. If a sensor fails in this area, other nodes can still collect data normally, which helps improve the overall robustness of the system.The network topology of the node is shown in Figure3. We use Wi-Fi wireless network communication to achieve data transmission between the node and the gateway. The Wi-Fi network has a wide coverage area and can cover 100 meters without obstructions. It has high reliability and no wiring, is safe for humans, and has a small impact on the environment. It can reduce the impact on the environment when it is deployed in the field, so using the Wi-Fi protocol to connect sensors and gateways is a good choice. Based on the above considerations, we use ESP8266 wireless communication module to realize the communication function.Figure 3
Network topology of sensor nodes.In this design, the module sends AT command through the serial port to initialize the esp8266 module after the node is powered on each time. Then, the sensor packs and sends the data after receiving the data. At the same time, the ESP8266 module can work in the mode of AP and STA; at this time, the node can be used not only as the STA of wireless Wi-Fi, but also as the AP of other sensor nodes to provide data forwarding services. The gateway acts as the AP access point of the sensor nodes, and all sensor nodes are connected to the gateway through the ESP8266 module. The gateway and the sensor nodes are connected via Wi-Fi, communicate through the TCP/IP protocol, and then perform data transmission in the 2.4 GHz frequency band.


## 3.1.4. Solar Automatic Tracking Module

This module is an important module to ensure the long-term endurance of the system. In this module, STC89C52RC chip with low energy consumption and four photosensitive resistors are used. The voltage of each photosensitive sensor is read through PCF8591chip to get the angle difference between the direct sunlight angle and the current solar panel. Then, the solar panel is moved to an angle perpendicular to the light by using ULN2003 to drive the stepping motor. This module is designed to maximize the efficiency of solar energy conversion. Compared with the traditional fixed solar system, this module can make the most reasonable dynamic adjustment according to the direct angle of the sun in different seasons and times.The realization of this design is to place the four light sensors on the four edges of the solar panel outward 45 degrees, and the position of the photosensitive resistor is shown in Figure4. Through the ADC module, the voltage of the four photosensitive resistors is converted in real time to determine the deviation of the current sun and then drive the stepping motor to make adjustment. Compared with the traditional time-based automatic adjustment method, this method has higher accuracy and simple algorithm, which can be realized without complex design.Figure 4
Position of photosensitive resistor.


## 3.2. Software Design

### 3.2.1. Software Architecture

The software flowchart of the node is shown in Figure5. First, after powering up the node, operating system and individual sensor hardware of the node are initialized, and then two main processes are created, which are the sensor working process and the Wi-Fi working process. Detailed steps of these processes are presented as follows. Firstly, the μC/OS-III is initialized; task stack size, task priority, task control block naming, task stack setting, and startup function parameters required by all processes are defined. Three process control blocks are created, which are Start_Task_TCB (operating system process), Item_Task_TCB (sensor process), and WIFI_Task_TCB (Wi-Fi process). Then, all hardware and sensors are initialized by the main function, next, all the parameters required by the operating system process are initialized, and OSTaskCreate() function is created, which creates the Start_Task_TCB process to run the UC/os-iii operating system. Finally, the sensor work process Item_Task_TCB and WiFi process WIFI_Task_TCB are continued, created by TaskCreate() function. In the Item_Task_TCB process, five functions named STOO_Get_Data(), UV_Read_Data(), VOICE_Read_Data(), RAIN_Read_Data(), and Get_Sunlight_Value() are periodically called to get environment data from the five different sensors separately; all the data are packed and sent by the process of WIFI_Task_TCB.Figure 5
Software flowchart of the system.When the program of the sensor node works correctly, each function is ready to collect data through I2C bus, ADC module, etc. And then the data collected by the sensor are sorted and encapsulated and sent to the remote server by ESP8266 module. In this way, we can observe the changes of environmental data in real time.


### 3.2.2. Migration of Operating System

μC/OS-III is migrated to the sensor node, which is a priority-based multitasking kernel operating system that can be tailored, upgraded, solidified, and deprived; the kernel can be trimmed to a minimum size of 4 kB, which needs very small resources to run and has very high efficiency, and the tasks can be switched in real time. During the migration, the uC-CPU, uC-LIB, and UCOS-III in the project are mainly modified, and the UCOS_BSP and UCOS_CONFIG files are configured at the same time. Finally, a lighting function is created to verify the success of the system migration.μC/OS-III operating system [28] has five task states by default, which are sleep state, ready state, run state, wait state, and interrupt service state. In this system, the μC/OS-III task is created by calling the OSTaskCreate() function, and the task code is stored in ROM, but ostaskcreate() function is required to inform the operating system about the task. After the task is completed, the task will be deleted by the OSTaskDel () function. In the single-CPU system of this article, the application needs to select the highest priority task from the ready queue of the μC/OS-III operating system by calling OSStart() or OSIntExit() or OS_TASK_SW().


### 3.2.3. Program of Each Sensor

As SM300D2 sensor outputs all data through UART serial port, this article uses the USART3 interrupt method of STM32 microcontroller to read data, and the baud rate is 9600 bps. The sensor pins are connected to PB10 and PB11 of the microprocessor, where PB10 is the USART3_TX of the microprocessor and PB11 is the USART3_RX of the microprocessor. Each time, it will send 17 groups of nine bits of data; each group contains eight data bits and one stop bit. Then, the microcontroller receives data through the interrupt mode of USART, retain eight data bits, and discard the ninth stop bit, until receiving 17 groups of data completely and calculating their checksums. Detailed steps are as follows: (1) calling the sensor interface function in the main program, waiting for the data to be finished. (2) Then, processing the raw data and generating meteorological data. (3) In the data returned by the sensor, the first set of data is a fixed sensor address and its address is 0x3c, and the second set of data is the fixed version number of the sensor and its address is 0 × 02; therefore, as long as these two groups of fixed data are received, the later data is the environmental data collected by the sensor.The ambient light intensity sensor uses I2C bus for data transmission, and certain steps should be followed for each data acquisition. In this paper, one measurement is adopted, that is, one acquisition and data transmission carried out after each power on; then, the chip automatically powers off; the steps are shown in Figure6. The execution is first to execute the code to power on the components and write instructions to the sensor; after waiting for a certain time delay, the power supply is stable. Next, selecting the acquisition precision with code, high-precision scheme is adopted in this paper and acquisition accuracy is 1LX, thus writing a high-accuracy acquisition instruction 0 × 10 (Single_Write_BH1750 (0 × 10)) to the sensor, waiting for 180 ms and the sensor acquisition to finish; then, the data is read according to the I2C communication signal. The chip then automatically powers off and waits for the next power-on execution.Figure 6
Procedure of light intensity sensor measurement.The UV sensor is connected to the PA7 port of the microprocessor; this port is a channel for the ADC1 converter built into the microprocessor. The physical signal collected by the ambient ultraviolet intensity sensor needs signal conditioning to perform analog-to-digital conversion. In this paper, we use the ADC channel built in STM32 microprocessor to process the voltage analog signal; after conversion by ADC converter of microprocessor, the data will be compared with the UV intensity comparison table, and then the corresponding UV level will be returned. In order to ensure the accuracy of the calculation of the UV intensity, the average value of 10 conversions is calculated as the final value.The rain sensor used in this article uses a wide-voltage LM393 comparator; thus, the output data has the advantages of clean signals, good waveforms, and strong driving capabilities. At the same time, it is equipped with a potentiometer to adjust the sensitivity according to demand. The digital switch output pin is connected to the PD9 pin of the microprocessor, and the microprocessor receives the relevant level signal of the pin through the interface function int8_t RAIN_Read_Bit(). The sensor board outputs high level when there are raindrops and low level when there is no water drop.When the voice sensor is powered on, the chip starts to collect the signal and output the analog signal and automatically converts the voltage signal into the analog signal through the ADC channel of the single-chip microcomputer. Then, the function GetADCValue() is called through the interface of VOICE_Read_Data(); the function reads the ADC value 10 times in a row and then averages it to get a relatively accurate value; the corresponding voice value can be calculated by the voice formula (1):(1)voice=∑i=11010∗logvalue0.001.


### 3.2.4. Program of Solar Automatic Tracking Module

The default operation mode of solar module is manual mode after powering on; at this time, we can switch manual mode to automatic mode through mode switch button (key_state). In manual mode, stepper motor can be, respectively, controlled to rotate in different directions by four buttons, so as to achieve the corresponding up, down, left, and right rotation of the lighting panel. In this paper, we switch working mode to automatic mode after powering on. In automatic mode, the single-chip microcomputer detects the light intensity values of the four directions of the lighting board through four photosensitive resistors on the lighting board and then controls the stepper motor to make the stepper motor always rotate in the direction of strong light intensity. When the light intensity collected by the sensors in the up and down direction and in the left and right direction is the same, stop rotating, so as to ensure that the front of the lighting board moves perpendicular to the side with the largest light intensity value to receive solar energy to the maximum.


## 3.2.1. Software Architecture

The software flowchart of the node is shown in Figure5. First, after powering up the node, operating system and individual sensor hardware of the node are initialized, and then two main processes are created, which are the sensor working process and the Wi-Fi working process. Detailed steps of these processes are presented as follows. Firstly, the μC/OS-III is initialized; task stack size, task priority, task control block naming, task stack setting, and startup function parameters required by all processes are defined. Three process control blocks are created, which are Start_Task_TCB (operating system process), Item_Task_TCB (sensor process), and WIFI_Task_TCB (Wi-Fi process). Then, all hardware and sensors are initialized by the main function, next, all the parameters required by the operating system process are initialized, and OSTaskCreate() function is created, which creates the Start_Task_TCB process to run the UC/os-iii operating system. Finally, the sensor work process Item_Task_TCB and WiFi process WIFI_Task_TCB are continued, created by TaskCreate() function. In the Item_Task_TCB process, five functions named STOO_Get_Data(), UV_Read_Data(), VOICE_Read_Data(), RAIN_Read_Data(), and Get_Sunlight_Value() are periodically called to get environment data from the five different sensors separately; all the data are packed and sent by the process of WIFI_Task_TCB.Figure 5
Software flowchart of the system.When the program of the sensor node works correctly, each function is ready to collect data through I2C bus, ADC module, etc. And then the data collected by the sensor are sorted and encapsulated and sent to the remote server by ESP8266 module. In this way, we can observe the changes of environmental data in real time.


## 3.2.2. Migration of Operating System

μC/OS-III is migrated to the sensor node, which is a priority-based multitasking kernel operating system that can be tailored, upgraded, solidified, and deprived; the kernel can be trimmed to a minimum size of 4 kB, which needs very small resources to run and has very high efficiency, and the tasks can be switched in real time. During the migration, the uC-CPU, uC-LIB, and UCOS-III in the project are mainly modified, and the UCOS_BSP and UCOS_CONFIG files are configured at the same time. Finally, a lighting function is created to verify the success of the system migration.μC/OS-III operating system [28] has five task states by default, which are sleep state, ready state, run state, wait state, and interrupt service state. In this system, the μC/OS-III task is created by calling the OSTaskCreate() function, and the task code is stored in ROM, but ostaskcreate() function is required to inform the operating system about the task. After the task is completed, the task will be deleted by the OSTaskDel () function. In the single-CPU system of this article, the application needs to select the highest priority task from the ready queue of the μC/OS-III operating system by calling OSStart() or OSIntExit() or OS_TASK_SW().


## 3.2.3. Program of Each Sensor

As SM300D2 sensor outputs all data through UART serial port, this article uses the USART3 interrupt method of STM32 microcontroller to read data, and the baud rate is 9600 bps. The sensor pins are connected to PB10 and PB11 of the microprocessor, where PB10 is the USART3_TX of the microprocessor and PB11 is the USART3_RX of the microprocessor. Each time, it will send 17 groups of nine bits of data; each group contains eight data bits and one stop bit. Then, the microcontroller receives data through the interrupt mode of USART, retain eight data bits, and discard the ninth stop bit, until receiving 17 groups of data completely and calculating their checksums. Detailed steps are as follows: (1) calling the sensor interface function in the main program, waiting for the data to be finished. (2) Then, processing the raw data and generating meteorological data. (3) In the data returned by the sensor, the first set of data is a fixed sensor address and its address is 0x3c, and the second set of data is the fixed version number of the sensor and its address is 0 × 02; therefore, as long as these two groups of fixed data are received, the later data is the environmental data collected by the sensor.The ambient light intensity sensor uses I2C bus for data transmission, and certain steps should be followed for each data acquisition. In this paper, one measurement is adopted, that is, one acquisition and data transmission carried out after each power on; then, the chip automatically powers off; the steps are shown in Figure6. The execution is first to execute the code to power on the components and write instructions to the sensor; after waiting for a certain time delay, the power supply is stable. Next, selecting the acquisition precision with code, high-precision scheme is adopted in this paper and acquisition accuracy is 1LX, thus writing a high-accuracy acquisition instruction 0 × 10 (Single_Write_BH1750 (0 × 10)) to the sensor, waiting for 180 ms and the sensor acquisition to finish; then, the data is read according to the I2C communication signal. The chip then automatically powers off and waits for the next power-on execution.Figure 6
Procedure of light intensity sensor measurement.The UV sensor is connected to the PA7 port of the microprocessor; this port is a channel for the ADC1 converter built into the microprocessor. The physical signal collected by the ambient ultraviolet intensity sensor needs signal conditioning to perform analog-to-digital conversion. In this paper, we use the ADC channel built in STM32 microprocessor to process the voltage analog signal; after conversion by ADC converter of microprocessor, the data will be compared with the UV intensity comparison table, and then the corresponding UV level will be returned. In order to ensure the accuracy of the calculation of the UV intensity, the average value of 10 conversions is calculated as the final value.The rain sensor used in this article uses a wide-voltage LM393 comparator; thus, the output data has the advantages of clean signals, good waveforms, and strong driving capabilities. At the same time, it is equipped with a potentiometer to adjust the sensitivity according to demand. The digital switch output pin is connected to the PD9 pin of the microprocessor, and the microprocessor receives the relevant level signal of the pin through the interface function int8_t RAIN_Read_Bit(). The sensor board outputs high level when there are raindrops and low level when there is no water drop.When the voice sensor is powered on, the chip starts to collect the signal and output the analog signal and automatically converts the voltage signal into the analog signal through the ADC channel of the single-chip microcomputer. Then, the function GetADCValue() is called through the interface of VOICE_Read_Data(); the function reads the ADC value 10 times in a row and then averages it to get a relatively accurate value; the corresponding voice value can be calculated by the voice formula (1):(1)voice=∑i=11010∗logvalue0.001.


## 3.2.4. Program of Solar Automatic Tracking Module

The default operation mode of solar module is manual mode after powering on; at this time, we can switch manual mode to automatic mode through mode switch button (key_state). In manual mode, stepper motor can be, respectively, controlled to rotate in different directions by four buttons, so as to achieve the corresponding up, down, left, and right rotation of the lighting panel. In this paper, we switch working mode to automatic mode after powering on. In automatic mode, the single-chip microcomputer detects the light intensity values of the four directions of the lighting board through four photosensitive resistors on the lighting board and then controls the stepper motor to make the stepper motor always rotate in the direction of strong light intensity. When the light intensity collected by the sensors in the up and down direction and in the left and right direction is the same, stop rotating, so as to ensure that the front of the lighting board moves perpendicular to the side with the largest light intensity value to receive solar energy to the maximum.


## 4. Results and Discussion

Due to the limitation of novel coronavirus disease prevention and control, our system could not be tested on a large scale. Validation tests were made in our community we live in, where sensor nodes were placed outdoors in a distance of 80 meters of the network gateway, and our computer received the collected data by the communication with the gateway. When the node is powered on, related processes are created automatically, and the software and hardware of the system are initialized. In order to test the stability of the system and the endurance of solar energy, we set the time interval for automatic collection of environmental data by the program to be every one minute. In the actual test, each data collection takes about two seconds to complete. When data collection of the node is completed, the sensor sends data to the nearby gateway. The gateway receives the data through the constantly scanned network port and intercepts the strings in the data to obtain the relevant sensor parameters and the unique identification number of each node. Finally, the gateway transmits the data to the database server for storage.By practical test, we find the instantaneous core current of the STM32 system is about 0.06 A when the node is in the data acquisition state (all the sensors start to collect data), and the current of different sensors is about 0.08 A; thus, the total power consumption of nodes in data acquisition is about 0.65 W, the working current of Wi-Fi transmitting data is about 0.1 A, and thus power consumption of the node during data transmission is about 0.8 W. When the node goes into sleep state, STM32 core is in power-on state, and other circuits are in standby state, the core current of the STM32 is about 0.05 A, and the current of other standby circuits is about 0.01 A; at this time, the power consumption of the node is about 0.3 W. The node collects data once an hour, works for 1 minute every hour, and is on standby for 59 minutes; thus, the power consumption of the node in one day is about 7.4 Wh. As shown in Figure7, the instantaneous power consumption of the system over a period of time is shown. In general, the overall power consumption of system nodes is significantly lower than that of other system nodes.Figure 7
Instantaneous power consumption of the system.The environmental detection node in this paper is effective in sensing and collecting the environmental data in real time. The running power of the node is very low when it works. According to the actual measurement, the power of the whole system is only 0.35 W−0.7 W, which can meet the needs of low-power continuous work. And the sun automatic tracking module is able to track the sun's position and provide continuous power energy. At the same time, the robustness and stability of the system are guaranteed. Since we have deployed three nodes in the same observation area at the same time, all three nodes collect data, and the gateway receives the data from three nodes and sends them to the database server. When the web server displays the environment data, it calculates the mean value of the same data collected by three nodes at the same time and displays the environment data in the form of mean value.In order to display the collected environment data interactively, we designed different visualization schemes for different environment data. As shown in Figure8, there are eleven kinds of real-time environmental data, which display the collected eleven environmental data in a unified and real-time way. At the same time, we also provide a specific visualization interface for each of the environmental data, which will not be displayed due to space constraints. Figure 6 is drawn by pyecharts, the third-party visualization library of Python. Twelve list parameters, including time, temperature, humanity, PM2.5, PM10, light, UV intensity, ech2o, CO2, TVOC, rain, and noise, are passed into the line() method of pyecharts library and are distinguished by multiple colors. The x-axis represents the time period, and the other eleven list parameters are the names of eleven environment data; the content in parentheses is the unit of measurement of the data. Due to the huge amount of data, it is inconvenient to directly display all the data. Thus, the datazoom_opts() method is re-inherited in the graph and a drag handle is added, so that you can directly drag on the graph to view the eleven types of environmental data corresponding to the moment.Figure 8
Comprehensive diagram of real-time data of eleven kinds of environments.In addition to drawing the real-time data graph, in order to understand the changes of some environmental data in a period of time, the graph of data changes in a certain period of visualization is added, and different visualization technologies are used to display. As shown in Figure9, the changes of CO2, TVOC, and average temperature in the past ten days are shown. The column graph and graph chart are displayed at the same time; among them, CO2 and TVOC are displayed by column graph, and the corresponding ordinate parameters are on the left side of the graph, indicating the average CO2 and TVOC volume of the day. Average temperature is displayed with a line graph, and a signed scale is added on the right side of the graph. The right side of the y-axis is divided into adjacent scales with a difference of five, and corresponding temperature parameter is on the right side, indicating average temperature of the day. The average values of CO2, TVOC, and temperature in a day can be clearly observed through this figure, and the time cycle can be customized according to user’s demand, such as one week or one month.Figure 9
Trend of average temperature, CO2, and TVOC in a period.Figure10 shows the PM2.5 and PM10 scatter graph in the past 13 days. The scatter size in the chart is drawn according to the size of the data value, which can clearly display the environmental data. At the same time, different colors are used to distinguish the data value beyond the range. Through the graph, the changes of the environmental data in different time periods are clearly displayed, and the time cycle of the chart can be based on specific requirement, such as one week or one month. The x-axis represents the time, and the y-axis represents the average value of PM2.5 and PM10 in one day. When extracting data from the database, the average value of PM2.5 and PM10 in a day is calculated, and then the average value is inserted into the value array. According to the array value, two kinds of color scatter are used to distinguish the scatter. The size of scatter point is determined by the data value; users can more intuitively feel the difference of data. We also add a visual mapping of inverted triangle at the bottom corner, and users can click different data points on the vertical axis of inverted triangle with a mouse, which can make the small balls in the pattern similar to the value flash, which is convenient for quickly finding the location of the scattered points.Figure 10
Data changes of PM2.5 and PM10 in a period.


## 5. Conclusions

This paper designs and implements a cheap, low-power, and rapid-deployment wireless sensor environment monitoring node and realizes the real-time collection of a variety of environmental data. The data transmission between the node and the gateway is realized by using the Wi-Fi wireless network. Multiple sensors are deployed in a region to collect data at the same time, which can ensure the accuracy and fault tolerance of the data. The power of the node is low in the working and running state, which can meet the low power consumption and continuous working demand of the node. At the same time, the node is equipped with the solar automatic tracking module, which can track the orientation of the sun in real time, continue the production and storage of power energy, and meet the long-term working demand of the node in various weather environments. Finally, through experimental verification, the node achieves the goal of real-time collection and upload and management of a variety of environmental data.



---

*Source: 8872711-2020-12-28.xml*