Design and implementation of IoT based environment pollution monitoring system: A case study of Iraq

Researches confirm the existence of widespread pollution in Iraq, where a large number of citizens suffer from symptoms related to environmental pollutants. This is accompanied by the lack of an integrated monitoring system that provides wide-scale, real-time monitoring of air pollution for pollutants (Particulate Matter (PM), Sulfur Dioxide (SO2), Ground-Level Ozone (O3), Carbon Monoxide (CO), and Nitrogen Dioxide (NO2), ionizing radiation). In this paper, an integrated system was designed and implemented to meet the requirements of air pollution monitoring in Iraq on a wide-scale and provide its results in real-time to the end-users in community service as a significant step towards smart cities. Distributed computing concepts and design patterns were used to realize the system in the form of web services along with the embedded sensing units. Where the readings from the former are sent in real-time to the later to be aggregated and analysed in database systems. Reporting services are run on the data in web-services to inform the citizens with the air quality, radioactively polluted areas, and provide real-time alerts and recommendations to those with respiratory diseases.


Introduction
Air pollution is a concern for society as it directly impacts the environment and human health. With the increase in environmental pollution in the past few years, respiratory diseases have become more prevalent with many deaths [1]. The number of passenger cars, buses, trucks, heavy construction equipment, and local generators has increased greatly in Iraq since 2003 In addition to the pollution caused by dust storms, which has been a major cause of high levels of air pollution threatening the lives of the population due to its negative effects on health and the economy [2,3,4]. As well as, the remnants of wars that have caused high environmental problems, according to the statistics of the effects of radioactive pollution on the lives of citizens resulting from the destruction 14-Tammuz nuclear reactor in 1981, In addition, the recent wars in Iraq (1991Iraq ( to 2015 where sophisticated ammunition that contained depleted uranium were used in combat. The usage of these weapons severely impacted humans, animals, and the surrounding environment [5,6,7,8]. That led some researchers to give recommendations to design a map showing all polluted areas in Iraq due to the increasing statistics of the population affected by pollution symptoms [8]. Giving the severity of the topic, it is clear that a true society needs a real-time service that helps monitor and observe changes in the concentration of environmental pollutants. With the absence of such a service at the current time, an idea emerged to design an integrated system supported by a web application to help the Iraqi people discover polluted areas and safe living spaces in the entirety of Iraq.

Air quality
The proposed system will adopt one of the most important standards to calculate the Air Quality Index (AQI). Which has been used by the US Environmental Protection Agency (EPA) to measure the risk levels of the five air pollutants: Particulate Matter (PM 10&2.5 microgram ), Sulfur Dioxide (SO 2 ), Ground-  Table 2 shows the classification of air pollutants concentration ranges based on AQI risk levels according to EPA standard [9]. Table 2. Breakpoints for AQI [9]. The Air Quality Index (AQI) value is calculated based on Equation 1 [9].

DLow
Where: I Low = index breackpoint corresponding to D Low , I High = index breackpoint corresponding to D High , D = pollutant concentration, D Low = pollutant concentration breakpoint ≤ D, D High = pollutant concentration breakpoint ≥ D For example, if we suppose that the system recorded an average concentration of Nitrogen Dioxide (NO 2 ) 1000 ppb through one-hour sensor reading, the result of AQI value can be calculated as follows:

( )
This result value means that the air quality is in the "Very Unhealthy" level.

Radioactive pollution
Another very dangerous pollutant is the ionizing radiation from natural or unnatural sources that can cause severe deformities in people such as DNA damage, sterility, cancer, and hypersensitivity, and so on, especially what children and fetuses may suffer from due to their immature Immune systems like birth defects and chronic diseases [10].
The proposed system will adopt the radiation thermometer levels used by the Centers for Disease Control & Prevention (CDC) to expose the risks of radiation doses, as listed in Table 3 [11]. Table 3. Radiation thermometer scale [11].

Cloud computing platforms
Building an organized sensors network to monitor the environmental pollution for all regions of Iraq from north to south is considered very important to preserve the safety of the population from pollution risks, and help the government locate and identify environmental pollution areas to apply treatment procedures. At this point, it is evident that such a network has to be designed and implemented on both the hardware (sensors level) up to the backend software and infrastructure. However, a network of such scale cannot be accommodated via legacy infrastructure solutions; hence we base our design on the cloud infrastructure as proposed in [12]. Along with the cloud infrastructure, we proceed to build the back-end services' software components where MQTT protocol is used for network communication [13], PHP, JavaScript, MySQL, and MongoDB are used to implement end-points [14,15]. All of which is to be discussed in detail in the next sections.
Overall, the paper is organized as follows: the optimal solution to deploy the system's sensors and the system overview are given in the second section, the third section describes the system design, which is divided into two parts; sensing unit design and web-application design. While we show the results in section fourth. Finally, we conclude the paper in section fifth.

System overview
The system is based on the Internet of Things (IoT) platform to provide connecting and exchange of sensors' data with the system's web-application as well as a real-time map monitoring service for the community. Figure 1 shows an overview of the system components with a simple explanation of the proposed locations where the sensor deployment is required.

Wide-scale deployment
It is necessary to have a scalable and affordable sensor distribution model. Hence, we use the following heuristic to identify the best sites:  Densely populated residential places.  Polluted areas caused by wars and bombing with modern weapons.  Along Iraq's borders with countries that possess nuclear reactors, to alert local citizens when there is a radiation leak near borders.  Hospitals (where there are patients who are undergoing surgery or have chronic diseases, also some hospitals may use some radioactive materials in some types of treatments, and this also need to be monitored to be aware of any radiation leakage cases).
The proposed network embodies the essence of IoT networking in its scale and spread, along which, comes IoT bottlenecks and shortcomings. It is preferable to distribute the sensors in the areas mentioned above in cellphone network towers' locations directly, knowing that the purpose of this is to provide internet service and places to put the sensors throughout Iraq (except hospitals as sensors should be mounted on their roofs). The benefits behind this method of distribution are to cover the critical places and to eliminate the following:  The cost of installing and maintaining the sensors towers and their wireless connections.  The cost of network devices and equipment (including routers, switches, wires, and other connectivity supplies).  The cost of hardware and security software, which protect the network from hacking and viruses, as it is a large network that requires a data center.  The cost of network labor for connecting, monitoring and managing, as well as the required software for that.  The cost of network power's supply and backup, like power generators or UPS devices to keep sensors running continually.

System design
The system comprises two main parts; the first part relates to the design and programming of the air pollutants sensing unit and the second relates to designing and programming a back-end cloud-based system in web-services.

Sensing unit design
The system-sensing unit consists of the following parts, and as shown in Figure 3.  The diagram shown in Figure 4 illustrates the working steps of the sensing unit software.

Backend design
The system web application has three main pages that were programmed using the following main programming tools (PHP, JavaScript, MySQL Database, and Mongo Database).

System Administrator Dashboard Webpage
The webpage layout is shown in Figure 5 and provides:  User (Supervisor) management [Add/Delete/Modify/Activate], Figure 6 and Figure 7.  Sensor management [Add/Delete/Modify/Activate/Deactivate], Figure 8 and Figure 9.  Supervisor's department management to assign the sensors' sites [Add/Delete/Modify/Visibility], Figure 10 and Figure 11.  Sensors monitoring map that displays the concentration averages of all pollutants and air quality indexes for all sites and showing their risks to human health, it has a similar design to the Citizen Service Webpage, as shown later.  Ads bar management [Add/Delete/Modify/Activate], Figure 12 and Figure 13.  Data search engine, Figure 14 and Figure 15.  An algorithm for checking the work of system sensors, the design of which is shown in Figure 16 and Figure 17.

Supervisors Control Panel Webpage
The webpage layout is shown in Figure 19. It provides some system admin control panel features that are limited to the area sensors the supervisor belongs to, as shown below:

Main Page/Citizen Service Webpage
The webpage layout is shown in Figure 20 and consists of:  Sensors monitoring map that display the concentration averages of all pollutants and air quality indexes for all sites in addition to showing their risks to human health.  Ads bar shows the necessary instructions that help the population to preserve their health.  Air Quality Index (AQI) chart shown in Figure 21.

System Messages
There is two JSON messages format used by clients (Wi-Fi modules) to send sensors' data to the MQTT server, as shown below:

First message
It is sent every 7.5 minutes to the system and is approximately the size of 75 bytes. This size varies with the number of digits of the sensing values or the number of pollutants that the sensor device sends as needed. For example,{"Lat":33.233547,"Lng":44.339588,"NO2":0.012168963,"SO2":205,"RD":0.00287448}. This message requires the following:  Internet download bandwidth of 625 bytes per message to enable the MQTT server to receive the topic, payload, MQTT overhead, and TCP overhead of the message, so the total download bandwidth required to receive (1000 messages) is 610.35 KB/s.  Internet upload bandwidth of 286 bytes per message to enable the MQTT server to send the required response for MQTT and TCP packets, so the total upload bandwidth required to complete the receipt (1000 messages) is 279.29 KB/s.

Second message
It is sent every 1 hour to the system and is approximately the size of 84 bytes. This size varies with the number of digits of the sensing values or the number of pollutants that the sensor device sends as needed.
For example, {"Lat":33.233547,"Lng":44.339588,"PM10":957.7999878,"PM2":686.5999756,"CO":1, "O3":0}. This message requires the following:  Internet download bandwidth of 634 bytes per message to enable the MQTT server to receive the topic, payload, MQTT overhead, and TCP overhead of the message, so the total download bandwidth required to receive (1000 messages) is 619.14 KB/s.  Internet upload bandwidth of 286 bytes per message to enable the MQTT server to send the required response for MQTT and TCP packets, so the total upload bandwidth required to complete the receipt (1000 messages) is 279.29 KB/s.

Data collection
It contains the concentration averages of all pollutants and AQI for all sites that have been calculated and prepared in the web server by (hourly auto running script) to be archived and displayed on the map. This collection was loaded by random values with (8,760,000) documents, this number of documents has been estimated as follows (1 document per hour for each site × 1000 sites × 24 hours per day × 365 days) which represent one-year data, each document represents a system update which done every one hour by a scheduled script.

System scripts
After the previous collections were loaded with the required data, the following results were obtained when executing the main web-application scripts of the system:

System auto running script
It is responsible for carrying out the following actions every hour:  It calculates the concentration averages of all pollutants for all sites and air quality indexes for recently received data (inserted in Sdata7min and Sdata1hour collection) from the sensors previously registered (i.e. that have been specified their latitude and longitude on the system map).  It archives the result values in Data collection to be ready for bringing them in case of need, for example, when the system administrators/supervisors perform the data search or when the AQI chart is displayed, the system fetches the required data from the Data collection.  Organizing and archiving just the all last values of pollutants concentration average and their AQI of all sensors as JSON format to provide a fast display for the last sensors' information on Google map.
The execution time of this script was 49.2611 sec for (1000) sites (each site senses the concentration of seven pollutants).

Map viewing script
It is responsible for displaying all pollutants and AQI concentrations for all sites on the map. This script is based on the last JSON message format file prepared and archived by the above script. The script page is available online and allows all people to view it. The execution time of this script was 1.2232 sec to display information (1000) sites.

Chart script
It is responsible for displaying the AQI values for any sensor for one month. This script depends on the data archived in Data collection. This chart is available online and allows all people to view it. The execution time of this script was 1.6933 sec to fetch AQI values of one site for (last month), which includes (720 documents), each document represents sensor information of one hour.

Sensors checking script
In this script, the system checks the working of all sensor transmitter modules (such as Wi-Fi Module) based on the timestamp of the last data received in Sdata7min collection, in addition to verifying the truth of the data received from all sensors, and preparing a detailed reports for the system's administrators/supervisors when needed. The execution time of this script was 26.2263 sec to test (1000) sites.

Search script
This script is available only to the system administrators/supervisors to give all information available about any sensor for any chosen period. This script depends on the data archived in Data collection. For example, the execution time of this script to fetch (26288 documents) was 1.3532 sec, each document carrying all the information for one site. Note: The system was loaded and tested, and all the above results were obtained using a laptop supported with the following:

Conclusions
In this paper, a community-oriented air pollution system was designed and built to provide real-time air quality monitor to the masses. The system is built to scale-up in measuring and reporting all concentrations of air pollutants for all regions of Iraq. The terminal units were built using C/C++ languages and the T-Call ESP32 wireless module while the back-end system was built using the programming tools (PHP, JavaScript, MySQL Database, and Mongo Database). As for the messaging protocol, MQTT was used due to its small-footprint and high throughput. The results illustrate the resulting system along with its menus and user portals. Real-time air-quality-control can be achieved on a very large scale as illustrated by this work but it has to be done via the proper system architecture.