• Tiada Hasil Ditemukan

IOT-BASED ENVIRONMENTAL CONDITION MONITORING SYSTEM

N/A
N/A
Protected

Academic year: 2022

Share "IOT-BASED ENVIRONMENTAL CONDITION MONITORING SYSTEM "

Copied!
104
0
0

Tekspenuh

(1)

IOT-BASED ENVIRONMENTAL CONDITION MONITORING SYSTEM

HENG QIAO HUI

University Sains Malaysia

JUNE 2018

(2)

IoT-Based Environmental Condition Monitoring System

By

HENG QIAO HUI

Thesis submitted in fulfilment of the requirement for the degree of

Bachelor of Engineering (Electrical Engineering)

JUNE 2018

(3)

ACKNOWLEDGEMENTS

This project is dedicated to everyone who interested in monitoring environmental parameter in the surrounding area. I could not complete it without the guidance of my supervisor, the assistance of technicians, help from friends, and the support from my family.

I would like to express my deepest gratitude to my supervisor, Ir.Dr.Teoh Soo Siang who gave me a lot of suggestions and ideas while I was doing the project. Besides, he always guides me during doing this project so I could achieve all objectives that had been stated and complete the project on time.

Next, I would like to special thank the technicians who had helped me during doing the experiments. They provided any assists that I had requested. Besides, appreciations are dedicated to my friends for their helpful inputs and supports when I needed.

Last, I would like to thank my family who always support me and encourage me.

Their encouragements are always the best motivation for me to finish the project.

(4)

TABLE OF CONTENTS

TABLE OF CONTENTS ii

LIST OF TABLES vi

LIST OF FIGURES vii

LIST OF ABBREVIATIONS xii

ABSTRAK xv

ABSTRACT xvi

CHAPTER 1 - INTRODUCTION

1.1 Research Background 1

1.2 Problem Statements 1

1.3 Research Objectives 2

1.4 Scope of the Project 3

1.5 Thesis Structure 3

CHAPTER 2 - LITERATURE REVIEW

2.1 Overview 5

2.2 Introduction and Background of EMS 5

2.3 Environmental Quality Specification 5

2.4 Environmental Monitoring in Livestock Buildings 7

2.5 Remote Monitoring System with Wireless Sensors Module for Room

Environment 8

2.6 Indoor Air Quality Monitoring using Wireless Network 10 2.7 Internet of Things based Smart Environmental Monitoring using the

Raspberry-Pi Computer 12

2.8 Existing EMS 13

2.9 Proposed EMS 14

2.10 Summary 15

(5)

CHAPTER 3 - METHODOLOGY

3.1 Overview 16

3.2 The Design of the Proposed IoTEMS 19

3.2.1 Hardware Design 19

3.2.1.1 Block Diagram of IoTEMS 19

3.2.1.2 Schematic Diagram of IoTEMS 20

3.2.1.3Component Description 24

3.2.2 Software Development 30

3.2.2.1Read Sensor Data and Store Data in Local Database 30

3.2.2.2Website Development for UI 34

3.2.2.3Flow Chart of IoTEMS for UI 38

3.3 Experiment to be Conducted on Different Sensors 39

3.3.1 DHT22 Temperature and Humidity Sensor 39

3.3.2 LDR 40

3.3.3 MQ2 Gas Leakage Detector 40

3.3.4 Dust Sensor 40

3.3.5 BMP180 Air Pressure Sensor 40

3.3.6 Sound Detector 41

3.3.7 Flame Air Sensor 41

3.3.8 Water Level Sensor 41

3.4 Summary 41

CHAPTER 4 - RESULT AND DISCUSSION

4.1 Overview 42

4.2 IoTEMS Assembly 42

4.3 Data Storage in Local Database 43

4.4 Website UI 44

4.5 Alarm Generation 54

4.6 Email Feature 54

(6)

4.7 Experiments to Test the Functionality and Accuracy of Sensors 55

4.7.1 DHT22 Temperature and Humidity Sensor 55

4.7.1.1 Results of Temperature Measurement from DHT 22 56 4.7.1.2 Results of Humidity Measurement from DHT 22 58

4.7.2 LDR 59

4.7.3 MQ2 Gas Leakage Detector 60

4.7.3.1 Results of LPG Value Measured From MQ2 62 4.7.3.2 Results of CO Value Measured From MQ2 64 4.7.3.3 Results of Smoke Value Measured From MQ2 65

4.7.4 Dust Sensor 67

4.7.5 BMP180 68

4.7.6 Sound Detector 70

4.7.7 Flame Fire Sensor 72

4.7.8 Water Level Sensor 73

4.8 Comparing Existing System 75

4.9 Summary 75

CHAPTER 5 - CONCLUSION

5.1 Conclusion 77

5.2 Limitation 78

5.3 Recommendations for Future Work 78

REFERENCES 79

APPENDICES

APPENDIX A: DATABASE TABLE

A.1 Login Table 83

(7)

A.2 Current Status Table 83

A.3 "tempdata" Table 83

A.4 "humiditydata" Table 83

A.5 "bmpdata" Table 84

A.6 "dustdata" Table 84

A.7 "flamedata" Table 84

A.8 "lightdata" Table 84

A.9 "mq2data" Table 85

A.10 "sounddata" Table 85

A.11 "waterdata" Table 85

A.12 "lowerlimit" Table 85

A.13 "upperlimit" Table 85

A.11 "programtime" Table 86

A.12 "selectedpar" Table 86

A.13 "temporarydata" Table 86

(8)

LIST OF TABLES

Page Table 3.1 Pin Connections between Electronic Components and RPi 3 22 Table 3.2 Pin Connections between Electronic Components and MCP3008 23 Table 3.3 Pin Connections between Electronic Components and Logic Level

Converter 24

Table 4.1 Temperature Value Comparison between DHT22 and Measuring

Instrument in Indoor 57

Table 4.2 Humidity Value Comparison between DHT22 and Measuring Instrument

in Indoor 59

Table 4.3 Dust Level Data Collected from Dust Sensor 67 Table 4.4 Sound Value Collected for Different Motor Voltage Supplies 71 Table 4.5 Flame Sensor Value at Different Distance from Flame Sensor 73

Table 4.6 Maximum Detection Range of Flame Sensor 73

Table 4.7 Water Level Data at Different Distance from Water Surface 74

(9)

LIST OF FIGURES

Page Figure 2.1 Mean Scores on Satisfaction with The Five Environmental Factors [11]

6 Figure 2.2 Performance Rating across Thermal Confort, Air Cleanliness, Odour, and

Noise in a Residential Area [11] 6

Figure 2.3 Physical Architecture of the EMS Proposed In [8] 7 Figure 2.4 System Configuration of a Home Networking System [14] 8 Figure 2.5 Block Diagram of the Designed Wireless Sensor Transmitter [14] 9 Figure 2.6 Block Diagram of the RF Receiver Board [14] 9 Figure 2.7 Screenshot of Mote GUI Displaying Live IAQ Data in Chart Form [15]

11

Figure 2.8 Screenshot of Aerosol GUI Displaying Live Aerosol Data [15] 11 Figure 2.9 Schematic Diagram of the System [16] 12

Figure 2.10 IBM Environmental Monitoring System [17] 13

Figure 2.11 Hanwell Environmental Monitoring System [18] 13 Figure 2.12 Humidity and Temperature Probe, Data Logger, Gateway, and Converter

in the Rotronic Monitoring System [19] 14

Figure 3.1 System Development Flow Chart 17

Figure 3.2 Block Diagram of the Proposed Developed IoTEMS 19 Figure 3.3 Overall Schematic Diagram of the Proposed IoTEMS 20

Figure 3.4 Raspberry Pi 3 Model B [20] 25

Figure 3.5 Raspberry Pi 3 Model B Pinout Diagram [21] 25

Figure 3.6 DHT22 Sensor Module Breakout [23] 25

(10)

Figure 3.7 Water Level Sensor Module [24] 26 Figure 3.8 MQ-2 Analogue Smoke Gas Leakage Sensor Detector [25] 26 Figure 3.9 Digital and Analogue Infrared IR Flame Fire Sensor Module [26] 27 Figure 3.10 GP2Y1010AU0F Compact Optical Dust Sensor PM2.5 [27] 27 Figure 3.11 Analogue and Digital Microphone Sound Detection Sensor [28] 27

Figure 3.12 BMP 180 [29] 28

Figure 3.13 Light Dependent Resistor [30] 28

Figure 3.14 MCP3008 [31] 28

Figure 3.15 Logic Level Converter [32] 29

Figure 3.16 Speaker [33] 29

Figure 3.17 Toggle Switch [34] 30

Figure 3.18 Coding for Getting Analogue Data from Sensor 30 Figure 3.19 Coding for Getting Connection between Sensors and Database 31

Figure 3.20 Example Coding of Retrieving Data 31

Figure 3.21 Example Coding for Updating Data 32

Figure 3.22 Example Coding for Inserting Data 32

Figure 3.23 Coding for Declaring Email Configurations in Python Programming 33

Figure 3.24 Coding of Calling Email Feature 33

Figure 3.25 Coding for Making Speaker Ring 33

Figure 3.26 Database Platform for IoTEMS 34

Figure 3.27 Example of the HTML Tags Usage 35

Figure 3.28 Example of CSS Coding 35

Figure 3.29 Coding for Declaring the Local Database 36

(11)

Figure 3.30 Example Coding for Retrieving Data 36

Figure 3.31 Example Coding for Updating Data 37

Figure 3.32 Example Coding for Comparing Data 37

Figure 3.32 Flow Charts of RPi 3 Program (a) and Client System (b) 38 Figure 4.1 Hardware Components Assembly 43

Figure 4.2 List of Tables in Local Database 44

Figure 4.3 UI for User Registration 45

Figure 4.4 UIs for Login Access 46

Figure 4.5 UI of Main Menu 48

Figure 4.6 UI of Current Status 48

Figure 4.7 UIs for Checking Data in Table Form 49

Figure 4.8 UIs for Checking Data in Graphical Form 51

Figure 4.9 UIs for Selecting the Parameters to Be Monitored 52 Figure 4.10 UI for Checking and Setting Limitation Range 53 Figure 4.11 UI for Checking and Setting Update Time Interval 54 Figure 4.12 Speaker and Toggle Switch for Alarm Generation 54

Figure 4.13 Warning Email Details 55

Figure 4.14 Figure 4.14: Experiments Set Up for DHT 22 at Outdoor (a), in Indoor (b), and Comparing Indoor Data with Model “Cole-Parmer” (c) 56 Figure 4.15 Temperature Collected against Time at Outdoor from DHT22 Sensor and

Meteorology Website [40] 57

Figure 4.16 Humidity Collected against Time at Outdoor from Different Methods 58

Figure 4.17 Light Intensity at Outdoor and Indoor 60

(12)

Figure 4.18 Experiment Carried Out for Testing LPG through MQ2 in Enclosed Area (a), at a distance 60cm from the sensor (b), and at distance of 150cm

from the sensor (c) 61

Figure 4.19 Experiments Carried out for MQ2 by Burning One Joss Stick (a) and

Two Joss Sticks (b) 62

Figure 4.20 LPG Value Collected in Enclosed Area 63

Figure 4.21 LPG Value Collected at Distance of 60cm from MQ2 63 Figure 4.22 LPG Value Collected at Distance of 150cm from MQ2 63 Figure 4.23 CO Value Measured by MQ2 in Enclosed Environment with One Joss

Stick Burning 64

Figure 4.24 CO Value Measured by MQ2 in Enclosed Environment with Two Joss

Stick Burning 65

Figure 4.25 Smoke Value Measured by MQ2 in Enclosed Environment with One Joss

Stick Burning 66

Figure 4.26 Smoke Value Measured by MQ2 in Enclosed Environment with Two

Joss Stick Burning 66

Figure 4.27 Experiment Carried to Get Maximum Dust Value 67 Figure 4.28 Graph of Dust Level Value Collected from Dust Sensor 68 Figure 4.29 Air Pressure Value Obtained from Different Methods 69 Figure 4.30 Air Pressure Value in Indoor and at Outdoor 69 Figure 4.31 Experiment Carried Out for Sound Detector 70 Figure 4.32 Sound Data Collected for Different Motor Voltage 71 Figure 4.33 Experiments Carried Out at 10cm (a), 20cm (b), and 30cm (c) from

Flame Sensor 72

Figure 4.34 Flame Value at Different Distance from Flame Sensor 73

(13)

Figure 4.35 Experiments Carried Out at 1cm (a), 2cm (b), and 4cm (c) from Water

Surface Using Water Sensor 74

Figure 4.36 Water Data from Different Distance from Water Surface 74

Figure A1 Details about User 83

Figure A2 Details about Each Parameter Value and Status for Current State a 83

Figure A3 Details of Temperature Parameter Table 83

Figure A4 Details of Humidity Parameter Table 83

Figure A5 Details of Air Pressure Parameter Table 84

Figure A6 Details of Dust Parameter Table 84

Figure A7 Details of Flame Parameter Table 84

Figure A8 Details of Light Intensity Parameter Table 84 Figure A9 Details of LPG, CO, and Smoke Parameter Table 85 Figure A10 Details of Sound Intensity Parameter Table 85

Figure A11 Details of Water Level Parameter 85

Figure A12 Details of Lower Limitation Value of Each Parameter 85 Figure A13 Details of Upper Limitation Value of Each Parameter 85

Figure A14 Table to Store Update Time Interval 86

Figure A15 Details about the Parameter Selected by User 86 Figure A16 Table to Store Current Parameter and the Datetime Selected for

Monitoring 86

(14)

LIST OF ABBREVIATIONS

ADC Analogue Digital Converter AGND Analog Ground

AO Analogue Output

CH Channel

CLK Clock

CO Carbon Monoxide

CO2 Carbon Dioxide

CPU Central Processing Unit

CS Chip Select

CSI Camera Serial Interface CSS Cascading Style Sheet

DO Digital Output

DOUT Digital Ground

DSI Display Serial Interface

EMS Environmental Monitoring System GPIO General Purpose Input Output

GND Ground

HDMI High-Definition Multimedia Interface HTML Hypertext Markup Language

HV High Voltage

IAQ Indoor Air Quality IO Input /Output

(15)

IoTEMS IoT-Based Environmental Monitoring System I2C Inter-Integrated Circuit

IP Internet Protocol IR Infrared Radiation LAN Local Area Network LCD Liquid Crystal Display LDR Light Dependent Resistor LED Light Emitting Diode LPG Liquified Petroleum Gas

LV Low Voltage

MySQL My Structured Query Language

NC Not Connected

Pa Pascal

PHP Hypertext PreProcessor

PW Power

RAM Random Access Memory

RH Relative Humidity

RPi 3 Raspberry Pi 3

RX Receive

SCL Serial Clock SDA Serial Data

SMTP Simple Mail Transfer Protocol SPI Serial Peripheral Interface

(16)

TCP Transmission Control Protocol

TX Transmit

UI User Interface USB Universal Serial Bus

VCC Voltage Common Collector VDD Drain Supply

VREF Voltage Reference

(17)

IoT-Based Environmental Condition Monitoring System ABSTRAK

Faktor-faktor persekitaran yang tidak diingini akan menyebabkan keprestasian syarikat-syarikat atau industri tertentu rendah. Selain itu, faktor ini juga membawa kebahayaan yang boleh menyebabkan kecederaan yang membawa maut. Dengan menggunakan sistem pemantauan alam sekitar yang berciri amaran bunyi, kesedaran dapat diberikan kepada pengguna dengan segera jika persekitaran berada dalam keadaan yang tidak selamat. Di samping itu, pengguna yang berbeza memerlukan parameter persekitaran yang berbeza. Sistem pemantauan alam sekitar yang sejagat dapat memenuhi pelbagai pengguna. Dalam projek ini, satu sistem pemantauan alam sekitar yang bernama Sistem Pemantauan Keadaan Alam Sekitar Berbasis “Internet of Things” (IoTEMS) telah didirikan.

IoTEMS ialah sistem terbenam yang dapat memantau 11 parameter alam sekitar, iaitu kesuhuan, kelembapan, keamatan cahaya, ketahapan habuk, tekanan udara, kepekatan gas (GPC) cecair petroleum, kepekatan karbon monoksida (CO), kepekatan asap, ketahapan api, ketahapan bunyi dan paras air melalui laman web. Sistem ini diprogramkan untuk mendapatkan data analog daripada sensor. Isyarat itu akan dihantar dan disimpan di pangkalan data. Sebagai fungsi antaramuka pengguna, sistem berasaskan web dibangunkan untuk membolehkan pengguna memantau data mengikut jenis parameter persekitaran.

Dengan ini, nilai, status, dan masa pengambilalihan data dapat diperhatikan apabila parameter telah dipilih melalui laman web. Beberapa eksperimen telah dijalankan untuk membuktikan keupayaan sistem ini. IoTEMS melibatkan pelbagai sensor alam sekitar.

Dengan ini, sistem ini tidak hanya dihadkan dalam satu persekitaran tetapi boleh digunakan dalam keadaan persekitaran yang lain seperti kawasan tertutup, kawasan luar atau industri tertentu. IoTEMS juga dapat meningkatkan keberkesanan pengeluaran terhadap sesetengah syarikat atau industri kerana sistem ini membekalkan ciri amaran bunyi.

(18)

IoT-Based Environmental Condition Monitoring System ABSTRACT

Undesirable environmental factors have potential to bring low performance to certain companies or industries. Besides, it even brings hazards which may cause fatal injuries. With a reliable environmental monitoring system, it can warn the users immediately by providing sound alert if the environment is under unsafe status. On the other hand, different users may require different environmental parameters to be monitored. Therefore, a universal system should be considered to cater for a wide range of users. In the project, an environmental monitoring system called IoT-Based Environmental Monitoring System (IoTEMS) was built. IoTEMS is an embedded system that can be universally used to monitor 11 environmental parameters, which are temperature, humidity, light intensity, dust level, air pressure, liquified petroleum gas (LPG) concentration, carbon monoxide (CO) concentration, smoke concentration, flame level, sound intensity, and water level through a website. The system was programmed to obtain analogue data from the sensors and then the data will be stored to a database. For user interface (UI) purpose, a website-based system was developed that to allow the users to monitor the sensor data according the type of environmental parameters through the website. The website was designed that for each of the selected parameters, the value, the status, and the time of data acquisition can be observed. Several experiments were carried out to verify the functionality of all sensors. IoTEMS provides various environmental sensors that the system is not only restricted in one environment but can be applied in other environmental condition such as indoor area, outdoor area or even certain industries.

IoTEMS can also enhance the effectiveness of the production in certain companies or industries by providing alarm hazardous conditions.

(19)

CHAPTER 1 INTRODUCTION

1.1 Research Background

Nowadays, the world faces a big challenge in environmental monitoring because environmental data is scarce. Increasing population, urbanization, energy, transportation, and agricultural developments are the main sources of environmental pollution [1].

Moreover, natural disasters, such as earthquakes, floods, tsunamis, and landslides, are sources of environmental phenomena that might affect people around the world [1]. In addition, global warming, ocean acidification, and biodiversity loss can also lead a large scale of environmental impact [1]. On the other hand, noise is another serious problem which sources including vehicles, trains, music, and factories [1].

Human health is foremost when it comes to assessing the overall comfort of the environment. According to statistics, people spend about 80% to 90% of the time indoors [2]. The statistic has indicated that a range of comfort and heath related effects are linked to the environment of indoor. In the past couple of years, the Australian commercial building sector has begun paying more attention to Indoor Environmental Quality (IEQ) issues because they believed that indoor environmental quality may impact the productivity and performance of office workforces [3].

In industrial aspect, the era of Industry 4.0 is upon the factories nowadays. They are facing strong demand to increase their productivity. With Environmental Monitoring System (EMS), the factory safety can be monitored to optimize the operation and ensure the quality of the environment [4]. Besides, accompanied by these industrial projects come factors that could potentially harm the environment and wildlife ecosystems. By monitoring the environment, the industrial projects being implemented will have lower impacts on the environment [5].

1.2 Problem Statements

Although there are a numbers of EMS have been developed, this kind of system is still not common in use among society nowadays. Most applications are used in some specific areas which required the environmental conditions to be monitored. For example, in certain industries such as agriculture and factory-based industries. Agriculture is highly

(20)

dependent upon weather and climate. Hence, the system for agriculture application only consists of certain environmental sensors to detect temperature, humidity, luminosity and air pressure [5]. While in factory-based industry, dust, gas, water and other hazardous materials are necessary to be monitored to optimised factory operation [4]. In addition, some specific EMS also have been used for specific purpose such as to monitor greenhouse gases [6] or climate change [7]. However, the environmental impact not only affect certain people or certain area but affect all people in the world. This causes most of the people are unable to identify their current environmental situation and will not get awareness if there is something happen around them. Hence, to protect the health and the safety of society, an environmental monitoring system with low cost and multifunction should be widely used in all regions no matter people are in house or in working. To make the system more effective, a system with universal used is preferred because it can be applied in anywhere.

On the other hand, it is inconvenient for the users to go to the location that places the EMS when they would like to check the environmental parameters. The worst thing is users may face problem to reach the spot causing them unable to monitor the status of environment immediately. Hence, for user convenient, a device with IoT capability and a UI through internet is necessary so that the users could monitor the environmental change at anywhere and anytime.

There could be a huge impact if one of the environmental parameters exceeds its limitation. For example, when airborne particles and microorganisms are above certain levels, they have detrimental effects on the health and welfare of exposed humans and livestock [8]. Besides, the situation will cause the reduction of production efficiency of livestock [8]. Hence, a warning signal should be sent to users as fast as possible if one of the parameters is out of the safety limit to prevent bad impact from happening.

1.3 Research Objectives

The main aim of this project is to develop a universal environmental monitoring system with IoT capability. The specific objectives of this project are as follows:

 To develop an embedded system that can be universally used to measure the environmental parameters which are temperature, humidity, dust, liquefied

(21)

petroleum gas, carbon monoxide, smoke, fire flame, air pressure, light intensity, water level, and sound level.

 To add IoT capability to the system. A website will be designed to allow users to access the recorded sensor data from anywhere through internet.

 To analyse the collected environmental data and generate alarm if the reading is above certain threshold level indicating a possible unsafe condition.

1.4 Scope of the Project

This project is focusing on developing a system to monitor the environmental condition using IoT. The project consists of three main components which are multi- sensors module, data management processor, and data analysis processor. The multi- sensors module combines various parameters from sensors. It is the digital or analogue transmission for the sensor data. Raspberry Pi (RPi) plays a role as a base station which combines all sensors and connects the sensors. Next, with the help of MySQL, data management can be performed through RPi. Data management is an administrative process that includes acquiring, storing, protecting, and processing required data to ensure the accessibility, reliability, and timeliness of the data for the users. Then, data analysis processor is performed by PHP code and will be displayed in a website. Data analysis processor is to analyse the collected data by stating the status of each environmental parameter, whether they are in safe status or unsafe status. The data can be monitored in the form of graphical or table forms so the user is able to identify the overall trend. Besides, through the analysis, the system will warn the users through sound alert and email if the environment is under non-ideal condition.

1.5 Thesis Structure

There are five main chapters in this thesis which consist the details from introduction to conclusion of this project. Chapter 1 is about the introduction of this project where the research background, problem statements, research objectives and scope of the project are explained.

A literature review that related to this project is presented in Chapter 2. The introduction and background about EMS will be discussed in the chapter. To develop the specification of EMS, some journals and references are referred in aspect of indoor area

(22)

and industrial area. Several existing EMS are also introduced and their specifications are explained. Lastly, the proposed EMS is described in this chapter.

Chapter 3 is the methodology of this project which describes how the project is conducted. The design of the IoTEMS is described in this chapter in term of hardware design and software development. In the aspect of hardware design, IoTEMS block diagram, IoTEMS schematic diagram, and the component used are explained. While, in the aspect of software development, the method to read and store sensor data in local database, the method to develop a website for UI, and the UI flowchart are described.

Next, the type of experiments that were carried out are also described in this chapter.

The results of this project are displayed in Chapter 4. This chapter shows IoTEMS hardware assembly, the list of tables that had been built in database, and a web-based UI that had been developed. Besides, in this chapter, the alarm and email features are introduced. Next, the findings from the experiments that had been done for sensor verification are illustrated in the form of tables and graphs.

Finally, the conclusion of this project is presented in the last chapter which is Chapter 5. Summary of the outcomes, limitations and the future works that can be carried out to improve the performance of IoTEMS are covered in this chapter.

(23)

Chapter 2

LITERATURE REVIEW

2.1 Overview

This chapter presents the related contents regarding EMS. In section 2.2, some introduction and history about EMS are introduced. Section 2.3 describes the specification of environmental quality in aspect of in indoor area and industrial area respectively. Section 2.4 and Section 2.5 introduces the researches that had been referenced. In section 2.6, the existing EMS will be introduced. Section 2.7 describes the proposed universal EMS. Section 2.8 presents a summary of this chapter.

2.2 Introduction and Background of EMS

The development of EMS has been applied in many applications. This development assists people in their jobs and reduce cost and time. The applications have grown rapidly in agriculture monitoring, habitat monitoring, greenhouse monitoring, climate monitoring and forest monitoring [9]. It brings advantage because the community has realized the importance of environmental quality in their life.

In 2009, an Environmental Monitoring System (EMS) was designed, developed and tested in Australia [8]. The development of the EMS was born from the need for an accurate, low-cost, user friendly kit for monitoring airborne pollutants. It allows for air quality improvement strategies to be implemented [8]. The routine use of the EMS has the potential to improve building environments and reduce pollutant emissions by creating awareness of air quality issues amongst livestock farmers [8].

2.3 Environmental Quality Specification In Indoor Area

A number of investigations have been carried out on the office buildings and demonstrated the importance effects of the indoor environmental quality. The environmental factors include the office layout, thermal environment, air quality, lighting environment, and acoustic environment [10]. Figure 2.1 shows the mean scores on satisfaction from respondents in the office building [10]. Based on the survey and analysis,

(24)

the qualities of the five environmental factors have significantly positive correlations with the office productivity [10]. Figure 2.2 shows the performance ratings across thermal comfort, air cleanliness, odour and noise in a residential area [11]. Based on the result, residents who have familiarized over time with their living environment tend to give more consistent judgement of the relative importance between pairs of the four key Indoor Environmental Quality attributes: thermal comfort, air cleanliness, odour and noise [11].

Figure 2.1: Mean Scores on Satisfaction with The Five Environmental Factors [11]

Figure 2.2: Performance Rating across Thermal Comfort, Air Cleanliness, Odour, and Noise in a Residential Area [11]

In Industrial Area

In industries, some environmental impacts need to be concerned to protect the workers’ safety and health. There are human toxicity, respiratory effects, ionization radiation, photochemical oxidation, aquatic ecotoxicity, and hazardous waste [12].

Moreover, in agriculture industry, temperature and humidity will strongly influence on the storage life of fresh fruits and vegetables. Taking cranberry as example, cranberries

(25)

should be stored at temperature ranging from 0 to 10° C in combination with relative humidity (RH) ranging from 75% to 98% so the fruits can be stored up to 6 months without decaying under these conditions [13].

2.4 Environmental Monitoring in Livestock Buildings

Clements MS et al. described the hardware configuration of an EMS unit in [8].

Figure 2.3 shows the physical architecture of the EMS created by them. The system is divided into several subsystems (as shown in Figure 2.3): Power Distribution Subsystem, Structural Subsystem, Gas Monitoring Subsystem, Air Monitoring Subsystem and Data Logging Subsystem. The role of Power Distribution Subsystem is to provide power to all the other subcomponents of the unit. Structural Subsystem allows for ease of portability during transport and mounting when in use, as well as protecting the internal components from the operating environment. Gas Monitoring Subsystem is used to monitor gas such as ammonia and carbon dioxide. Air Monitoring Subsystem allows for monitoring of temperature, humidity and particle concentration within the livestock shed. Data Logging Subsystem will record sensor data and provide a UI for the unit.

Figure 2.3: Physical Architecture of the EMS Proposed In [8]

The custom circuit board includes a microcontroller, real-time clock, LCD screen, SD card interface and three push buttons. The push buttons provide basic user I/O for configuring, starting and stopping the system respectively. While, the real-time clock is used to time-stamp records obtained from sensor modules, which will be saved locally to

(26)

the non-volatile memory. A software called BASE-Q is a database application used to capture, store and retrieve air and environment quality data. The desktop BASE-Q software maintains data records, provides data security, accepts data from external sources and from manual input and provides search and reporting functions. The desktop Base-Q software is the main repository for data obtained from EMS units, which used to manage, store and view the recorded data. Besides, the pocket-based BASE-Q software (PBQ) allows for information to be easily retrieved in the field, such as reading SD cards of EMS units, before being returned to the desktop BASE-Q for synchronization.

2.5 Remote Monitoring System with Wireless Sensors Module for Room Environment

In [14], a system with several sensors such as temperature sensor, humidity sensor, CO2 sensor, flying dust sensor was proposed. The system was built on a RF transmitter board for monitoring indoor environment conditions. Figure 2.4 shows the system configuration of this monitoring system.

Figure 2.4: System Configuration of a Home Networking System [14]

Commercial discrete sensor devices can be built in a socket module for analogue and digital sensors. The analogue voltage data were converted to 8-bit digital signals via ADC0809 chip. Stand-alone 8051 microcontroller board was designed and fabricated as a server board. The control signals for lighting, heating, air conditioning and switching

(27)

electric appliances can be sent from PC via Transmission Control Protocol/Internet Protocol (TCP/IP) or from push button switches on 8051 microcontroller board.

Wireless sensor transmitter and receiver modules were also designed and fabricated by using a Complex Programmable Logic Device (CPLD) chip for simple system structure and eventual system cost reduction separately [14]. Figure 2.5 shows the block diagram of the wireless sensor transmitter. The commercialized Ultra High Frequency (UHF) data transmitter and receiver module chips (TX2 transmitter, RX2 receiver, Radiometrix Ltd, England) were used as a RF transmitter and a receiver separately. RF receiver part was composed of a CPLD chip with function of as shown in Figure 2.6.

Figure 2.5: Block Diagram of the Designed Wireless Sensor Transmitter [14]

Figure 2.6: Block Diagram of the RF Receiver Board [14]

(28)

2.6 Indoor Air Quality Monitoring using Wireless Network

To determine the environmental quality of an indoor space, an environmental monitoring system with wireless solution is developed by Bhattacharya, S. et al in [15].

With the system, the environmental parameters such as temperature, humidity, gaseous pollutants, aerosol/Particulate Matter can be measured. The system development is distributed into 4 parts, which are hardware module, data acquisition module Indoor Air Quality (IAQ) toolkits, and demand control ventilation module.

In the hardware module, ATmega1281 is used as its microcontroller, Xbee module from Digi is used as ZigBee based wireless communication module, and there is a gas sensor boards for measuring carbon monoxide and carbon dioxide. These gas sensors are working based on the principle of resistive heating. Besides, DustTrak DRX Aerosol Monitor Model 8533 from TSI Incorporated is chosen to monitor real time dust.

The DustTrak DRX Monitor is a battery operated, data-logging, light-scattering laser photometers that gives real-time aerosol mass readings.

In data acquisition module and IAQ toolkit section, a GUI is developed to display real time data coming from motes of each location at every one-minute interval and the data is presented in graphical form. Figure 2.7 shows the screenshot of mode GUI. User can check historical data of each place in form of graph with mean, max, and average value of each parameter. While, live aerosol data can be observed from a remote place via aerosol module IAQ toolkit. Screenshot of Aerosol GUI is shown in Figure 2.8. The data collected are analysed in term of Air Quality Index (AQI). AQI make the users understand what effects of those gas on habitat’s health.

(29)

Figure 2.7: Screenshot of Mote GUI Displaying Live IAQ Data in Chart Form [15]

Figure 2.8: Screenshot of Aerosol GUI Displaying Live Aerosol Data [15]

Lack of fresh air can make people feel uncomfortable, drowsy and sick. To ensure a good IAQ, a ventilation system is proposed in [15]. Depending upon actual occupancy of carbon dioxide concentration, ventilation rate will be modulated to maintain IAQ and comfort level of users.

(30)

Context Aware Framework (CAF) works as a generic middleware between the sensors and applications. CAF is used to collect data and allow for various applications.

Through applications, users can get notifications whenever there is any change for environmental parameter. Besides, the trigger points can be set to send alerts by using SMS, Email or alarm.

2.7 Internet of Things based Smart Environmental Monitoring using the Raspberry-Pi Computer

In [16], an environmental monitoring system developed using Raspberry-Pi (RPi) and programmed using Python Programming language was proposed. The system is designed such that it can be controlled and accessed remotely through an IoT platform.

Figure 2.9 shows the schematic diagram of the system. With IoT, the information collected through sensors are uploaded directly to the internet at anytime and anywhere.

The system consists of several subsystems, which are sensing, computer processing, uploading, and data interpretation.

Figure 2.9: Schematic Diagram of the System [16]

The purpose of sensing subsystem is to detect all environmental parameters using a collection of sensors. The system consists of sensors that can measure air quality, weather, and earthquake. The sensors used include TNP 36 (temperature sensor), DHT 22 (humidity sensor), LDR (light sensor), MQ 7 (carbon monoxide concentrations sensor), and thin-film-piezoelectric sensor (earthquake level sensor).

In term of computer processing, RPi is used to handles all the processing and controlling needed for the system to function. It receives and processes the sensing information and generates the necessary controls to store and transmit the data. Each

(31)

sensor is connected to the GPIO pins of RPi in different configurations. By writing program code in Python language, the system can be operated according to desired functions.

In term of uploading data, Extended Environment Markup Language Protocol (EEML) is a protocol implemented to share data between remote environments to enable users to tag and share real time sensor data from objects, devices, and spaces around the world. Last but not least, the purpose of data interpretation is to transform the collected sensor data into meaningful information.

2.8 Existing EMS

IBM Environmental Monitoring System is referred from the website in cite [17].

The system integrates existing environmental sensors and power generators into a comprehensive monitoring, alarm and control system. This EMS is targeted for applying in business field. EMS can monitor temperature, humidity, the occurrence of fire, smoke or water, and even security breaches, enabling a business to see how its data-centre is operating. EMS can immediately give alert when issues are detected.

Figure 2.10: IBM Environmental Monitoring System [17]

Hanwell Environmental Monitoring System is referred from the website in cite [18]. The system is one of the commercial EMS products from IMC Group Ltd. The system consists of data loggers, radio and GPRS transmitters to collect data such as energy, temperature, humidity, wind speed and direction, Lux and ultraviolet, insect pest control, CO2, pressure, and many more.

Figure 2.11: Hanwell Environmental Monitoring System [18]

(32)

Rotronic Monitoring System (RMS) is referred from the website in cite [19].

RMS software allows for a real-time monitoring of any parameter required. Rotronic offers solutions for parameters such as humidity, temperature, dew and frost point, differential pressure, pressure, flow, lux and CO2. It also offers an analogue to digital converter so that all analogue signals can be monitored. The data can be viewed through RMS webpage. Moreover, its software offers charts and graphics. An alarm function (Email, SMS, Telephone Call) is also provided [19]. Besides, the analysis tool allows users to establish daily, weekly, monthly or personalised reports with all the statistical data required.

Figure 2.12: Humidity and Temperature Probe, Data Logger, Gateway, and Converter in the Rotronic Monitoring System [19]

2.9 Proposed EMS

As discussed in previous sections, there are quite a number of EMS had been developed. To enhance the effectiveness and functionality of EMS, IoTEMS is proposed in this project. IoTEMS consists of three main components which are multi-sensor module, data management processor and data analysis processor.

A. Multi-sensor module

There are 8 sensors in the multi-sensor module which are DHT22 temperature sensor module, BMP 180 air pressure sensor, microphone sound detection sensor, dust sensor, MQ-2 analog smoke gas leakage sensor detector, infrared flame fire sensor module, water level sensor module, and light dependent resistor. Raspberry Pi 3 (RPi 3) uses its GPIO pins to interact with those sensors, and speaker. The analogue sensors will be converted to 8-bit digital signals via an analogue to digital converter so that the data can be read and processed by RPi 3.

(33)

B. Data management processor

The function of data management processor includes acquiring, validating, storing, protecting, and processing required data. MySQL plays a main role in this part. My SQL is a structured query language used to talk to the database. It allows to insert, update, remove or retrieve data in database. Sensor data is obtained by programming RPi. With MySQL and programming RPi, the collected data is stored in database. Through PHP and MySQL, the sensor data can be retrieved and displayed in website-based UI. PHP is a widely-used open source general purpose scripting language that is especially suited for web development and can be embedded into HTML. Besides, by programming PHP with MySQL, the alarm threshold of the sensors can be set or changed by user through the UI webpage.

C. Data analysis processor

Data analysis processor is for analysing the collected data. In the proposed system, the collected data is analysed and arranged into three sections which are daily data, weekly data and monthly data. Daily data section is used to monitor all sensor data for one day; weekly data section is used to monitor the average of sensor data for a day from a selected date to the other selected date; monthly data section is used to monitor the average of sensor data for each week within the selected month. In addition, the collected data are also programmed so can be displayed in the form of graph. By setting the limitation range of each environmental parameter, the status of respective parameter can be known, where within the limitation range is “Safe” status and vice versa. Moreover, an alarm sounds and an email will be sent to user if one of the parameter is out of the limitation.

2.10 Summary

This chapter provides a detailed explanation on the previous and existing EMS. A little introduction and background of EMS is also discussed. Some journals that had been referenced to understand the necessary specifications of EMS and how the EMS was developed are introduced in this chapter. The approach to develop IoTEMS is presented in the last section. The methodology to develop the proposed approach is further discussed in Chapter 3.

(34)

Chapter 3 METHODOLOGY

3.1 Overview

This chapter presents the methodology of this project. The hardware design is described in section 3.2. In the section, the overall block diagram is explained to show the relationship between RPi 3 and the other components. Besides, the schematic diagram of the complete system is illustrated to show the interfacing and connection of the respective components. The pin connections are presented in several tables and some explanations are given. Lastly, the main components used in the embedded system are introduced and their usage are explained. In section 3.3, the software development is described. The software program that used for getting data from sensors and storing the data in local database is introduced. Moreover, the program code used to create the website is also described. Some code examples are illustrated by figures and explanations.

Besides, the flow chart of IoTEMS will also be described. In section 3.4, the method to test the accuracy or the functionality of the sensors are described. Finally, section 3.5 gives a summary of this chapter. Before going through those sections, the system development flow chart of this project is shown in Figure 3.1.

(35)

Yes

No

Yes No

Figure 3.1: System Development Flow Chart Literature Review

Determine and purchase the required hardware components and tools Start

Yes

No

Does the system function correctly?

Interface one sensor and relative hardware components with Raspberry Pi

Program Raspberry Pi to collect and store sensor data in database

Create a website as UI to allow user to monitor sensor data in table form and in graphical form

End

Troubleshoot the system Interface another sensor with Raspberry Pi

Verify the collected data by experiments

Does the sensor get give correct data?

Test the sensor

Troubleshoot the hardware and software parts

Do all sensors give correct data?

(36)

Figure 3.1 shows the system development flow chart. After several literature reviews and investigations, the required hardware components and the tools that needed are determined and then purchased. The system development was started after getting the components and tools. A sensor with its related hardware components are interfaced with RPi 3. The sensor is tested to ensure its analogue value can be obtained. The software and hardware parts will be troubleshooted if the value could not be obtained. After that, another sensor is then interfaced with RPi 3 and is tested. After all sensors are connected and the data can be read by RPi 3, the RPi 3 is programmed to store the real-time data obtained in a local database. Next, a website is developed for UI. The website is developed such that user can monitor the sensor data in table or graphical forms. Besides, to ensure the feasibility of the sensors used, several experiments are then carried out to verify the data collected. If the data collected does not change according to conditions, troubleshooting of the system will be carried out and the system is tested again. These two steps are repeated until the system can be run smoothly and all objectives are achieved.

(37)

3.2 The Design of the Proposed IoTEMS 3.2.1 Hardware Design

3.2.1.1 Block Diagram of IoTEMS

The overall block diagram of IoTEMS is presented in Figure 3.2, which the interface relationship between the components is presented.

Figure 3.2: Block Diagram of the Proposed Developed IoTEMS

As shown in Figure 3.2, a power source is needed to provide power supply to RPi 3. RPi 3 is a microcontroller to program the whole system. The multiple sensors are as inputs which detect the environmental parameters and send their data to RPi 3. The collected data will be stored in the local database of RPi 3 in the respective table. Besides, with built-in wireless LAN feature in RPi 3, a website developed can be accessed once RPi 3 is turned on and Wifi is connected by RPi 3. By programming RPi3, the website will display the sensor data, its respective status, and the graph of the environmental parameter selected according to the time selected. Moreover, a speaker is installed in the system to give alarm to the users if one of the parameters is out of the range of its lower and upper safety limits.

(38)

3.2.1.2 Schematic Diagram of IoTEMS

Figure 3.3 shows the schematic diagram of IoTEMS. It shows the pin connections between the RPi 3 with an analogue digital converter (ADC), a logic level converter, and 8 sensors.

Figure 3.3: Overall Schematic Diagram of the Proposed IoTEMS

(39)

As shown in Figure 3.3, for ADC (MCP3008), there are 8 pins need to be connected to RPi 3 where its VDD, VREF, AGND, CLK, DOUT, DIN, CS/SHDN, and DGND are connected to 3.3VPW1, 3.3VPW1, GND1, GPIO11, GPIO9, GPIO10, GPIO8, and GND1 of RPi 3 respectively. For logic level converter, there are 4 pins need to be connected to RPi 3 where its pin HV, LV,GNDH, and GNDL are connected to pin 5VPW1, 3.3VPW1,GND6, and GND1 of RPi 3 respectively. For DHT22, there are 3 pins connected to RPi 3 where its pin GND, DATA_SIGNAL, and 3.3V are connected to pin GND1, GPIO23, and 3.3VPW1 of RPi 3 respectively. For LDR, there are 2 pins need to be connected to RPi 3 where its pin +TERMINAL and -TERMINAL are connected to pin 3.3VPW1, and GND1 of RPi 3 respectively. Noted that there is a 10k ohms resistor in between pin +TERMINAL and pin 3.3VPW1. For MQ2 gas leakage detector, there are 2 pins need to be connected to RPi 3 where its pin VCC and GND are connected to pin 5VPW1 and GND6 of RPi 3 respectively. For dust sensor, there are 5 pins need to be connected to RPi 3 where its pin V.LED, LED.GND, LED, S.GND, and VCC are connected to pin 3.3VPW1, GND1, GPIO26, GND1, and 3.3VPW1 of RPi 3 respectively.

Noted that there is 150 ohms resistor connected in between pin V.LED and pin 3.3VPW1.

There is a connection where a 220uF capacitor is connected in between pin LED.GND and pin V.LED. For BMP180, there are 4 pins need to be connected to RPi 3 where its pin VIN, GND, SCL, and SDA are connected to pin 3.3VPW1, GND1, GPIO3, and GPIO2 of RPi 3 respectively. For sound detector, there are 2 pins need to be connected to RPi 3 where its pin 5V and GND are connected to pin 5VPW1 and GND6 of RPi 3 respectively. For flame fire sensor, there are 3 pins need to be connected to RPi 3 where its pin DO, 3.3V, and GND are connected to pin GPIO24, 3.3VPW1, and GND1 of RPi 3 respectively. For water level sensor, there are 2 pins need to be connected to RPi 3 where its pin 3.3V and GND are connected to pin 3.3VPW1 and GND1 of RPi 3 respectively.

For speaker connection, to amplifiy the volume of speaker, a PNP transistor is added. There are 2 pins need to be connected to RPi 3 where +TERMINAL and - TERMINAL are connected to 3.3VPW1 of RPi 3 and BASE of PNP respectively. While, the BASE, COLLECTOR, and EMITTER of PNP are connected to -TERMINAL of the speaker, GPIO21 of RPi 3, and GND1 of RPi 3 respectively. For toggle switch, there are 3 pins need to be connected to RPi 3 where END_TERMINAL1, WIPER_TERMINAL, and END_TERMINAL2 are connected to 3.3VPW1, GPIO20, GND1 of RPi 3

(40)

respectively.Table 3.1 shows the pin connections between the electronic components (a MCP3008, a logic level converter, a speaker, a toggle switch, and 8 sensors) and RPi 3.

Table 3.1: Pin Connections between Electronic Components and RPi 3 Electronic

Component

Pins of Electronic

Component Pin Connection to Raspberry Pi 3

MCP3008

VDD, VREF, AGND, CLK, DOUT, DIN, CS/SHDN,

DGND

3.3VPW1, 3.3VPW1, GND1, GPIO11, GPIO9, GPIO10, GPIO8, GND1

LOGIC LEVEL CONVERTER

HV, LV,GNDH, GNDL 5VPW1, 3.3VPW1,GND6, GND1

DHT22 GND, DATA_SIGNAL, 3.3V GND1, GPIO23,3.3VPW1

LDR +TERMINAL, -TERMINAL Connect to 3.3VPW1 and a 10k ohms resistor in between , GND1 MQ2 GAS

LEAKAGE DETECTOR

VCC, GND 5VPW1,GND6

DUST SENSOR V.LED, LED.GND, LED, S.GND, VCC

Connect to 3.3VPW1 and 150 ohms resistor in between, GND1, GPIO26,

3.3VPW1

BMP180 VIN, GND, SCL, SDA 3.3VPW1, GND1, GPIO3, GPIO2 SOUND

DETECTOR 5V,GND 5VPW1, GND6

FLAME FIRE

SENSOR DO, 3.3V, GND GPIO24, 3.3VPW1, GND1 WATER

LEVEL SENSOR

3.3V, GND 3.3VPW1, GND1

SPEAKER +TERMINAL, -TERMINAL 3.3VPW1, Base of PNP

TOGGLE SWTCH

END_TERMINAL1, WIPER_TERMINAL,

END_TERMINAL2

3.3VPW1, GPIO20, GND1

(41)

Most of the sensors used which carry analogue pin need to be connected to MCP3008 because RPi only provides digital IO pin. The sensors that provide analogue output include LDR, dust sensor, flame fire sensor, water level sensor, MQ2 gas leakage detector, and sound detector. In addition, different sensor requires different level of power sources. LDR, dust sensor, flame fire sensor and water level sensor require 3.3V power sources. Hence, their analogue pins which supplied by 3.3V can directly connect to MCP3008 because MCP3008 is also powered by 3.3V. However, MQ2 gas leakage detector, and sound detector need 5V power. Hence, their analogue pins which supplied by 5V need to be connected to logic level converter to step down voltage to 3.3V before connected to MCP3008. Table 3.2 shows the pin connections between the sensors involved and MCP3008. Table 3.3 shows the pin connections wih logic level converter.

Table 3.2: Pin Connections between Electronic Components and MCP3008 Electronic

Component

Pins of Electronic

Component Pin Connection to RPi 3

LDR +TERMINAL CH0

DUST

SENSOR VO CH2

FLAME FIRE SENSOR

AO CH5

WATER LEVEL SENSOR

AO CH6

(42)

Table 3.3: Pin Connections between Electronic Components and Logic Level Converter

Electronic Component

Pins of Electronic

Component Pin Connection to RPi 3

MCP3008 CH1, CH3, CH4 LV4, LV1, LV2

MQ2 GAS LEAKAGE DETECTOR

AO HV4

SOUND

DETECTOR AO HV1

3.2.1.3 Component Description

In this project, an RPi 3 microcontroller is used to receive and collect sensor data from multiple sensors. The sensors include light dependent resistor, temperature and humidity sensor, water level sensor, smoke detection sensor, gas leakage sensor, fire sensor, dust sensor, microphone sound detection sensor and pressure sensor. The sensor data are then stored in the local database in RPi 3. A speaker is installed to give sound if a certain parameter is found under non-ideal condition.

RPi 3 Model B is the third generation of RPi series of microcontrollers. It consists of Quad Core 1.2GHz Broadcom BCM2837 64bit CPU, 1GB RAM, BCM43438 wireless LAN and Bluetooth Low Energy (BLE) on board, 40-pin extended GPIO, 4 USB 2 ports, 4 Pole Stereo output and composite video port, full size HDMI, CSI camera port for connecting a RPi camera, Display Serial Interface (DSI) display port for connecting a RPi touchscreen display, and micro SD port for loading operating system and storing data [22]. Due to RPi 3’s reliability, processing speed and versatility, it is selected to be used as the main controller in this project. RPi 3 is used to control the overall flow of the system.

It is programmed to collect the real-time data value from multiple sensors. Besides, with RPi 3, data sensor can be displayed in a website. Moreover, by programming RPi 3, the speaker will also sound if a certain parameter is under non-ideal condition. Figure 3.4 shows RPi 3 Model B while Figure 3.5 shows the pin out diagram of RPi 3.

(43)

Figure 3.4: Raspberry Pi 3 Model B [20]

Figure 3.5: Raspberry Pi 3 Model B Pinout Diagram [21]

DHT22 Sensor Module Breakout is a sensor to measure humidity and temperature.

It has four pins which are VDD pin, Serial Data line pin (SDA), NC pin, and GND pin. It takes only 1 wire (digital) to communicate with the microcontroller (in this system is RPi 3). It can measure temperature with the range from -40° C to +80° C while humidity with the range from 0 to 99.99%RH [23]. The accuracy for measuring temperature is ±0.1° C while for measuring humidity is ±2%RH [23]. Figure 3.6 shows the figure of DHT22 Sensor Module Breakout.

Figure 3.6: DHT22 Sensor Module Breakout [23]

(44)

Water Level Sensor Module is a sensor to measure water level. It consists of 3 pins which are signal pin, for 5V pin and GND pin [24]. The signal output is connected to RPi 3 analogue pin to get water level value. Figure 3.7 shows the figure of Water Level Sensor Module

Figure 3.7: Water Level Sensor Module [24]

MQ-2 Analog Smoke Gas Leakage Sensor Detector consists 4 pins which are VCC pin, GND pin, DO pin, and AO pin. It utilizes an MQ-2 as the sensitive component and has a protection resistor and an adjustable resistor on board [25]. The resistance of the sensor changes when the concentration of the target gas changes [25]. It is sensitive to LPG (liquified petroleum gas), i-butane, propane, methane, alcohol, hydrogen and smoke [25]. It is used as domestic leakage detector, industrial gas detector and portable gas detector [25]. Figure 3.8 shows the figure of MQ-2 Analog Smoke Gas Leakage Sensor Detector.

Figure 3.8: MQ-2 Analogue Smoke Gas Leakage Sensor Detector [25]

Digital and Analogue Infrared IR Flame Fire Sensor Module reacts to ordinary light, is generally used in flame alarm [26]. It has 4 pins which are VCC pin, GND pin, DO pin, and AO pin [26]. The detection range is from 760nm to 1100nm [26]. The detection angle is about 60 degrees, particularly sensitive to flame spectrum [26]. Figure 3.9 shows the figure of Digital and Analogue Infrared IR Flame Fire Sensor Module.

(45)

Figure 3.9: Digital and Analogue Infrared IR Flame Fire Sensor Module [26]

GP2Y1010AU0F Compact Optical Dust Sensor PM2.5 is a dust sensor. An infrared emitting diode and a phototransistor are diagonally arranged into this sensor device [27]. It detects the reflected light of dust in air such as cigarette smoke [27].

Besides, it can distinguish smoke from house dust by pulse pattern of output voltage [27].

Figure 3.10 shows the figure of GP2Y1010AU0F Compact Optical Dust Sensor PM2.5.

Figure 3.10: GP2Y1010AU0F Compact Optical Dust Sensor PM2.5 [27]

Analogue and Digital Microphone Sound Detection Sensor is used to detect sound.

It has 4 pins which are 5V pin, DO pin, AO pin, and GND pin [28]. For digital output, the sensitivity can be adjusted by the built-in potentiometer. The frequency range is from 100 to 10000HZ. The sensitivity is -46 ±2.0 at 1kHz [28]. Figure 3.11 shows the figure of Analogue and Digital Microphone Sound Detection Sensor.

Figure 3.11: Analogue and Digital Microphone Sound Detection Sensor [28]

(46)

BMP 180 measures a pressure range of 300 to 1100hPa [29]. The I2C interface allows for easy system integration with a microcontroller [29]. It consists 4 pins which are VCC pin, GND pin, SDA pin and SCL pin [29]. Figure 3.12 shows the figure of BMP 180.

Figure 3.12: BMP 180 [29]

Light dependent resistor is used to detect the presence or the level of light. It consists 2 pins which are positive terminal and negative terminal. Figure 3.13 shows the figure of light dependent resistor.

Figure 3.13: Light Dependent Resistor [30]

MCP3008 is a successive approximation 10-bit analogue-digital converter with on-board sample and old circuitry [31]. It consists of 16 pins which are VDD pin, VREF pin, AGND pin, CLK pin, DOUT pin, DIN pin, CS/SHDN pin, DGND pin, and CH0 to CH 7 pin [31]. In this project, MCP3008 is used to convert analogue sensor data to digital data because only digital pins are provided by RPi 3. Figure 3.14 shows the figure of MCP3008.

Figure 3.14: MCP3008 [31]

(47)

Logic level converter is used to step up or down the voltage between 3.3V and 5V. It has the capability to convert 4 pins on the high side to 4 pins on the low side with two inputs and two outputs provided for each side. It needs to be powered that high voltage source to HV pin, low voltage source to LV pin, and ground of the system to GND pin. It consists of 12 pins which are 4 HVs for IO pins, 4 LV for IO pins, HV pin, LV pin, and 2 GNDs [32]. In IoTEMS, several sensors are from 5V while some sensors are from 3.3V. To connect their analogue pin to MCP3008, the voltage of all analogue pins must be 3.3V. Hence, logic level converter is used to step down the analogue pins which from 5V to connect to MCP3008. Figure 3.15 shows the figure of logic level converter.

Figure 3.15: Logic Level Converter [32]

In IoTEMS, speaker is used to give awareness to users if a certain parameter is under non-ideal condition which is out of the relative parameter’s lower limit or upper limit. It consists of 2 pins which are GPIO pin and GND pin. Figure 3.16 shows the speaker that is compatible with RPi 3.

Figure 3.16: Speaker [33]

(48)

A toggle switch is used to turn off the speaker when the speaker sounds. It consists of 3 pins which are end terminal, wiper terminal and end terminal. The value of the wiper terminal will change depending on which side the toggle switch is turned to. Figure 3.17 shows the figure of toggle switch.

Figure 3.17: Toggle Switch [34]

3.2.2 Software Development

3.2.2.1 Read Sensor Data and Store Data in Local Database

Python language is used to program RPi 3 to read and store the sensor data from all sensors to local database, send email to user for awareness and sound the speaker when in non-ideal environment. Python is a powerful programming language that is easy to use which easy to read and write [35].

To read data from sensor, SPI library need to be imported to the coding. SPI or called Serial Peripheral Interface is an interface bus which used to send data between microcontrollers and small peripherals such as shift registers, sensors, and SD cards [36].

Figure 3.18 shows the coding of getting analogue data from sensor by using the library.

Figure 3.18: Coding for Getting Analogue Data from Sensor

To retrieve data from database or insert and update sensor data to database, MySQLdb library need to import to the coding. As mentioned before, MySQL is used to talk to database. Figure 3.19 shows the coding to make connection between sensors and database. Figure 3.20 to Figure 3.22 show the example coding for retrieving data, updating data, and inserting data.

def ReadChannel(channel):

adc = spi.xfer2([1,(8+channel)<<4,0]) data = ((adc[1]&3) << 8) + adc[2]

return data

(49)

Figure 3.19 shows the coding about the declaration of the database used information. The figure also shows the coding of giving command to retrieve data from database and insert data to database.

Figure 3.19: Coding for Getting Connection between Sensors and Database Figure 3.20 shows the coding for retrieving the lower limit value of temperature that had been set. The purpose of the code is to analyse the current status of temperature to find out whether the temperature is within the limitation range.

Figure 3.20: Example Coding of Retrieving Data

def databaseHelper(sqlCommand,sqloperation):

configurations = getConfigurations() host = configurations["mysql"][0]["host"]

user = configurations["mysql"][0]["user"]

password = configurations["mysql"][0]["password"]

database = configurations["mysql"][0]["database"]

backuppath = configurations["sqlbackuppath"]

data = ""

db = MySQLdb.connect(host,user,password,database) cursor=db.cursor()

if sqloperation == "Select":

try:

cursor.execute(sqlCommand) data = cursor.fetchone()

except:

db.rollback() elif sqloperation == "Insert":

try:

cursor.execute(sqlCommand) db.commit()

except:

db.rollback()

emailWarning("Database insert failed", "") sys.exit(0)

sqlCommand = " SELECT Temperature FROM lowerlimit "

templow=databaseHelper(sqlCommand,"Select")

(50)

Figure 3.21 shows the coding to update the current value and status for each sensor to “currentstatus” table in the local database.

Figure 3.21: Example Coding for Updating Data

Figure 3.22 shows the coding to insert current temperature value to “tempdata”

table which in the local database.

Figure 3.22: Example Coding for Inserting Data

Besides, there is a feature that an email is sent to user if one of the parameters is out of the range of limitation value. To send email to user, some libraries need to import to the coding. SMTP or called Simple Mail Transfer Protocol is a TCP/IP protocol used in sending and receiving e-mail [37]. To program it, some configurations and settings are set before an email function can be called out through coding when one of the parameters out of its limitation range. Figure 3.23 shows the coding for declaring email configurations in python programming.

sqlCommand = "UPDATE currentstatus SET Temperature='%s',Temperature_Status='%s',

Humidity='%s',Humidity_Status='%s',Light='%s',Light_Status='%s',Sou nd='%s',Sound_Status='%s',Dust='%s',Dust_Status='%s',LPG='%s',LPG_S tatus='%s',CO='%s',CO_Status='%s',Smoke='%s',Smoke_Status='%s',Flam e='%s',Flame_Status='%s',Water='%s',Water_Status='%s',Air_Pressure=

'%s',Air_Pressure_Status='%s'" %(temp,status[0],hum,status[1],light ,status[2],sound,status[3],dust,status[4],mq2LPG,status[5],mq2CO,st atus[6],mq2SM,status[7],flame,status[8],water,status[9],pressure,st atus[10])

databaseHelper(sqlCommand,"Insert")

sqlCommand = "INSERT INTO tempdata SET Value='%s', Status='%s'" %(temp,status[0])

databaseHelper(sqlCommand,"Insert")

Rujukan

DOKUMEN BERKAITAN

The objective of this research is to determine the influence of varying light Abstract: Light is an important environmental factor that have an influence on a

This project has developed the IoT-Based Monitoring Wick Hydroponic System to ease user in monitoring their hydroponic plant. User will be notified the temperature and

Website is the main control mode in this aquarium monitoring system where the user can monitor the sensors of aquarium and control the its actuators such as light, water pump,

Significant operation mechanism of internet connectivity embedded remote triggering and monitoring system is concentrated in signal translation of network embedded system,

The use of sockets manually is still used, with this S-IoT system the user does not have to turn on and off an electrical appliance manually the socket can be controlled

The proposed design tool can be used to identify the sizing of the GCPV system and conduct the performance, environmental and economic analysis on the recommended

So, the main concern for this project was to design and develop an Internet of Things (IoT) enabled weather station using sensing technology that can measure ambient

Sensors used in the monitoring system are pH sensor module E-201-C, waterproof temperature sensor DS18B20 and water level sensor switch.. Water temperature sensor