IoT-based weather station with air quality measurement using ESP32 for environmental aerial condition study

This article discusses the design of a weather station device that also functions to measure the concentration of gases in the air. This real-time telemetry device based on the internet of things (IoT) uses the ESP32 board to process measurement data. Some of the weather parameters measured are wind speed, wind direction, humidity, ambient air temperature, air pressure, rainfall, and ultraviolet (UV) index. Meanwhile, the gas concentration parameters in the air are ozone, hydrogen, methane, ammonia, carbon monoxide, and carbon dioxide. The readings from all sensors are processed by the ESP32 board and uploaded to the server. Then a client device will receive the data set and then processed, displayed on the monitor, and stored in the form of a text file. Furthermore, the monitor and the data are used for the analysis of the surrounding air quality and weather conditions.


INTRODUCTION
Knowing the air condition in the open environment is important thing to determine the effect of pollution in an area. Especially during a pandemic of airborne diseases, such as COVID-19, everyone needs to pay attention to the surrounding air quality. Whereas, the concentration of various gases contained in the air is a determining factor for the value of air quality [1]. The more pollutant gases, the air in the area can be said to be more polluting.
Weather is a factor that also affects the quality of air condition [2]. The weather itself is an air conditioner that includes temperature, humidity, and air pressure which are included as main parameters [3]. Changes in weather conditions can be measured and observed with a device commonly called a weather station [4]. The implementation of this weather station has also been very wide in various kind of research for agriculture [5], analysis of photovoltaic power forecasting [6] and [7], measurement of weather and light intensity [8], measurement of weather and relative altitude [9], redundancy data on the internet of things (IoT) based systems [10], and analysis of the potential for wind energy [11]. On the other hand, research on the use of backscatter sensors for remote measurements was also carried out by Darsena et al. [12] and [13]. The weather station device designed in this article is used to measure weather conditions and air quality in an open area. With an IoT-based topology, this device can be used telemetry and also for remote observation [14], [15], and [16]. With this IoT technology, devices in the field can connect with other electronic devices wherever they are [17]- [22]. With this also, an environmental observer does not need to come directly to the field and TELKOMNIKA Telecommun Comput El Control  IoT-based weather ststion with air quality measurement using ESP32… (Peisma Megantoro) 1317 measure all parameters for his study needs. Observations can be made from in front of a computer screen and as long as it is connected to the internet network [23]- [25].
Weather station application device on this research featured with air quality measurement. It was because the important need to measure the air pollutant gasses. The core of this device is a microcontroller board specifically used for internet network applications. The ESP32 can act s a complete standalone system or a slave device to hosting an MCU, decreasing communication stack overhead on the main application processor [26]- [28]. Unlike its sibling ESP8266 [29]- [34], the ESP32 board has more features, especially pins that can be used for reading analog signals or analog to digital converter (ADC). This of course will be very beneficial for applications that use many analog sensors. This board is used to read all-weather and gas sensors and then send the data to the server in real-time. On the user side, an application software based on visual basic programming is designed for the purposes of observation, processing, and data storage. Visual basic programming is currently the most popular language [35] and [36]. This weather station application software is made in an informative and practical way which is suitable for both laptops and computers. It is hoped that from good interface design, the process of observing or studying weather and air conditions can proceed with focus.

METHOD
This research consists of several parts, such as; sensor technology, microcontroller, internet of things (IoT), and user interface (UI). Sensor technology is used to read the parameters which can be measured. The embedded system using is a microcontroller used in specific control applications. IoT is used as a means of data communication between instruments and users. Visual basic-based programming is used for user operation, data display, data process, data storage.

System design
This device is shown in Figure 1 is including of 2 designs, namely the field station and the base station. The field station consists of sensors and an ESP32. This device is placed on the roof of the Nanizar Zaman Joenoes Building of Universitas Airlangga. Meanwhile, the base station which consists of a PC is placed in operator room in the building for real-time observation. Apart from being displayed on the monitor screen, the processed data from the sensor is also stored in PC memory. Both field stations and base stations are connected to the same wifi network provided by the building.

Hardware design
The firmware for the ESP32 was built according to the workflow in Figure 2 (a). Based on the ESP32 workflow installed in the field station together with all these sensors starts with the initialization of the pins used, the library, the connection to the sensor, and the connection to Wi-fi. After that, the device is connected to a local Wi-fi network with the SSID and password that has been previously set. After a successful connection, the device will activate the server.
Get into the main program, that runs in an infinite loop to read all sensor data, combine all readings into one string, then send it to the server if there any request from client device. Then Figure 2 (b) shows the harware design of the system. It uses ESP 32 development kit C as the main processor. Both processor and all sensors supplied by 2 DC/DC step down converters. The system uses 16x2 LCD to show the connected wi-fi ssid and its IP address on local connection. As mentioned before, Figure 2 is clearly explain both the firmware of the ESP32 and hardware design of the system on the field.

Software system
The communication with field device uses mDNS protocol. The field device will read sensor and send them to server only when there is a connection request come from client, which called as the base station software. On Figure 3, the software workflow created in visual basic, starting with the initialization of all the variables used, date and time, also the wi-fi connection. Then the software will send data request to server and and get a line of text as the feedback. Data obtained from server is still in the form of a comma-separated line of text, it is necessary to separate it for each parameter. After each parameter has got its own data, all data is displayed in the user interface software, along with chart and windrose charts. After that, all data is saved to Excel.

Sensor characterization
The characterization process for the whole sensors needs to be done to measure the performance, which is accuracy and precision. The first test is done for each accuracy of the sensor. In terms of measurement, accuracy is the main factor affecting the performance of a measuring instrument. Accuracy shows how precise an instrument or measuring instrument is given a certain value. This test was done by comparing the sensor with a standardized instrument. The comparison will result in the error calculated by (1).
The second test is to measure the precision that shows how consistent a measuring instrument gives a certain scale value at many times. This can be calculated from the standard deviation obtained from each measurement. Standard deviation can be calculated by the following formula.
In this study, the third characterization was only carried out on gas sensors. This characterization process refers to the sensor data from each of the MQ-135, MQ-131, MQ-8, MQ-4, MQ-9, and MQ-811 sensors. This process is used to convert the 12 bit ADC value received by the ESP32 analog input pins to the gas concentration value in ppm units. The first thing to calculate is the sensor module output resistance ( ).
is the maximum output voltage from sensor which is 3.3V, is the resistance in the sensor which is 1000Ω, is the maximum value that can be read by by the analog input pin which is 4096, is integer given by the analog pin, is the board circuit voltage which is 5V. Then the comparison value of dan This is entered into each of the regression formulas from each sensor to calculate the value of the gas content in the air (ppm). On the other hand, the R_oini value is the sensor output resistance obtained in the standard test condition (STC) measurement which has a gas content in the air of 100 ppm.

IMPLEMENTATION. 3.1. Field station
The field station consists of sensors and an ESP32 microcontroller board which is used to read the sensors, process the data, then send them to the server simultaneously in a row of strings. Measurement of weather conditions uses a set of weather station equipment consisting of a vertical axis anemometer, wind direction arrows with a rotary encoder, rain gauge, barometric sensors, and DHT 11. The barometric sensor uses shield BMP280, while DHT11 is used to measure ambient temperature and humidity.The anemometer, wind vane, and rain gauge devices as shown in Figure 4 (a) are placed on the roof of the building that is free from everything around it. The weather controller shown in Figure 2 (b) is used to process the initial data from the anemometer, wind vane, and rain gauge. Coupled with data from the DHT11 and BMP280 sensors, the data is processed and then sent via serial communication as output to the main microcontroller or the ESP32 board. Measurement of air quality parameters is carried out by reading gas sensors such as; MQ-135 for ammonia, MQ-131 for ozone, MQ-4 for methane, MQ-131 for ozone, MQ-9 for carbon monoxide, MQ-8 for hydrogen, and MQ-811 for carbon dioxide. Apart from the gas sensor, this device also measures UV ray index.
As shown in Figure 5, all gas sensors are placed in one board which is integrated with the ESP32 board and the power supply. Given that there are 8 gas sensor modules used, of course, 2 DC power supplies will be very capable of meeting the power needs of each component. This is done so that there is no reading error on the sensors.

Base station
The tasks of UI software are to obtain data from the server, process, display on the screen in actual time, and store data on PC memory for further data analysis purposes. Sampel of a dataset presented in the UI software showed in Figure 6 are windrose, wind speed chart, and other sensors mentioned before. Each reading panel is featured with a label and a level indicator. The indicator is green if the value is in the lower limit, the indicator is orange if the value is in the middle limit, and the indicator is red if the value is in the upper limit. The limitation value of each weather measurement sensor is obtained from BMKG's (Meteorology Climatology and Geophysics Council of Indonesia) standard data. while the limit value for each gas sensor is obtained from the permissible exposure limit (PEL) table. Each gas measurement is also presented in real-time chart to analyze the change over a day. Date and time data are also presented in real-time. This becomes important for analyzing further weather data. Each data visualizations in the application are also expected to make it easier for users to analyze and predict weather change parameters where the field station device is placed. This is also useful for media education for students and lecturers for academic purposes.

Gas sensors reading conversion
By looking at the graph of the sensitivity characteristics of each gas sensor, an equation is obtained by regression method to convert the comparison value between the actual output and the STC output ( ) into ppm unit. The value are obtained by reverse-calculating the equation below for PEL value of each measured gas. Please note that PEL for ammonia is 50 ppm, PEL for Ozone is 0.05 ppm, PEL for Hydrogen is 10 ppm, PEL for methane is 200 ppm, PEL for CO is 50 ppm, and PEL for CO2 is 5000 ppm.
is output voltage of the sensor which ranged from 0V to 3.3V. With these equations, each ADC value can be converted into units of ppm.

Sensor characteristic analysis
Characterization process used in this research are accuracy and precision. The method used for calculating precision is repeatability. Tests are carried out under the identical physical conditions, the identical sensor device, the identical standard measuring instrument, and by the same measurement operator. The results of testing all the sensors above are presented in Table 1.
In the data summarized in Table 1, all sensors available to do an accuracy test have good accuracy. Wind vane has good accuracy because it has a good pulse per rotation resolution specifications and linear inputoutput. Likewise, temperature measurements by DHT 11 and UV index by the sensor have high accuracy because of the good linearity of input and output. Otherwise, all sensors tested with repeatability methods have a good level of precision, except the wind vane. The lack of precision that happened to the wind vane is because it has a rotation resolution of 45 degrees, which is too large.

User interface (UI) and visualization
In the view of Figure 7, the chart for wind observation is emphasized because these two parameters are the most important ones to be visualized on a graph. To test the quality of the UI software, in this research a survey was carried out on application users who were considered in terms of visualization. The visualization in question is the level of informative and comfort design.  Figure 5 shows that 62.5% percent of 32 respondents stated that the display of this UI software was informative. A quarter said it was not very informative. This is because the background color and placement of windrose charts and charts are much larger with other parameter displays. From this survey, it was also found that 75% of respondents stated that the application design was rigid, not too elegant.

Data observation
Data that has been read and displayed are stored in computer memory in excel form. Data reading was carried out in 15-minute intervals. Test data was taken on September 14, 2020, from 9 am to 9 pm, with location coordinates (-7.266502, 112.784395). Figure 8 shows all gas sensor measurements in ppm. Based on PELs mentioned in the previous section, only ammonia, and ozone are measured always under each PEL. It describes low air quality in the area.
The Windrose chart showed in Figure 9 indicates that mostly wind on the area blew from North, sometimes from East and South. This is due to the west monsoon that blow from the Indian Ocean. Figures 10  and 11 are the measurements form DHT11 which are showing an almost steady reading throughout the measurement time. Barometric pressure data throughout the measurement time showed in Figure 12 also describes a stable reading. The temperature, humidity, and barometric pressure are applicable because the weather is also stable during the dry season in the area.

CONCLUSION
The conclusion from the research in this article shows that the design of a weather station device that is integrated with measuring gas levels in the air has been successfully carried out using IoT technology. All sensors for weather measurement have an accuracy of more than 90%, and only wind direction measurements have a precision of less than 90%. Likewise, all gas sensors that can only be tested for precision, have a precision level of more than 80%. With the characteristics of these sensors, a capable telemetry network, and a desktop application UI with high informativeness, it is hoped that it can help observe weather and air conditions properly. On the other hand, a designed weather station device can also be used as a medium for research and education in related fields.