Development of an internet of things-based weather station device embedded with O 2 , CO 2 , and CO sensor readings

ABSTRACT


INTRODUCTION
Information about weather conditions is beneficial for any purpose [1].Starting from disaster management [2], agriculture [3], [4], traffic management, environmental learning [5], and finding out the potential for renewable energy in a location.Weather parameters are wind speed and direction, air temperature and humidity, rainfall, air pressure, and solar radiation.In addition, measuring air quality levels is also very important, considering the effects of weather and climate change.Information about air quality that various parties can access can also be used for environmental impact analysis for policymaking in the environmental sector.In addition, the effect of clean air quality can also suppress the development of the tourism sector.This is an example of Gili Iyang Island, Sumenep, Indonesia.The island, known as oxygen island, has the second-highest oxygen level in the world, according to the Indonesian Institute of Aeronautics and Space.
On the other hand, internet of things (IoT) technology is a new point in the science of long-distance data transmission, commonly known as telemetry.This technology connects various devices and human needs in an internet network [6], [7].This allows everyone to access anything regardless of distance, as long as it is connected to the internet [8].internet of things technology is also commonly used for telemetry purposes, especially for measuring the data of various fields, including weather and air quality data [9], [10].Like some research that has been done before.Such as the intelligent weather station system based on the IoT 1123 conducted by Huang et al. [11].Mini weather stations with IoT mobile applications have also been proposed by Gupta et al. [12].A study on designing a low-cost weather station using a NodeMCU was conducted by Singh et al. [13] and Wulandari et al. [14] have developed an IoT-based weather station for farm, also used a Raspberry Pi board by Savic et al. [15].There is also research on weather stations used for agricultural purposes that have been done by Botero-Valencia et al. [16].The assessment of weather conditions is also helpful in determining the potential of wind energy in Oman, described in the Al-Yahyai et al. [17].Nsabagwa et al. [18] also aimed to design three generations of the automatic weather station prototype.Previously, researchers had also developed a weather station device called AirFeel.AirFeel version 1 can monitor weather conditions and levels of pollutant gases in the air (there are seven types of gases) [19].The device uses the ESP 32 devkit-C microcontroller board as a data collector and simultaneously uploads datasets to the server.Unlike previous studies, this AirFeel weather station device version has a different system topology.The latest system uses two microcontroller boards, one for data acquisition and one for data communication.The shield board is also separate, whereas the weather shield already has additional sensors.The new system also has an oxygen sensor, a carbon dioxide sensor, a carbon monoxide sensor, and a solar cell used to measure solar irradiation levels.

METHOD
As a result of previous research, the AirFeel weather station device was developed for version 4. In the development of version 4, the system topology and the sensors used are very different.This research consists of three parts, namely the design of field stations, database storage systems, and android-based mobile applications.

System design
The AirFeel weather station version 4 system consists of a field station, a base station, and an Android application.An overview of the design system is presented in Figure 1.The field station equipment comprises sensors, interface circuits, a microcontroller board, and a mobile wireless fidelity (Wi-Fi) router (MiFi).At the same time, the base station device consists of a minicomputer that stores data online.In addition, the results of data monitoring are also displayed in android-based applications that have been published on the play store.A field station is a device used to retrieve weather and gas parameter data.The data obtained from the sensors is processed and then sent to the database server.The sensors consist of a weather sensor and three gas parameters.A 3-cup anemometer is used to measure speed, a wind vane is used to measure wind direction, and a rain gauge is used to measure rainfall.The weather station sensor shield accesses the sensor data power signal.Where in the shield is suitable for the Arduino Uno board [20]  1124 measure temperature and humidity, as well as a BMP280 sensor to measure barometric pressure, these data are collected by the weather shield and then sent to the board microcontroller 1 via serial communication.The carbon dioxide (CO2) sensor module and carbon monoxide (CO) sensor module have output as an analog signal, so it is read by the external analog to digital converter (ADC).Also, the solar cell has voltage and current output measured by a direct current (DC) voltage current sensor i.e.INA219.Then external ADC, INA219, and the oxygen (O2) sensor module are accessed directly by board microcontroller 1 via interintegrated circuit (I2C) communication.On board microcontroller 1, all data obtained from air sensors and weather shields are processed and combined into one dataset.Then the data set is sent serially to the microcontroller board 2 and parsed again with the time and date data downloaded from the network time protocol (NTP) server.The complete dataset consists of sensor data, date, and time, then sent to the real-time database.Data transmission uses a 4G internet connection from a mobile Wi-Fi router (MiFi).In addition, the dataset is also saved to the secure digital (SD) Card via serial peripheral interface (SPI) communication.
At the base station, datasets have been stored in real-time in the cloud database.The dataset can be accessed by mini server computing devices used as data servers from AirFeel devices.In addition, the dataset can also be accessed with an android-based smartphone with the AirFeel application.Thus, the dataset can be viewed and monitored in real time via an android application with a good interface design.

Hardware design
This custom weather station device with air quality readings is supported by a mini photovoltaic (PV) system, which generates electricity from solar irradiation [21].This mini-PV system supplies the electrical energy needed by the AirFeel device.Figure 2 shows the PV system consists of solar panels, a solar charge controller (SCC), and batteries to store electrical energy.The electrical energy generated by the solar panels is stored in the batteries so that the weather station system can operate day and night.
Apart from the availability of independent electricity, this device also requires a reliable internet connection.The telemetry system is based on the IoT, where field data transmission is carried out via the 4G network.Therefore, a capable Wi-Fi router device, such as MiFi Huawei E5576, is used.

Real-time database
The design of this device uses a Google Firebase account for temporary data storage in real-time uploaded from the field station.In Firebase, the data is stored as JavaScript object notation (JSON) and synchronized continuously to each associated client [10].This means the client does not need to make any calls to get data changes.Firebase takes control and notifies your application whenever data changes.If the data on the server has not changed, there will be no calls and no responses, resulting in optimal use of bandwidth [22], [23].The feature used in this study is a real-time database.

Android-based application
This android-based application is used to observe changes in all measured parameters' values.The AirFeel monitor application shows the results of reading data from the sensors at the field station.There are three parameters of gas levels in the air, namely O 2 , CO 2 , and CO.In addition, six weather parameters are also presented, namely wind speed, wind direction, rainfall, air temperature, air humidity, and barometric pressure.This application's main menu also displays the field station's location with global positioning system (GPS) readings and the date and time of data acquisition [24].

Sensor characterization
A complete sensor characterization must be performed to measure performance, accuracy, and precision.Regarding measurements, accuracy is the primary factor affecting measurement performance.Accuracy indicates how accurately an instrument or gauge is given a given value.This test was performed by comparing the sensor with standardized equipment.The second test is to measure precision.This shows how the gauge reads a given scale reading consistently over and over.This can be calculated from the standard deviation obtained from each measurement.
In this study, sensor characterization was carried out for O2, CO2, and CO readings.The three gas sensors use the interface module from DFROBOT, and the output from these sensors is an analog signal that has been filtered and amplified.The output signal can be accessed by the microcontroller board 1, so it can be directly processed into the actual unit, ppm.

IMPLEMENTATION 3.1. Field station system
All sensors, microcontrollers, and routers are placed in the field for measurement.As shown in Figure 3, the testing location is in Universitas Airlangga, Kampus C, Surabaya, Indonesia.The latitude and longitude coordinates are -7.266260 and 112.785307, respectively.
The aluminum box protects the field station's components shown in Figure 3(a), which protects the electronics from heat, rain, and animals (such as insects).Electrical equipment for the mini-PV system in the form of solar charge controller (SCC) and batteries to supply the electrical energy needed by the customized weather station system is also placed safely in the panel box.A digital timer is used to reset the weather station system at a set time, i.e., three times a week.
The anemometer is a vertical windmill with three scoop-shaped grids that can catch the wind, as shown in Figure 3(b).The vertical turbine type can take in the wind from all directions.A wind vane is used to measure the direction of the wind.This wind vane is shaped like a rocket and has a wide fin on its back.This fin allows the wind vane to rotate as the wind flows.The reading of the irradiation level of the sun is using a mini solar cell.Unlike previous research, this research uses a different gas concentration reading concept with the deployment of the O2 measurement on the Gravity DFROBOT oxygen sensor module that is designed based on an electrochemical principle and can support I2C output, calibrated in air, and can accurately measure oxygen concentration in the outside air.Moreover, the CO2 reading also uses a sensor module from Gravity DFROBOT.The sensor has an onboard MG-811 gas sensor, which is highly sensitive to CO2 and less dependent on humidity and temperature.Also, for reading CO, it uses the DFROBOT sensor module.The sensor uses MQ7, an easy-to-use CO detector that is reliable for detecting CO concentration in the air within a precision range from 20 to 2,000 ppm. Figure 4(a) explains the program for the microcontroller board embedded in the Arduino Uno R3.Arduino Uno R3 is the best choice for an automation system like this [25]- [27].The workflow of this program begins with system initialization in the form of serial communication feature initialization, input, and output, barometric pressure sensor initialization, humidity sensor, current and voltage sensor module (INA219), external analog to digital converter (ADC) initialization, as well as the interrupt function which used to read weather sensors.Then read the weather parameters from the weather shield: wind speed and direction, rainfall, humidity, temperature, and barometric pressure.After that, calculate the value of these parameters in order to obtain the actual magnitude.The parameter reading of gas levels in the air is then carried out on the O2, CO2, and CO sensors connected to the I2C pin on the board.The dataset obtained from weather sensor readings is parsed with the gas sensor reading data.Then the dataset is sent to microcontroller board 2 via serial communication.
Figure 4(b) explains the program for the microcontroller board 2 embedded in Wemos D1 Mini ESP8266.The ESP8266-based microcontroller board is suitable for an automation system that uses an internet connection [28].The primary function of this board is to upload datasets to the database server in Firebase.The workflow begins with system initialization, namely, initialize secure digital (SD) Card, serial communication, initialize Wi-Fi connection, connect to Firebase, and enable user data protocol (UDP) for connection to NTP server.The work of this program is waiting for the dataset to be sent serially from the microcontroller board 1.After receiving the data, the program will request data date time to the us.pool.ntp.orgNTP server.The system will reset if the date and time data are not obtained.Then the date time data will be parsed with the sensor reading dataset.Then the program will save the complete dataset to the SD Card in the .txtformat.Lastly, the program will upload the entire dataset to the Google Firebase server database.The program will reset if an error occurs while uploading data to Firebase.

Database
Field devices upload data sets every minute.The data is then saved to the real-time database.This database storage is temporary, not permanent, so the dataset will always be replaced by data later.In the Android application, data will be updated every 2 minutes.During this period, the application requests data access data from the real-time database.In the smartphone application, datasets are stored for a limited time.Datasets for application will be deleted in 24 hours.

1127
A Python-based application is also made to create a more complete database.The program in this desktop application requests data from the Firebase real-time database every 5 minutes.The dataset that has been received is then stored on the Raspberry Pi 4B minicomputer memory.The results of receiving the dataset are stored in a .csvfile format.Thus, complete data access can be retrieved from the database on this Raspberry Pi memory.In addition to the Android applications and mini-computer databases, the dataset is stored on the SD Card for backing up.

Android-based user interface design
Figure 5 presents the monitoring menu on an android-based application called AirFeel monitor.This application can already be downloaded from Google Play Store.This app is programmed with android studio.The main function of the AirFeel monitor application is data acquisition from a real-time database and then displaying it on the smartphone screen.
Figure 5(a) shows the real-time reading of all parameters obtained from field station measurements.There are seven field devices in this AirFeel monitoring system, but the options displayed are only AirFeel device five systems.

Sensor value conversion
In this study, calibration was performed only for CO2 and CO sensors.This is considering that the manufacturer has calibrated all-weather sensors.Likewise, the O2 sensor, that sensor has been calibrated.CO2 sensor readings were carried out 50 times with an interval of 5 ms. Figure 1, the CO2 sensor is read with an ADS115 external ADC operating at 15 bits.Then the sensor output voltage is calculated by (1): where  2 is CO2 sensor output,   is sampling value from ADC integer,   is voltage reference for a sensor such as 5 V, and _ is the maximum value of 15 greater or equal to the zero-point voltage ( _ ) such as 0.220 V which define the output of the sensor in volts when the concentration of CO2 is 400 ppm.Then define the curve as an array as (2): where   is the voltage drop of the sensor when transferring the sensor from air into 1,000 ppm CO2, such as 0.030 V. Then the real value of CO2 in percentage will be calculated as (3): where   is equal to 13.5.Then conversion for the CO sensor by giving (4).External ADC reads the CO sensor on channel number 0.
where   is the output voltage from the sensor and,   is ADC reading on channel number 0.

Field station system work
A reliable power source must support the field station system.This is even more so if the system is used in a remote area.In remote areas, there is usually no power source from the network.Therefore, this device's supply of electrical energy must be available independently.As explained in Figure 2, the PV system used in this weather station device has specifications, i.e., 50 Wp monocrystalline PV panel, 12 V DC 10 A SCC, and 12 V 18 Ah deep cycle valve regulated lead acid (VRLA) battery.
The AirFeel system uses 5 V electricity supplied by the PV system.The DC 5 V supply is used for controllers, sensors, and MiFi routers.In operation, it was found that the controller devices, including sensors, consumed a current of 260 mA.Meanwhile, the mifi router consumes a DC of 130 mA.That means the entire AirFeel system device requires around 1.95 Watts of power.A designed PV system is proven to make a customized weather station system that can live for 24 hours.The PV system has also been tested in cloudy weather conditions, but AirFeel is still active until the following day with 60% battery capacity.

Base station system work
The base station is used to store datasets that have been downloaded in real time from the Firebase server.This base station is located in the laboratory.The base station section comprises a minicomputer (Raspberry Pi 4B), SD card memory, a monitor screen, and other utilities.Researchers can observe data traffic from all field stations with the data provided by this local database server.Using a Python-based program, the database successfully stores the dataset readings on the real-time database link from the AirFeel 5 and 7 field stations.The datasets are downloaded and saved at 5-minute intervals in .csvformat.The base station program embedded on the Raspberry Pi 4B board can operate 24 hours non-stop.In addition, when there is a power failure or loss of internet connection, this program will restart.

Android-based monitoring system
Android-based applications that have been successfully created with an informative and good interface.One main menu allows the user to read the parameters, which are presented clearly.This application can be downloaded from the Google Play Store under AirFeel.To access information from field stations, users must register a Google account for their mobiles/tablets with the operator.Then the operator will add a Google account on the Firestore page with the appropriate information from the user.The AirFeel application is still developing and has limited data access.All features and menus can be accessed when the user has successfully logged in to the application.Access the AirFeel application menu not only on one field station 5 but on all field stations installed.Subsequently, all data from AirFeel devices in the field can be presented integratively and informally.

Instrumentation analysis
The accuracy and precision level are obtained from the sensor characterization testing results.The O2, CO2, and CO sensors are tested within their signal conversion board.In this study, the measurements tested were O2, CO2, and CO readings.This test is carried out by comparing sensor readings with standardized measuring instruments.The method used to calculate accuracy is reproducibility.The tests are performed under the same physical conditions, the same sensor settings, the same standard measurement equipment, and by the same measurement operator.SEN0465 DFR O2 sensor tested with Lutron PO2-250 O2 meter.SEN0159 DFR MQ811 CO2 sensor is tested with Lutron GC-2028.SEN0132 DFR MQ7 CO sensor is tested with a standardized Co meter, Lutron GCO-2008.Table 1 shows the test results for the used sensors.

Data acquisition
As a further system performance test, data was acquired to measure weather parameters and gas concentration levels in the air.The processed dataset comes from the recorded data file on the SD Card.The system does this e SD Card data recording every 1 minute.This stored dataset contains 16 measurement parameters.The parameters stored in this dataset include CO concentration (ppm), O2 concentration (%), CO2 concentration (ppm), wind direction (degree), wind speed (m/s), wind gust (m/s), humidity (%), air temperature (ºC), barometric pressure (hPa), rainfall (mm hour), daily rainfall (mm hour), solar irradiation (W/m 2 ), latitude, longitude, date, and time.

Data sampling and validation for short period
Data sampling is carried out in 2 methods: daily data acquisition for 24 hours and data acquisition while the system is activated.Figure 6 shows the dataset obtained on January 16 th , 2023.In Indonesia, this date is the rainy season.Based on weather forecast data on Accuweather on the same date, it was found that cloudy weather occurred in a few days.It also rains every day, so the wind parameter readings and solar irradiation are slightly inconsistent.
Figure 6(a) shows the wind rose on January 16 th , 2023.It shows that the wind mainly blew from the northwest and north direction, with an average speed of 5 to 10 m/s.Then Figure 6(b) shows the same as the wind rose; the wind in the specific location had a maximum speed (wind gust) of 6.2 m/s. Figure 6 The chart of O2 gas in the upper subplot shows that O2 concentration on that day is not too fluctuating.The range of O2 values measured between 21.2% to 22.0%.The O2 value indicates that air quality in the location is in good condition.The chart of CO2 in the center subplot shows that the CO2 value measured between 907 to 1,404 ppm.It indicates that the CO2 concentration on that day is too polluted.It was because the location for testing the system is outside, near the main road inside the campus area.Figure 7 shows the measurement readings for gas concentration.Gases measured are O2, CO2, and CO stored in the SD Card module for 24 hours on January 6 th , 2023.
Then the bottom chart of the CO value is measured between 4 to 7 ppm.The average CO concentration outside did not affect the body's condition and respiration.The O2 and CO reading is unstable because the sensor has not had good repeatability when programmed in the Arduino Uno microcontroller board.Figure 7.The O2, CO2, and CO dataset was recorded 24 hours on January 6 th , 2023

Data sampling and validation for long period
Data acquisition was held for overall system activation from January 1 st, 2023, to February 21 st 2023.Based on Figure 8, the O2, CO2, and CO gas concentration data measured in the air are mostly in healthy condition.Furthermore, the chart of O2 measurement done by the DFROBOT O2 sensor shows that the O2 value is not too fluctuating and concentration over the days indicates air with oxygen-rich.Besides that, the measurement of CO2 (MQ811 sensor) and CO (MQ7 sensor) are somewhat fluctuating in those days.It can be caused by air pollution, considering the location of this system test is near the main road, with lots of vehicles passing by, especially on weekdays.Otherwise, the CO2 and CO concentration decreases during the weekend.
Figure 9 also shows the weather parameters measured by the AirFeel weather station system.The dataset obtained from SD card storage of the AirFeel version 4 system has done to be analyzed.This system successfully records all sensor readings every 1 minute.
The weather parameter was recorded in 16 parameters, such as gas concentration and weather condition.The weather condition reading in Figure 9 shows the system has a consistent measurement system with coherent accuracy and precision.The data obtained are compared to secondary data from accuweather.comat the exact date and time, and they are appropriate.

CONCLUSION
The design of a weather station system and gas concentration reading was successfully made to monitor actual weather and air quality condition.The laboratory scale test shows that the measurement of each gas sensor has coherent accuracy and repeatable measurement results.The test results show changes in the gas concentration value considered by the standardized measurement device.On the field test, the system also indicates that all three gas sensors have higher than 85% accuracy, such as +95% for DFR O2 sensor reading, +88% for DFR MQ811 O 2 sensor reading, and +93% for DFR MQ7 CO 2 sensor reading.The Airfeel monitor android-based application is beneficial for monitoring all sensor readings in all field station devices by requesting data to Firebase database every 2 minutes.With its second version, the mobile application can store temporary data on users' smart gadgets and has a location monitor by GPS.An online database server has also been created using a Raspberry Pi 4 B device with a Python-based database program.This database program requests data from the same Firebase Database, then stores it in a database array on its read-only memory (ROM) storage.This AirFeel version 4 weather station system can be activated 24 hours long by electricity supplied from a mini-PV system.The weather station system and its mobile Wi-Fi router, which has 1.95 Watts total power consumption, can be satisfied with a 50 Wp solar panel and a 12 V 9 Ah deep cycle battery.So, this system can be applied reliably in a remote area, for instance, a remote or small island.
Int J Elec & Comp Eng ISSN: 2088-8708  Development of an internet of things-based weather station device embedded with … (Prisma Megantoro)

Figure 2 .
Figure 2. Wiring diagram of custom weather station system supplied by mini-PV Int J Elec & Comp Eng ISSN: 2088-8708  Development of an internet of things-based weather station device embedded with … (Prisma Megantoro) 1125

Figure 3 .
Figure 3. Customized weather station field system, (a) controller and gas sensors setup, (b) anemometer, wind vane, rain gauge, and solar cell sensor probe set up on the field


ISSN: 2088-8708 Int J Elec & Comp Eng, Vol.14, No. 1, February 2024: 1122-1134 1126 3.2.Firmware design This program is made with the Arduino IDE.The program embedded on both microcontroller boards is presented in Figure 4. Figure 4(a) describes the program workflow on microcontroller board 1, while Figure 4(b) describes the program workflow for uploading datasets to the database server on microcontroller board 2.

Int
Development of an internet of things-based weather station device embedded with … (PrismaMegantoro)

Figure 5 (
b) depicts the solar irradiation level sub-menu with actual chart and measurement acquisition data.The user can also find the measurement points on the chart by clicking on the chart area.

Figure 5 (Figure 5 .
Figure 5. UI real-time display on AirFeel application; (a) main menu, (b) sub-menu for CO monitoring, (c) sub-menu for wind rose, and (d) sub-menu for field device location Int J Elec & Comp Eng ISSN: 2088-8708  Development of an internet of things-based weather station device embedded with … (Prisma Megantoro) 1129

Figure 6 .
Figure 6.Weather data recorded on January 24 hours on January 16 th , 2023; (a) wind rose, (b) solar irradiation level and wind speed

Figure 8 .
Figure 8. Air gas concentration (O2, CO2, and CO) measured in location between January to February 2023

Table 1 .
Accuracy and precision test result