VIETNAM NATIONAL UNIVERSITY HO CHI MINH CITY UNIVERSITY OF INFORMATION TECHNOLOGY ADVANCED PROGRAM IN INFORMATION SYSTEMS NGUYEN ĐỨC KHÁI — 19521658 GRADUATION THESIS AIR QUALITY MONITORING AND PREDICTING APPLICATION INFORMATION SYSTEMS ENGINEER THESIS ADVISOR MSc. DO DUY THANH HO CHI MINH CITY, YEAR 2023 ACKNOWLEDGEMENT First and foremost, I’d like to deeply express my gratitude and grateful to my supervisor Ms. Cao Thi Nhan for all of her valuable support and revision with my final thesis. In the early stage when I started working on my graduation project, I encountered many problems, concerns, and even fears of not being able to complete it.
However, thanks to her encouragement, inspiration, suggestion, and help, I was able to complete my graduation thesis. Next, I am extremely appreciative that the Department of Information Systems and OEP has provided me with an excellent opportunity to put all of my education, perception and experience to solve a massive problem as well as applying them to hands-on a real application. Without the need for hesitation, this experience has provided me with a strong foundation in my career path. Finally, I would like to express my sincere appreciation and respect towards my family members for encouraging me throughout the process of conducting my graduation thesis.
In addition, I would like to thank my younger cousin, Mr. Bui Quang Phu for assisting me in researching the basic knowledge and foundations of data mining. Thanks to them, I am inspired to persevere in the face of challenges and create the product of the best quality. Table of Contents ABSTRACTION 1.
HTHHn HH H HH T HH 2 IV. The importance of monitoring air Quality .-----s<+<<ss++se+seeeesess 6 1. Effects of mainly indoor air pollutants on human health. TA, 5 5 se <seesee 8 PS ')9°, /(G 6a.
Objectives and SCOD€. G12 11H HH ng ngư 11 L411. INDOOR AIR QUALÏ T”Y.- 2 0 c3 99H HH HH it 13 "Noion ae. AQI Scale for Different PollufanfS.
General problem solving apprOach.-- - --ssss si ererrree 19 2. Related acc cố. Required technology for developing appÌication. Reason for building SySf€T.
Reason user will choose this appÌiCafiOT. loT-BASED AIR QUALITY MONITORING SYSTEM. A synopsis of the proposed SVSf€T.-- SG Q19 v SH ri, 27 3. ToT hardware and €VIC©S.
TH HH nh ng 27 3. Ăn nh HH nh in 27 3. Wi-Fi Module ESPS26G6. HH HH HH 30 3.
Sharp dust sensor GỚP2Y 1010AUOE. CCS811 TVOC CO2 S€TSOI. G1111 HT HH HH 33 3.c + SS St k*n* HT TH TH HH niệt 34 3. Sensor COnÍIBUTAfIOH.- Gà nh nh ng rư41 3.
System WOTKÍ[OW. cọ TH HH HH Hi, 42 3. Virtual Private S€TV€T.- Ác SH TT HH TH HH HH ni kt 44 3. Google Cloud Compute Engine.
Vultr Cloud PTOVI€T.- o6 S3 ng ng ng nến 45 3. Docker monitor by POTAIT€T. Work with ToT devices. Gv ng ke 46 3.
Learn from đafa. SH TH TH HH He 54 4. Replace OUtÏI€TS. Apply MinMax SCaÌT.
Transform to window size (Ì4fa. Gà HH HH57 4. Split to train, test and validation S€K.- -- «sec ssc<sessessers 58 4. Ăn TH HH TH kh 59 4.- <5 5 + ret59 XSANH? \) no TC.
HH nh re62 4. Experiment on self-measurement dafaS€L.- 555555 s+++s<++svesssexs 66 "“"ÐốŒt::aiađiaiiitftẩầỶẢỶ. Dafa DF€DTOC€SSINE. Ăn HH HH Hy 67 4.
Train, test afAS©.- G1 1 TH TH HH nh re 69 Non. Connect the device to a DOW€T SOUITC€. Gv ng re, 69 5. Connect device With WI-ÏEFI.
- - - - cc ccc 1E SS SH SSSSnS S555 51 1k kvkkkkrer 70 5. Monitor air quality through w€©bSI{€.- --- «5 HH TH TT HH HH HH 77 Chapter 6. ĐÁ HH T HH TH TH TH TH HH kg krry 83 "`. Q1 Tnhh Tu HH Ti HH nh vn 83 REFERENCES 1.
85 LIST OF FIGURES Figure 1. 1: Smog covers Ho Chi Minh CÍIfy. 2: PM particles size comparisons with human haIr. 3: Arduino Uno micro-confTOÏÏ€T.-- 5 «+ + £++*£+se++eeesxx 12 Figure 2.
1: AQI Category and Levels of Concern. 2: AQI color formulas in RGB (red, green, blue) and CMYK (cyan, magenta, yellow, bIack). s11 TH TH TH nh gi 17 Figure 2. 3: CO AQT Scale [29] .- -- -- + <1 1x21 1 2111118211111 1g ng ng ve 17 Figure 2.
5: TVOC AQT SCaÌ6. 7: Interface of US AMQP Project in Hanoi, Vietnam. 1: WeMos NodeMCu DI-EÌ. 2: Additional boards manager URLLS.
3: MQ gas sensors mOdUÏe. 5 + + ***kE+sv+eeeeerseeeseke 30 Figure 3. 4: MQ Series Se€nSOT DITOUI. 56 + SE VESsvEsseEeeeersrkerske 31 Figure 3.
5: Structure and function of Sharp GP2Y1010AUOE. 6: Connection Diagram CCS811 and ESPS§266. 7: Backend ArchIf€CfUTC. -- --- <1 x1 HH ng re 35 Figure 3.
8: RabbitMQ between Email service and API service. 10: best_model h5 file and best_scaler pkl file. 11: Loading model and sCaÏer.-- «+ «++s£++++eexss+ssxs 38 Figure 3. 12: Getting predict data by using Postman.
13: MQTT broker between IoT and API service. 14: MOTT X Inf€rface. 15: System WOTKÍÏOW.- «nh TH Hư 42 Figure 3. 16: Cloned repository on VPS.-- «cv ng ng ke 43 Figure 3.
17: Start all services by running docker compose. 18: Deployment model using Docker. 19: Google Cloud $300 credit proøram. -- 5 + x3 vn ng ng 45 Figure 3.
21: Portainer user ITI€TÍAC€. 22: AirChecker project Github repOSitOTy. 23: IOT devices in reality. s5 xxx seeeeeeskre 49 Figure 4.
HH TH TH TH TH TH HH tre 50 Figure 4. 3: Check missing value in đafas€t. 4: IQR method for identifying OufÏI€TS. 5: Replace outliers with threshold.-------«-++<<<=++<eex+sesss 56 Figure 4.
6: Before and after replacing OutÏI€TS .- ------««+5s«=+ss++ss+ 56 Figure 4. 7: Value of dataset after applying scaler. 8: Transform scaled data to window size đafa. 9: Split dataset and reshape to LSTM layer input shape.
10: Experiment 1 model configurafION. 11: Experiment Ï train, test Set 2. cee eeceeseeeseceseeeeeeceseceeeeseeeneeees 60 Figure 4. 12: Experiment 2 confiØUTAfIOI.
13: Experiment 3 configuraf1ON.- - -----++- «+ +++sx++eeeeeseereeesrs 61 Figure 4. 14: Experiment 4 confiØUTAfIOI. 15: Relationship of first 100 samples on train set. 16: Relationship of first 100 samples on validation set.
17: Relationship of first 100 samples on test set. 18: Air Quality Index (AQT) prediction pÏot. 19: Select feature and index coÏumn. 1: Device CORTI€CfOTS.
3: Setup Wi-Fi for ESP8266. 5: Install for desktop app. 6: Mobile application 1TIf€TÍACG. 7: Composite AQT Í€afUTGS.- - -- n1 HH re 74 Figure 5.
10: Predict feature and user guidebook feature. 11: Individual pollutant concentrafIOH. 13: Propose solution for high pollutanfS. 15: Historical pollutant value chart.
17: Email alert to user’s €TmaIÏ.--- 55+ + sx£+Eseseeseesserseee 79 Figure 5. 19: Air quality report (page Ï). 20: Air quality report (Page 2). - -- - - vn rưkt 82 LIST OF TABLES Table 2.
1: oT device name list. eee eeesseceseeeseeeseceeceeeeeseeesseeseseneeenaeees 20 Table 2. 1: WeMos NodeMCU DI RI technical specIfications. 2: 3-layer model and hands-on 1ÌÏustraflon.
3: Prediction service API endpOInIfS. 4: Response structure from predicted APPI. 5: Sensor cOnfiØUTAfIOT. 6: Docker compose commands.
7: Portainer account InfOrmafioII.-- -- 5s +++<s+++se++eeex+zsss 46 Table 4. 1: Dataset column mmeanInØ. 3: PM10 Annual Summary. 4: SO2 Annual Summary.
s5 13 E+*VE+#vEEeeeEseeeeseeeee 52 Table 4. 5: NO2 Annual Summary. 6: CO Annual SummarV.-- -- c5 + 3E E+*vE+veeEeeerseeeeeeerse 53 Table 4. 8: The first ten rows data in the dataset.
9: Google Colab RÑ@SOUTC€S.- 5 5 1 ng ng ng rưưt 59 Table 4. cee eesceseceseeeseeeeseceseceeeeseeeeseeeaeeeeeeneees 62 Table 4. 11: Experiment RMSE results 20. cee ceeceeeceeeeeceneceseeeseeeeneesseeeaeeess 63 Table 4.
12: Model evaluation using MAPE. 13: The own dataset Structure .- Ă HS He 67 Table 4. 14: RMSE result of own_data traiming. 1: Application features ÏIS(.- 56c vn rưkt 69 Table 5.
2: Devices requireMent ZV:aađađa.- 70 LIST OF ABBREVIATIONS PDYÐFmƠœH© Aout: Analog Output API: Application Programming Interface AQI: Air Quality Index CO: Carbon Monoxide Dout: Data/Digital Output GND: Ground IoT: Internet of Things LSTM: Long Short-Term Memory O3: Ground level ozone © PM: Particulate Matter — — .5: Particulate Matter with aerodynamic diameter < 2. PPM: Parts per millions o¬sWBnwN. PPB: Parts per billion. TVOC: Total Volatile Organic Compounds.
Vcc: Voltage Common Collector —¬ Sa. VOC: Volatile Organic Compounds — ~. VPS: Virtual Private Server ¬ œ. Wi-Fi: Wireless Fidelity LIST OF FORMULAS Formula 2.
1: AQI formula for each pollutant Formula 2. 2: Composite AQI formula. ABSTRACTION With the increasingly negative climate change, people are gradually exposed to toxic substances, some of which have a direct impact but also some that have a long- term impact. Nowadays, people get sick more often and diseases have increasingly unpredictable variations.
Surely no one does not remember that the Covid-19 epidemic caused loss of both life and property. With technology gradually playing an important role in most aspects of life, I realized an opportunity to apply technology to partially solve the air problem. This is the reason I want to build an air quality monitoring and prediction system based on IoT. The system includes sensors to measure pollutants such as CO, O3, PM2.5, TVOC, thereby providing warnings to the user's device through notifications.
The system also includes a website that can be used on phones and is implemented with Progressive Web Apps (PWA) technology so users can download and use it like software. Regarding the air quality forecast feature, I apply the LSTM algorithm model to forecast air quality for the next 7 days. Motivation Dust, cigarettes, toxic chemicals from factories, dust from construction sites, exhaust from vehicles, etc. These are all components that make the air in the atmosphere.
The human atmosphere is increasingly seriously polluted. Over the years, research, articles and information from the media and news have mentioned issues of climate warming [1], the greenhouse effect [2], especially respiratory diseases, infectious disease epidemics like Covid-19 [3] etc. are ringing the alarm bell and waking everyone up. Human activities are causing the concentration of pollutants to increase significantly.
According to Reuters: "Beijing’s city government has issued a red alert for severely high levels of air pollution in the Chinese capital, running for five days from Friday evening, the environmental protection bureau said Figure 1. 1: Smog covers Ho Chi Minh City. (source: “HCMC smog made up of condensed pollutants: environment dept”, H. Anh, VnExpress, Sep.
26, 2019) With the development of information technology in general and the development of Internet of Things technology in particular, it is not difficult for us to create an application or monitoring system to measure air quality to prevent, research and analysis. In addition, in the area where I live, it is a small alley about 3 meters wide where, when a motorbike turns around, a lot of dust and smoke is discharged directly into the house. With an understanding of technology, IoT, and the above situation, I was prompted to create an application that can measure air indicators and provide warnings and solutions to family members. The idea of the application is to measure pollutants using sensors and display the concentration of substances on the website in real time while building a backend system and database to save measurement results every hour.
Air pollution This section aims to learn about air pollution, air pollutants and their sources, etc. At the same time, briefly introduce how to check air quality using the air quality index (AQD. Air pollution refers to the introduction of chemical, physical, contamination, or biological substances into the internal or external environment, resulting in alterations to the inherent properties of the atmosphere. The main pollutants that impact public health that need to be considered first include particulate matter, carbon monoxide, ozone, nitrogen dioxide, and sulfur dioxide [5].