Final-2017-5-1-Zhuo LI-Thesis

Download as pdf or txt
Download as pdf or txt
You are on page 1of 74

ARDUINO BASED ENVIRONMENTAL AIR

MONITORING SYSTEM

By
ZHUO LI

Submitted in partial fulfillment of the requirements

For the degree of Master of Science

Department of Electrical Engineering and Computer Science

CASE WESTERN RESERVE UNIVERSITY

August, 2017
CASE WESTERN RESERVE UNIVERSITY

SCHOOL OF GRADUATE STUDIES

We hereby approve the thesis/dissertation of

(Zhuo Li)

Candidate for the degree of (Master of Science)*

Committee Chair

(Christos Papachristou)

Committee Member

(Christos Papachristou)

Committee Member

(Hongping Zhao)

Committee Member

(Ming-Chun Huang)

Date of Defense

(May 1st)

*We also certify that written approval has been obtained


for any proprietary material contained therein

I
Table of Contents
List of Tables ............................................................................................................................III
List of Figures ......................................................................................................................... IV
Abstract ................................................................................................................................... VI
1. Introduction ...................................................................................................................................1
1.1 Motivation ...........................................................................................................................1
1.2 Project overview..................................................................................................................2
1.3 Outline of thesis ..................................................................................................................3
2. Background ...................................................................................................................................5
2.1 Air environmental parameters .............................................................................................5
2.2 Embedded design and Arduino platform ...........................................................................10
2.3 Sensor techniques ..............................................................................................................12
3. Design methods ...........................................................................................................................15
3.1 System key requirements ..................................................................................................15
3.2 System design overview ....................................................................................................15
3.2.1 Working principle ...................................................................................................15
3.2.2 Architecture design .................................................................................................17
3.3 System controller unit .......................................................................................................18
3.4 Sensors methodology ........................................................................................................20
3.4.1 PM2.5 sensor module .............................................................................................20
3.4.2 Temperature and humidity sensor module..............................................................23
3.4.3 Rain sensor module ................................................................................................24
3.4.4 Electrochemical gas sensor module........................................................................26
3.5 Hardware schematic design ...............................................................................................31
3.5.1 Power circuits .........................................................................................................32
3.5.2 Clock circuit ...........................................................................................................38
3.5.3 Analog to digital converter circuit ..........................................................................41
3.6 Software implementation ..................................................................................................43
3.7 System output and end device ...........................................................................................48
4. Experiment and results ................................................................................................................52
4.1 Twelve hours experiments .................................................................................................52
4.2 PM2.5 sensor experiment ..................................................................................................56
4.3 Rain sensor experiment .....................................................................................................58
5. Summary and future work ...........................................................................................................59
5.1 Summary ...........................................................................................................................59
5.2 Future work .......................................................................................................................60
Appendix .........................................................................................................................................62
A. Project schematic ................................................................................................................62
B. Print circuit board ...............................................................................................................63
C. Project budget .....................................................................................................................64
Bibliography....................................................................................................................................65

II
List of Tables
Table 2.1 PM2.5 pollutant level ................................................................................................6
Table 3.1 Arduino mega 2560 specification ..........................................................................18
Table 3.2 PMS1003 sensor specification.................................................................................22
Table 3.3 Electrochemical gas sensors ....................................................................................30
Table 3.4 Pin definition of the TPS73801 ...............................................................................35
Table 3.5 Pin definition of DS1302 .........................................................................................39
Table 3.6 ADS 1115 pin definition ..........................................................................................42
Table 3.7 Timer function code .................................................................................................47
Table C.1 Hardware cost .........................................................................................................64

III
List of Figures
Figure 2.1 Working principle of the NDIR sensor ..................................................................12
Figure 3.1 System block diagram ............................................................................................17
Figure 3.2 Arduino mega 2560 board .....................................................................................19
Figure 3.3 Block diagram showing all interfaces with the Arduino microcontroller ..............19
Figure 3.4 PMS1003 sensor ....................................................................................................21
Figure 3.5 Function block diagram of the sensor ....................................................................22
Figure 3.6 PM2.5 connection block diagram ..........................................................................23
Figure 3.7 AM2302 sensor ......................................................................................................24
Figure 3.8 TEMP/HUM connection block diagram ................................................................24
Figure 3.9 FC-37 sensor ..........................................................................................................25
Figure 3.10 Rain senor connection block diagram ..................................................................25
Figure 3.11 KE-50 sensor ........................................................................................................26
Figure 3.12 O2 sensitivity ........................................................................................................27
Figure 3.13 Oxygen electrochemical sensor structure.............................................................27
Figure 3.14 MG-811 sensor.....................................................................................................28
Figure 3.15 CO2 and O2 connection block diagram ................................................................29
Figure 3.16 System Schematic block diagram ........................................................................31
Figure 3.17 Power circuit ........................................................................................................32
Figure 3.18 7805 regulator ......................................................................................................33
Figure 3.19 TPS73801 circuits ................................................................................................34
Figure 3.20 TPS73801 simplified schematic...........................................................................36
Figure 3.21 Clock circuit .........................................................................................................38
Figure 3.22 Analog to digital signal block diagram ................................................................41
Figure 3.23 AD converter circuit .............................................................................................42
Figure 3.24 ADS1115 ..............................................................................................................42
Figure 3.25 Flow chart for monitoring air quality parameters ................................................44
Figure 3.26 Screen display ......................................................................................................49
Figure 3.27 Screen connection diagram ..................................................................................49
Figure 3.28 CP2102 USB to UART adaptor ...........................................................................50
Figure 3.29 DATA received on a host computer .....................................................................50
Figure 3.30 AC-DC Power adapter .........................................................................................51
Figure 3.31 Battery holder ......................................................................................................51
Figure 3.32 Final prototype .....................................................................................................51
Figure 4.1 Temperature measurement .....................................................................................53
Figure 4.2 humidity measurement ...........................................................................................53
Figure 4.3 CO2 measurement ..................................................................................................54
Figure 4.4 O2 measurement .....................................................................................................55
Figure 4.5 PM2.5 measurement ..............................................................................................56
Figure 4.6 Screenshot taken from Airnow...............................................................................56
Figure 4.7 PM2.5 sensor experiment.......................................................................................57
Figure 4.8 Rain sensor experiment ..........................................................................................58

IV
Figure 5.1 Solar module connection diagram..........................................................................61
Figure A.1 System schematic ..................................................................................................62
Figure B.1 Print circuit board layout .......................................................................................63
Figure B.2 Print circuit board ..................................................................................................63
Figure B.3 Completely assembled circuit board without attached external components ........64

V
Arduino Based Environmental Air Monitoring System

Abstract

by
ZHUO LI

Environmental air parameters directly affect our daily quality of life, and they can

change from day to day or even hour to hour. With rapid industrialization over the past

few decades, there is a dramatically increasing demand for people to monitor the local

air quality to know how they live and what they breathe. In this work, we proposed an

air monitoring system based on the Arduino platform. This environmental air

monitoring system is designed to provide an efficient, straightforward and robust

solution to monitor the air quality continuously and in real-time. It is a portable system

that integrates multiple sensors into a single unit and can be placed anywhere. The

acquired results are displayed on a screen and can also be saved on a host computer for

further analysis.

VI
1. Introduction

1.1 Motivation

The atmosphere is a chaotic system, air condition is influenced by many factors and

can change quickly. Air condition and quality directly affect people’s daily lives, such

as their commute to work and the safety of outdoor activities. With the awareness of

more and more serious air pollution in many countries growing, there is an increasing

demand for a more efficient way to observe, record and collect air quality data.

Usually, people will obtain atmospheric conditions from weather forecasts, but these

can only provide limited information in any given location, and are not very accurate.

Although there are some advanced systems that might be able to monitor more

atmospheric parameters, these systems usually generalize their measurements over a

very large area, for instance, monitoring real time parameters for a metropolitan area or

a large suburbs using a few observation points. Additionally, after reviewing many

articles, currently there is no device available on the market that could automatically

monitor multiple types of air quality parameters at the same time, specifically the

combination of O2(Oxygen)、PM2.5(Particulate matter that has a diameter of 2.5um

or less)、CO2 (Carbon Dioxide)、rain、temperature and humidity. This makes getting

the whole picture in terms of harmful particles, gases, temperature and humidity very

difficult.

1
Therefore, it is useful to develop a single mobile device that is fully automated mobile

device that can capture measurements at any location for short-term and long-term

analysis. This proposed environmental monitoring system can give real time

measurements of 6 air parameters and record the results on a host computer for future

studies. The system integrates O2、PM2.5、CO2、rain、temperature and humidity sensors

into one single unit and utilizes an Arduino Mega 2560 as the controller component.

The proposed system provides a user friendly, low cost, and portable solution to monitor

multiple environmental air parameters.

1.2 Project overview

By incorporating the techniques of sensors and embedded system design, this

environmental air monitoring system can provide a convenient and straightforward

monitoring method that integrates multiple sensors into a single unit. This is a portable,

user-friendly, low power and low cost air monitoring device that can measure

environmental air parameters of interest in real-time. This device can be used anywhere

to monitor air quality, including outdoors for industrial air pollution near factories and

indoors for home, hospital or school use with sensitive populations. The data provided

from the device can be used to distinguish between high and low air quality areas.

Through this system, we can automatically collect the information about PM 2.5,

humidity, temperature, CO2, O2, and rain. The values read from the sensors are

processed by the Arduino microcontroller and the results are displayed on the OLED

2
(Organic Light Emitting Diodes) screen for quick viewing. The results can also be

stored as a text file on a host computer. These saved values can be used to produce

graphical representations of the air characteristics and further analyze the data to look

for trends within a given area of a particular period of time.

In addition, this device is designed with an additional connection port, which can be

used to connect another gas sensor. This provides more flexibility going forward for

both the product designer, who can easily add and or test new sensors, and the consumer,

who has the ability to tailor the device to their personal needs. This additional port is

connected to a separate power supply to reduce the power consumption and allow the

sensor to operate periodically. The connection port is connected to an AD converter to

digitize the sensor’s analog signal and the result will display on the screen. With this

extra port, the device can measure any type of potential air pollutants, such as CO

(Carbon Monoxide), SO2 (Sulfur Dioxide), O3 (Ozone), etc. along with the 6 measures

already taken by the device. This customizability gives the product limitless potential.

1.3 Outline of thesis

The thesis is organized as follows. Chapter 1 lays out the motivation of the study, and

followed by a briefly overview of the project. Chapter 2 describes the background of

the research, including the different air environmental parameters. The embedded

system design and sensor technique are reviewed. Chapter 3 discusses all the hardware

components used in the project, and why the specific hardware and software designs

3
were made based on the Arduino platform. In Chapter 4, the experiment setup is

discussed, followed by the results of these experiments. In Chapter 5, the project is

summarized and future directions of the research are discussed.

4
2. Background

2.1 Air environmental parameters

With rapid industrialization and urbanization over the past decades, the world has

experienced widespread air pollution and increased awareness of the importance of

environmental air monitoring. Air pollution can be defined as an atmospheric condition

in which various substances are present at concentrations high enough, above their

normal ambient levels to produce a measurable effect on people, animals, vegetation or

materials. Air pollutants are dangerous to human health as well as environment [1].

In scientific research concerning air quality studies, scientists are able to determine the

significant short and long-term impacts that come from industrial activities and the

areas that may experience these effects. In people’s daily lives, environmental monitors

can indicate the safety of people’s in-door and out-door activities. For example, people

can stay informed of local real-time air pollution to decide if they can exercise outside,

if they need a breathing mask to be safe, or if staying indoors is their best option. In

extreme conditions, schools will be closed for the safety of the children, and it is best

for anyone who is sensitive to reduce their exposure to hazardous air pollution levels.

Deciding the air quality on any given day requires environmental analysis and

monitoring, which is a very challenging and dynamic field. In this part, we discussed

the several major air parameters that are related to the safety of people during their day-

5
to-day lives.

There has been an increasing awareness of the air quality issue all over the world, with

a special focus on PM 2.5. This parameter refers to microscopic solid or liquid matter

suspended in the air that has a diameter of 2.5µm or less. Particle pollution comes from

many different types of sources, including power plants, industrial processes, vehicle

tailpipes, woodstoves, wildfires, and some agricultural operations. PM2.5 is able to

penetrate deep into our lung tissues and can cause various health problems.

Particle pollution is linked to a number of health problems, including coughing,

wheezing, reduced lung function, asthma attacks, heart attacks and strokes. It also is

linked to early death [2]. Therefor it is best for kids、older adults and other sensitive

people to protect themselves from unhealthy air condition by shortening outdoor

activities and choosing less strenuous activities. The table 2.1 [3] shows the impacts of

different level of PM2.5 pollutant.

Table 2.1 PM2.5 pollutant level

PM2.5 (µg/m3) PM2.5 Health Effects Statement PM2.5 Cautionary Statement


Good PM2.5 air pollution poses little or
None
(0-35) no risk.
Unusually sensitive individuals Unusually sensitive people
Moderate
may experience respiratory should consider limiting
(36-75)
symptoms. prolonged outdoor exertion.
Increasing likelihood of Active children and adults,
Unhealthy for
respiratory symptoms in and people with respiratory
Sensitive Groups
sensitive individuals, disease, such as asthma,
(75-115)
aggravation of heart or lung should limit prolonged
6
disease and premature mortality outdoor exertion.
in persons with cardiopulmonary
disease and the elderly.
Active children and adults,
Increased aggravation of heart or and people with respiratory
lung disease and premature disease, such as asthma,
Unhealthy mortality in persons with should avoid prolonged
(116-150) cardiopulmonary disease and the outdoor exertion; everyone
elderly; increased respiratory else, especially children,
effects in general population. should limit prolonged
outdoor exertion.
Significant aggravation of heart Active children and adults,
or lung disease and premature and people with respiratory
mortality in persons with disease, such as asthma,
Very Unhealthy
cardiopulmonary disease and the should avoid all outdoor
(151-250)
elderly; significant increase in exertion; everyone else,
respiratory effects in general especially children, should
population. limit outdoor exertion.
Serious aggravation of heart or
lung disease and premature
mortality in persons with
Hazardous Everyone should avoid all
cardiopulmonary disease and the
(251-500) outdoor exertion
elderly; serious risk of
respiratory effects in general
population.

Oxygen is another important air parameter, as it’s essential to life. The oxygen level in

the atmosphere varies from place to place. For instance, areas near a large number of

factories and big cities have lower Oxygen levels due to pollution. Other places such as

rural areas and forests have higher oxygen levels that promote good health because

there is less pollution and more plants to make oxygen.

The normal atmosphere contains between 20.8 to 21 percent oxygen. According to

OSHA (Occupational Safety and Health Administration), air oxygen concentration

below 19.5 percent is considered to be oxygen deficient; and above 22 percent is oxygen

7
enriched.

CO2 is a colorless, odorless gas and non-combustible gas. Moreover, it is considered

under the category of asphyxiate gases that have capability of interfering the availability

of oxygen for tissues [4]. The global average concentration of CO2 now in Earth's

atmosphere is about 400 ppm (parts per million by volume). Prior to the Industrial

Revolution, CO2 levels were at 280 ppm. The planet didn't reach the 400 ppm mark by

itself. There is abundant evidence showing that the atmospheric CO2 increase is caused

by humans. CO2 makes up less than 1 percent of our atmosphere. But this small

amount of CO2 has a big impact on the planet. Plants use CO2 for photosynthesis and

earth's temperature is controlled by CO2. For these reasons and more, CO2 is an

important parameter in measuring air quality.

The unit of parts per million (ppm) is numerically equivalent to micromoles of CO2 per

mole of air. Outdoor CO2 levels are usually 350-450 ppm whereas the maximum indoor

CO2 level considered acceptable is 1000 ppm. When the concentration goes above

1000ppm, the air becomes stagnant and people begin to feel sleepy. Once the CO2

reaches 5000ppm, a person should be limited to 8 hours of exposure according to OSHA

(The Occupational Safety and Health Administration).

Rain can help to remove pollutant particles from the air, and it is a very efficient way

to decrease the PM2.5 level quickly. It is also linked to temperature and humidity levels

8
thus is an important factor in weather condition.

Temperature and humidity also affect the presence of pollutants in the air. For instance,

haze often occurs when dust, smoke and other pollutant particles accumulate in

relatively dry air. Winter is the most polluted time of year in China, as cold and dry air

prevents smoke and other pollutants from dispersing. This is because warm air sits near

the ground and the air can rise easily and carry away pollutants, but cold air is trapped

near the ground by a layer of warm air.

Temperature and humidity can also affect human comfort and many manufacturing

processes in industries. OSHA recommends temperature control in the range of 20-

25°C and humidity control in the range of 20%-60%.

In addition to above parameters there are some other factors that determine the air

quality. These factors include toxic gases (NOx, O3, CO, SO2, NH3, H2S), volatile

organic compounds (benzene, toluene, xylene), polycyclic aromatic hydrocarbons

(PAH), greenhouse gases (CO2, CH4, N2O), particulate matter PM2.5, PM10 (PM10

are particles less than 10 micrometers in diameter), aerosol and dust, heavy metals,

pollens in the environment. Humans inhaling pollutants for an extended period of time

will cause irreversible damage to their health [5].

9
2.2 Embedded design and Arduino platform

This system utilize the embedded design technique and the Arduino platform.

According to the definition of IEEE, an embedded system is a single-purpose computer

built into a larger system for the purposes of controlling and monitoring the system [6].

Arduino is a tiny embedded system that you can program to process between the device

and the external components you connect to it. Embedded systems can range from

having no user interface (UI) -- for example, on devices in which the embedded system

is designed to perform a single task -- to complex graphical user interfaces (GUI), such

as in mobile devices. User interfaces can include buttons, LEDs, touchscreen sensing

and more. Some systems use remote user interfaces as well. Embedded systems control

many devices in common use today. Embedded systems use operating systems or

language platforms tailored to embed use, particularly where real-time operating

environments must be served [7]. Several operating systems have been developed

specifically for embedded applications, the dominant operating systems are Linux,

Android, Windows CE, VxWorks, and QNX.

Arduino is an open-source electronics platform. Arduino hardware board designs use a

variety of microprocessors and controllers. The hardware boards are equipped with sets

of digital and analog input/output (I/O) pins that may be interfaced to various expansion

boards (shields) and other circuits. The boards feature serial communications interfaces,

including Universal Serial Bus (USB) on some models, which are also used for loading

programs from personal computers. Arduino integrated development environment (IDE)


10
is the software part that supplies many very good libraries for basic functionalities, and

could run on Mac, Windows, and Linux. Compared with other systems, Arduino offers

some specific advantages [8]:

 Inexpensive - Arduino boards are relatively inexpensive compared to other

microcontroller platforms.

 Cross-platform - The Arduino Software (IDE) runs on Windows, Macintosh OSX,

and Linux operating systems. Most microcontroller systems are limited to

Windows.

 Simple, clear programming environment - The Arduino Software (IDE) is easy-to-

use for beginners, yet flexible enough for advanced users to take advantage of as

well.

 Open source and extensible software - The Arduino software is published as open

source tools, available for extension by experienced programmers. The language

can be expanded through C++ libraries, and people wanting to understand the

technical details can make the leap from Arduino to the AVR C programming

language on which it's based. Similarly, you can add AVR-C code directly into

your Arduino programs if you want to.

 Open source and extensible hardware - The plans of the Arduino boards are

published under a Creative Commons license, so experienced circuit designers can

make their own version of the module, extending it and improving it.

11
2.3 Sensor techniques

A sensor is a device that detects and responds to some type of input from the physical

environment. The specific input could be light, heat, motion, moisture, pressure, or any

one of a great number of other environmental phenomena. The output is generally a

signal that is converted to human-readable display at the sensor location or transmitted

electronically over a network for reading or further processing [9]. Sensor types include

photoionization detectors, infrared point sensors, ultrasonic sensors, electrochemical

gas sensors, and semiconductor sensors, laser sensors.

In general, infrared sensors and electrochemical sensors are two common types in

detecting air gas content. The non-dispersive infrared (NDIR) absorption method is a

popular spectroscopic approach of gas concentration measurement that is best suited

for gases with absorption lines in 3-5 and 8-12 µm ranges [10]. For instance, NDIR

sensor can use for CO2, CO, N2O, hydrocarbons and hydrogenated fluorocarbons.

Figure 2.1 Working principle of the NDIR sensor Figure 1

An infrared (IR) lamp directs waves of light through a tube filled with air toward an IR

12
light detector, which measures the amount of IR light that hits it. As the light passes

through the tube, any gas molecules that are the same size as the wavelength of the IR

light absorb the IR light only, while letting other wavelengths of light pass through.

Next, the remaining light hits an optical filter that absorbs every wavelength of light

except the exact wavelength absorbed by the measured gas. Finally, an IR detector reads

the amount of light that was not absorbed by the measured gas molecules or the optical

filter. The difference between the amount of light radiated by the IR lamp and the

amount of IR light received by the detector is measured. The difference is proportional

to the number of measured gas molecules in the air inside the tube [11].

The advantage of NDIR approach is the high sensitivity and wide heat energy dynamic

and frequency ranges [10]. However, This NDIR sensor is very large and has a slow

response time, and is cost prohibitive. Because of these limitation, electrochemical gas

sensors are more suitable for a portable device in terms of size and cost.

There are three types of PM2.5 detectors: infrared detector, beta attenuation mass

monitoring detector and laser diffraction detector. Infrared detector can only give a

good or bad assessment, without an exact value of PM2.5 particles. Beta attenuation

monitoring is a widely used air monitoring technique employing the absorption of beta

radiation by solid particles, as Beta radiation can pass through solid matter. The main

principle is based on a kind of Bouguer (Lambert–Beer) law: the amount by which the

flow of beta radiation (electrons) is attenuated by a solid matter is exponentially

13
dependent on its mass and not on any other feature (such as density, chemical

composition or some optical or electrical properties) of this matter. The air is drawn

from outside of the detector through an "infinite" (cycling) ribbon made from some

filtering material so that the particles are collected on it [12].

Beta attenuation measurements can get extremely accurate results of particles’ size and

density in the air, but they’re very big and cost thousands of dollars. This is the type of

measurement detector used only by big monitoring agencies, such as the US embassy

in Beijing. The last one, laser sensors, are a more common type on the market that

people can afford. Its performance is very excellent and can produce results very close

to those of the beta attenuation detector.

14
3. Design methods

3.1 System key requirements

The goals of this system are:

 The system provides a user friendly, straightforward and robust solution to monitor

the air quality continuously and in real-time.

 The system is a portable device that can be located anywhere to monitor the indoor

and outdoor air parameters.

 The system has high measurement accuracy and low power consumption.

 The system provides comprehensive air quality measurements by integrating

multiple air parameters into one system.

 The system is compatible with multiple types of gas sensors so that it can be

customized for future needs.

3.2 System design overview

3.2.1 Working principle

This system works by collecting data of specific environmental parameters, including

gas contents and the amount of dust present in the air. The system has five fixed sensors

and an additional connection port for an extra gas sensor. The five fixed sensors monitor

six types of air parameters: PM 2.5, humidity, temperature, CO2, O2, and rain. The extra

sensor can be chosen from multiple types of gas sensors that are compatible with this

device, such as CO, SO2, and O3.


15
In general, after sensor modules detect the air environmental variables, they generate

either analog data or digital data depending on the sensor type for further processing.

An analog to digital converter is utilized to convert analog data into a digital signal.

The Arduino microcontroller processes all the acquired digital signals and then displays

the final results on the OLED (organic light-emitting diode) screen.

A professional debugging assistant software can continuously receive the incoming

environmental parameters from the serial port and store the data in a text file on the

host computer. The Arduino micro-controller communicates with the host computer

through its serial port. These extracted data can be plotted on a graph, which offers a

way to visualize trends over a period of time for changing air environment parameters

and historical weather patterns.

16
3.2.2 Architecture design

Figure 3.1 System block diagram Figure 2

This environmental air monitoring system is based on the block diagram shown in

Figure 3.1. There are two main parts. The dashed lines represent data acquisition

mechanisms. The right part represents the data processing and display components.

The left part is designed to acquire the air parameters, which includes measurement

circuits for CO2, PM2.5, temperature and humidity, O2, and rain, as well as an additional

air gas measurement circuit that can be customized for future use. The gathered analog

data from O2, CO2 and, potentially, the extra gas sensors are digitized by sharing a same

AD converter.

The right part includes the power supply module, clock circuit, and screen display

circuit. The Arduino microcontroller is the main component that is centrally connected

17
to all the other components. The clock circuit provides the function of time keeping and

synchronizes different parts of the circuit. This power supply module includes two types

of voltage regulators: LM7805 and TPS73801. Because LCD’s back-light display

consumes a lot of power, the system here uses a more efficient OLED display. The

microcontroller is connected to an OLED screen and a host computer to display and

save the measurements. The results can be read out through the Arduino’s serial port to

a host computer.

Through these two parts, the Arduino microcontroller processes the data detected by all

the sensors and further converts them into a viable form.

3.3 System controller unit

The system uses the Arduino Mega 2560 board which encompasses an ATmega2560

microcontroller and associated hardware.

Table 3.1 Arduino mega 2560 specification Table 2


Specification
Microcontroller Operating ATmega2560
Voltage 5V
Input Voltage 7-12V
Digital I/O Pins 54
Analog Input Pins 16
DC Current per I/O Pin 40 mA
DC Current for 3.3V Pin 50 mA
Flash Memory 256 KB of which 8 KB used by bootloader
SRAM 8 KB
EEPROM 4 KB
Clock Speed 16 MHz

18
Figure 3.2 Arduino mega 2560 board Figure 3

There are analogue input and digital input/output pins available the board for the

attachment of other electronic devices for input or output. As shown in figure 3.2 [13],

Arduino Mega 2560 board has 54 digital I/O pins, 16 analog inputs, 4 hardware UARTs,

a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a

reset button. There are 14 of 54 digital I/O pins that can be used as PWM outputs, which

can modulate output voltage using different pulse widths. The 4 hardware UARTs are

used for serial communication. The board can be powered using the USB connector or

powered using the AC to DC adapter or battery.

Figure 3.3 Block diagram showing all interfaces with the Arduino microcontroller Fig 4

Figure 3.3 is the block diagram that shows all interfaces with the microcontroller. The

gas sensors give out analog signals that are digitized by the 16 bits Analog to digital
19
converter. Temperature & Humidity, rain, clock module are connected with the

Arduino’s digital I/O pins. PM2.5 sensor module uses UART communication to

transmit data to the Arduino. The Arduino uses the I2C bus to communicate with the

Analog to digital converter and the OLED screen. I2C communication needs to use the

Arduino's SDA and SCL pin. SCL stands for 'serial clock' and is used to control when

data is sent. The SDA line is used to send over serial data.

3.4 Sensors methodology

The proposed device consists of 5 fixed sensors that are used to monitor air parameters.

These 5 sensors are PM 2.5, humidity and temperature, CO2, O2, and rain sensors. The

sensors are connected to an Arduino Mega 2560 board. When the device is powered on,

the sensors start to generate data in real time. In this section, each sensor will be

discussed in detail.

3.4.1 PM2.5 sensor module

Fine particulate matter (PM2.5) are tiny particles in the air with a diameter of 2.5μm or

less. It is an air pollutant that is a concern for people's health and causes the air to appear

hazy. Therefore, the number of suspended particles in the air is a very important ambient

value. This proposed system uses a PMS1003 sensor to detect PM2.5 concentration in

the air. PMS1003 has excellent performance in detecting fine particulate matter, along

with being very stable and reliable. PMS1003 can directly provide real time responses

and digital output values. Its minimum distinguishable particle diameter is 0.3μm.

20
Figure 3.4 PMS1003 sensor Figure 5

The sensor works using the laser scattering theory and therefore has high accuracy. The

sensor produces scattering by using a laser to radiate suspending particles in the air,

then collects scattering light in a certain degree, and finally obtains the curve of

scattering light over time. In the end, equivalent particle diameter and the number of

particles with different diameters per unit volume can be calculated based on MIE

theory [14]. This theory suggests situations where the size of the scattering particles is

comparable to the scattered light pattern. MIE theory does not refer to an independent

physical theory or law, but instead to the collection of MIE solution and model. The

MIE solution to Maxwell’s equations describes the scattering of an electromagnetic

plane wave by a homogeneous sphere. The solution takes the form of an infinite series

of spherical multipole particle waves. The scattering of particles is accurately predicted

by the MIE scattering model [15].

21
Figure 6Figure 3.5 Function block diagram of the sensor [14]

As illustrated in figure 3.5, light scattering can be induced when particles go through

the detecting area. The scattered light is transformed into electrical signals and these

signals will be amplified and processed. The number and diameter of particles can be

obtained by analysis because the signal waveform has certain relationship with the

particles diameter. To have the system work accurately, the sensor needs to have the

sensed air ventilated, so a fan is built in the sensor [16].

Table 3.2 PMS1003 sensor specification


Specification:
Range of measurement 0.3-1.0μm, 1.0-2.5μm
Minimum distinguishable particle diameter 0.3μm
Total Response Time: <10s
Operational voltage: DC 5V
Effective Range 0-500μg/m3
Resolution 1μg/m3
Dimension 65×42×23mm

This sensor module has eight pins: GND, VCC, SET, RX, TX, RESET, PIN7 and PIN

8. According to the manual, PIN7 and PIN8 should never be connected. VCC pin should

connect to the 5V power supply. Ground pin should connect to the ground. The sensor
22
is in the working status when SET pin pull high. When SET pin is in low level, the

sensor is set to sleeping mode. When RESET pin goes low, the sensor will reset the

signal, so writing this pin high to ensure the working state is maintained. RX and TX

pins are connected with the Arduino’ UART port to transmit the data.

Figure 3.6 PM2.5 connection block diagram Figure 7

The PM2.5 data packet has 32 bytes; the first two data bytes, 0x42 and 0x4D, are two

fixed communication starting indicators. The 13th and 14th data bytes specify the value

of PM2.5 (the 13th is high 8 bits and the 14th is low 8 bits). In order to improve the

accuracy, we set the sensor to take 10 consecutive readings, excluding the highest and

lowest readings, and then we take the mean of the remaining 8 measurements.

3.4.2 Temperature and humidity sensor module

The temperature and humidity measurements sensor module used in this system is AM

2302, it uses a capacitive humidity sensor and a thermistor to measure the surrounding

air. It provides the current temperature and humidity readings and give out digital

readings. The sensor includes a capacitive sensor wet components and a high precision

temperature measurement devices. Capacitive sensing is a technology for detecting

humidity, it is based on capacitive coupling that can detect and measure anything that

is conductive or has a dielectric different from air. A thermistor is a type of negative


23
coefficient resistor whose resistance is dependent on temperature, it is widely used for

temperature measurements.

Figure 3.7 AM2302 sensor Figure 8

Figure 3.8 TEMP/HUM connection block diagram Figure 9

AM2302 sensor module has several good characteristics such as low power

consumption, long term stability, fast response, strong anti-interference ability. The

sensor communicate with the Arduino using a DHT library. This sensor is operated at

3.3V-5.5V. The temperature range is﹣40 ~ 80ºC, and the accuracy is ± 1ºC, response

time <10s. The humidity Accuracy ±2 %RH, and range is Range 0-99.9 %RH, response

time <5s. Three pins are used in this sensor module: DAT, VCC, and GND. As

illustrated in Figure 3.8, connect the sensor’s DAT pin to Arduino’s digital I/O pin, and

then the microcontroller can read the data.

3.4.3 Rain sensor module

The FC-37 rain sensor module is used for rain detection. It is made with high quality

24
RF-04 double sided material and has good anti-oxidation and anti-conductivity features.

The sensor’s dimensions are 5cm×4cm, and it is operated at 5V. As shown in figure

3.9,the FC-37 rain sensor consists of two pieces: the electronic board and the collector

board that collects the water drops. There is an indicator light on the electronic board

that shows whether the sensor is working or not.

Figure 3.9 FC-37 sensor Figure 10


The sensor board acts as a variable resistor that will change from 100k ohms when wet

to 2M ohms when dry. When the sensor is wet, the resistance increases, and the output

voltage decreases. When dry, the resistance is lower, and the output voltage is higher.

Figure 3.10 Rain senor connection block diagram Figure 11

The FC-37 rain sensor use three pins to work. The sensors’ DO pin is connected to the

Arduino board’s digital IO pin to communicate. When sensor board has no rain drop,

DO pin output will be high, and indicator light will turn on. When rain sensor detects a

droplet of water, DO pin output is low, the indictor light will turn off.

25
3.4.4 Electrochemical gas sensor module

Electrochemical gas sensor is an analog sensor and gives the output into form of analog

signal. This signal is fed to ADC which will convert it into digital form. Once converted

into digital form, the microcontroller can process the digital gas signal as per the

application [9]. There are many types of electrochemical gas sensors available on the

market and can be used on the Arduino board. In addition to the two gas sensors (O2,

CO2) configured on this device, an extra type of electrochemical gas sensor can be

easily added to the system.

3.4.4.1 O2 sensor

This system used the GS Oxygen Sensor KE-50 (Figure 3.11). It is a unique galvanic

cell type oxygen sensor which was developed by the Japanese company FIGARO. This

sensor has 10 years life expectancy, excellent chemical durability, and most importantly

it is not influenced by CO2, CO, H2S, NOx, H2. The measurement range is 0-100 %,

and Accuracy ±2%. The operating temperature is between 5-40℃.

Figure 3.11 KE-50 sensorFigure 12

The KE series sensor is a lead-oxygen battery which incorporates a lead anode, an

oxygen cathode made of gold, and a weak acid electrolyte. Oxygen molecules enter the

26
electrochemical cell through a non-porous fluorine resin membrane and are reduced at

the gold electrode with the acid electrolyte. The current which flows between the

electrodes is proportional to the oxygen concentration in the gas mixture being

measured. The terminal voltages across the thermistor (for temperature compensation)

and resistor are read as a signal, with the change in output voltages representing the

change in oxygen concentration. The relationship of output voltage of oxygen

concentration is showed in figure 3.12.

Figure 3.12 O2 sensitivity Figure 13

The following chemical reactions which take place in KE sensors are shown [17]:

Cathodic reaction: O2+ 4H++ 4e-→2H2O

Anodic reaction: 2Pb + 2H2O →2PbO + 4H++ 4e-

Total reaction: O2+ 2Pb →2PbO

Figure 14Figure 3.13 Oxygen electrochemical sensor structure [10]

27
3.4.4.2 CO2 sensor module

The CO2 sensor module has an MG-811 on board. It has very good sensitivity, and long

stability. The MG-811 is highly sensitive to CO2 and less sensitive to alcohol and CO.

Figure 3.14 MG-811 sensor Figure 15

The sensor use solid electrolyte cell Principle. The components of the solid electrolyte

cell is shown as below [18]:

Air, Au|NASICON||Carbonate|Au, air,CO2

A single vertical line ( | ) is drawn between two chemical species that are in different

phases but in physical contact with each other (e.g., solid electrode | liquid with

electrolyte). A double vertical line ( || ) represents a salt bridge or porous membrane

separating the individual half-cells.

The below equations show the basic working theory :

When the sensor is exposed to CO2, the following electrodes reactions occurs:

Cathodic reaction:2Li++ CO2 + 1/2O2 + 2e-= Li2CO3

Anodic reaction:2Na++ 1/2O2 + 2e-= Na2O

Overall chemical reaction:Li2CO3 + 2Na+= Na2O + 2Li++ CO2

28
This sensor module is operated at DC 6V, its measurement range is 0-10000 ppm. The

heating consumption is very large, it’s about 1200mW. The dimension of sensor is

40mm×25mm×35mm. Figure 3.15 shows how CO2 and O2 sensor modules are

connected with the AD converter.

Figure 3.15 CO2 and O2 connection block diagram Figure 16

The table 3.3 lists the types of electrochemical gas sensors that are compatible with this

device. Potential additional sensors include O3, CO, CH4, and SO2 sensors; SO2 and O3

are air pollutants linked with industrial activities, and CO sensors can be used to

monitor gas leakage in homes. These sensors can provide the device with more

measurements and applications.

Since the sensors listed all have a large power consumption and require a preheating

process, the dual power supply design enable any sensor chosen in the future operates

periodically. The working principles for these sensors are similar, so they can be easily

implemented as shown for the following reasons:

 5V DC power supply

 Sensor module is compatible to a 3 pin header.

 The output is an analog signal and can be digitized by the system’s AD Converter.
29
Table 3.3 Electrochemical gas sensors Table
4
Sensor Application Power Consumption Picture
Name
MQ-2 CH4 (Methane ≤900mW
gas)

MQ-7 CO (Carbon ≤350mW


monoxide)

MQ131 O3 (Ozone) ≤900mW

2SH12 SO2 ≤800mW

30
3.5 Hardware schematic design

This section explains circuit components and schematic design procedures, along with

operation principles and the system board layout.

Figure 3.16 System Schematic block diagram Figure 17

The device uses a dual power supply design. Two types of voltage regulators are used:

LM7805 and TPS73801. The LM7805 voltage regulator outputs 5 volts for the Arduino

board and all other 5V components that have low power consumption.

The two TPS73801 LDO (low-dropout regulator) are used to power electrochemical

gas sensors. These kinds of sensors have a very high power consumption, and the

TPS73801 LDO regulators are able to supply periodic power to reduce the cost. In

addition, TPS73801 LDO serves to provide a 6V supply to the CO2 sensor.

Because the gas sensors produce analog output, they connect to the AD converter circuit
31
before being read and processed by the microcontroller. The clock circuit serves the

functions of time keeping, synchronizing different parts of the circuit, and coordinating

the actions of digital circuits.

The measurement results are displayed on the screen and also can be viewed on a host

computer. J8 port connects with Arduino’s UART (TXD3 and RXD3) and is used for

debugging and sending the measurements. A host computer’s USB can be connected to

the J8 port via an adaptor.

3.5.1 Power circuits

3.5.1.1 LM7805 voltage regulator

Figure 3.17 Power circuit Figure 18

LM7805 voltage regulator is a popular choice for regulating to a 5V output. In this

design, we will use it to convert 12V to 5V. A heatsink is attached to the chip for

absorbing and dispersing heat.

The LM7805 is a three-pin IC as the figure 3.18 shows. The maximum input voltage is

36V. The regulator will eventually regulate down to 5V. The Ground pin establishes the

32
ground for the regulator. The Output pin is the regulated 5 volts DC.

Figure 3.18 7805 regulator Figure 19

In figure 3.17, D1 allows current to flow only if the correct polarity is applied, so it

functions as a reverse violate protection component. SS36 is a common kind of schottky

diode. F1 fuse is used to protect the circuit if too large a current flows through it. R1

used to limit the current flow going through the LED.

A clean and stable voltage is very important both for input and output of the regulator.

Capacitors placed on the input side are used to filter out any noise coming from the

voltage source. Capacitors placed at the output of the voltage regulator are used to avoid

any ripples or noise imposed on the DC voltage line. A clean DC signal is very

necessary when outputting voltage to power sensitive components. The LM7805

regulator will also work better when a clean DC signal is fed into it.

Large electrolytic capacitors have good ability to filter out low frequency ripple and to

respond to abrupt voltage spikes and drops. A typical 10μF capacitor is chosen here.

However, large electrolytic capacitor itself is not enough to do the whole job. It is not

good at filtering higher frequency noise because electrolytic tend to have large internal

series resistance (ESR). The small capacitors with low ESR and low inductance is
33
therefore added in parallel to the large capacitor. The small capacitors have excellent

high frequency response, but cannot store enough energy to deal with the large load

transients. To achieve the best overall performance, an electrolytic capacitor is added

in parallel to the ceramic capacitor in the circuit. The large electrolytic capacitor handles

low frequency ripple, and major output load changes; the small capacitor handles noise

and fast transients. The small capacitor used here is a non-polarized and multilayer

ceramic capacitor. The value of the small capacitor selected here is a 0.1μF, to ensure

the ratio of two capacitors is large enough.

3.5.1.2 TPS73801 low-dropout regulator

Figure 3.19 TPS73801 circuits Figure 20

Gas sensors like CO2, SO2, and O3 usually require a long time to warm up and have

34
very large power consumption. Depending on the different type of gas sensors, the

heating consumption might be as high as 1200mW. Therefore, a separate power supply

circuit using TPS73801 is designed here to provide voltage directly to the gas sensors.

The sensors work according to the interval that has been set. In addition, this circuit

also meets the need for a 6V input voltage for the CO2 module. There are two LDO

regulators. One is used for the fixed CO2 sensor. The other is used for an extra sensor

that can be added to the system in the future, to provide a more personal and flexible

device.

Table 3.4 Pin definition of the TPS73801Table 5


1 IN Input, power is supplied to the device through the IN pin.
2 Out Output, the output supplies power to the load.
3 Ground Ground
4 FB Feedback. This is the input to the error amplifier.
5 EB Enable. The EN pin is used to put the TPS73801 regulators into a
low-power shutdown state. The output is off when the EN pin is
pulled low.
6 GND Ground

The TPS73801 is a LDO optimized for fast transient response. Many sensitive sensors

cannot tolerate voltage ripple and spikes. The TPS73801 regulators have very low

output noise, which makes them ideal for sensitive RF supply applications. Output

voltage range is from 1.21 to 20 V. Internal protection circuitry includes reverse-battery

protection, current limiting, thermal limiting, and reverse-current protection. The

devices are available as an adjustable device with a 1.21-20V reference voltage. Other

applications include post regulator for switching supplies and portable/battery-powered

equipment. [19]

35
The TPS73801 regulator has an EN pin to shutdown the output power supply. The

output is off when the EN pin is pulled low, and the output is on when the EN pin is

pulled high. This enable the gas sensor working periodically. Thus the overall power

consumption of the system are reduced. In addition, the TPS73801 can regulate the

output voltage with small dropout voltage and current ripple. Through this design, the

system will achieve a better performance, low-noise and low consumption.

The TPS78301 has an adjustable output voltage range, the output voltage can range

from 1.21V to 20V. In order to provide 5V and 6V voltages for sensors, respectively,

we need to calculate the values of resistance used in the circuits. The output voltage is

set by the ratio of two external resistors as shown in figure 3.20. The device maintains

the voltage at the FB pin at 1.21V referenced to ground. The current in R1 is then equal

to 1.21V/R1, and the current in R2 is the current in R1 plus the FB pin bias current. The

FB pin bias current, 3uA flows through R2 into the FB pin. The output voltage can be

calculated using the formula shown in equation 1. The value of R1 should be less than

4.17 kΩ to minimize errors in the output voltage caused by the FB pin bias current. The

output voltage can be set using the following equations [19]:

Figure 3.20 TPS73801 simplified schematic Figure 21

36
𝑅2
𝑉𝑜𝑢𝑡 = 1.21𝑉 (1 + 𝑅1) + 𝐼𝐹𝐵 × 𝑅2 (1)

𝑉𝐹𝐵 = 1.21𝑉 (2)

𝐼𝐹𝐵 = 3𝜇𝐴 (3)

Output rang = 1.21V to 20V

For most type of gas sensors, the input voltage supply is 5V.

𝑅9
Set𝑉𝑜𝑢𝑡 = 5𝑉, according to the equation (1), 𝑉𝑜𝑢𝑡 = 1.21𝑉 (1 + 𝑅10) + 3𝜇𝐴 × 𝑅9

Since the product of 3𝜇𝐴 × 𝑅9 is relatively small,here we make the calculation as

following: 1.21V(1 + R9/R10) ≈ 5V, then we get that R9/R10 ≈ 3.13 Choosing

the value of R9 and R10 based on the above calculation, as well as the availability on

the market, finally, we set that R9 = 3.2K and R10 = 1K

To verify this setting fulfilled the requirement:


𝑅2
𝑉𝑜𝑢𝑡 = 1.21𝑉 (1 + ) + 3𝜇𝐴 × 𝑅2 = 1.21(3.2/1) + 0.003 × 3.2 ≈ 5.09𝑉
𝑅1
The calculation steps are same for the CO2 sensor:
𝑅14
𝑉𝑜𝑢𝑡 = 1.21𝑉 (1 + ) + 3𝜇𝐴 × 𝑅14 ≈ 6𝑉
𝑅13
R14/R13 ≈ 3.96 We set that R14 = 4.7K and R13 = 1.2K
𝑅14
𝑉𝑜𝑢𝑡 = 1.21𝑉 (1 + ) + 3𝜇𝐴 × 𝑅14 = 1.21(4.7/2) + 0.003 × 4.7 ≈ 5.96𝑉
𝑅13

In figure 3.19, the LED 2 and LED 3 are two light indicators, when the EN pin is in a

high state, the output is on and the LED will light up. R11 and R15 are used to limit the

current flow go through the LED. R12 and R16 are pull down resistors. C7 and C12 are

bypass capacitors, the value selected here is the recommended value from the datasheet.

37
An electrolytic capacitor is added in parallel to a ceramic capacitor on the output of the

chip as the decoupling capacitor.

Additionally, J1 and J2 test pins are only used when we test the chip. In the normal

working state, they are not connected. When we need to test or debug the device (e.g.

checking if there is a 6V output), we short connect the J1 or J2 with a jumper wire so

that EN pins will be in the high state, keeping the LED lights on. This reduces the work

needed to control the EN pin state by the microcontroller and the code needed to run it.

3.5.2 Clock circuit

Figure 3.21 Clock circuit Figure 22

The clock circuit will provide the function of time keeping, the coordinating and

synchronizing actions of different parts of the circuit.

The DS1302 was chosen as the time keeping chip, which uses an external 32.768 kHz

crystal. The DS1302 trickle-charge timekeeping chip contains a built in real-time clock

and 31 bytes of static RAM. The real-time clock circuit provides information about

second, minute, hour, day, week, month, and year. It can also adjust for leap years or

38
months with fewer than 31 days.

Even though Arduino has a built-in oscillator, it only operates at a resonant frequency

at 16MHz. In addition, this Arduino built-in timekeeper only keeps track of time since

the Arduino board was last powered, if it lost power, the timer is set back to 0. The

DS1302 chip can drive timings and execution on a more precise scale as the 32.768

KHz clock frequency can get a precise 1 second period by dividing the frequency.

DS1302 also uses a battery powered real time clock when the device is turned off.

Table 3.5 Pin definition of DS1302Table 6


X1, X2 32.768 kHz Crystal Pins
GND Ground
RST Reset
I/O Data input/output
SCLK Serial Clock
VCC1, VCC2 Power Supply Pins

The DS1302 uses synchronous serial communication, only three wires are required to

communicate between the microcontroller and the clock chip: I/O (data line), and

SCLK (serial clock) and RST (Reset).

This chip has a dual supply configuration. It can be operated either by battery or a 5V

power supply. VCC1, VCC2 are both power supply pins. VCC2 is the primary power

supply pin,while Vcc1 is connected to a battery to maintain the time and date in the

absence of primary power.

39
The DS 1302 will operate from the larger of Vcc1 or Vcc2. When Vcc2 is greater than

Vcc1+0.2V, Vcc2 will power the DS1302. When Vcc2 is less than Vcc1, Vcc1 will

power the DS1302. Based on the commonly used battery type on the market and the

recommend value from the datasheet, here the system uses a 3V button battery for the

Vcc1, to ensure the Vcc2 is the larger power supply.

SCLK pin is used to synchronize data movement on the serial interface. The X1 and

X2 pins are bridged with a standard 32.768 kHz Crystal. I/O pin is date input/output

pin, and the Reset pin will pull high during a read or a write.

Because the chips are extremely sensitive to voltage fluctuations, a 0.1μF Bypass

capacitor is placed right next to the chip power pin, to help filter the electrical noise out

of circuits. Typically, 0.1uF is used for most logic circuits. In this way, noise is shunted

through the capacitor, reducing the effect it has on the rest of the circuit. R2, R3, R4 are

all pull up resistors. Their selections were based on general recommendations from the

datasheet and previous experience. 1-10K is the typical value for pull up and pull down

resistors. They are used to ensure that the signal will be on a defined logic level if no

active devices are connected to it. Pull up resistor pulls the terminal to the voltage

supplied and pull down resistor pulls the terminal to the ground. The benefit of

including a pull up or pull down resistor is that it makes the circuitry susceptible to

noise, and the logic level (1 or 0) cannot be changed from a small variation in terms of

voltages on the terminal [20].

40
3.5.3 Analog to digital converter circuit

The Electrochemical gas sensors give out analog output and so they have to be

connected to an AD converter before reading and processing by the microcontroller.

Even though the Arduino 2560 has an on board 10 bit ADC, an external ADC with 16

bits has been selected to digitize the analog signals for better resolution.

Figure 3.22 Analog to digital signal block diagram Figure 23

ADS1115 is a precision, low power, analog-to-digital converter with 16 bits of

resolution. It has a gain amplifier which is able to magnify 16X the original signals. An

onboard programmable gain amplifier that offers input ranges from the supply to as low

as ±256mV, allowing both large and small signals to be measured with high resolution.

Data are transferred via an I2C serial interface. ADS 1115 is able to operate in a wide

range of power supply, from 2.0V~5.5V, so they are compatible with all common 3.3v

and 5v processors.

41
Figure 3.23 AD converter circuit Figure 24

Pull-up resistors are required for I2C interface. R7, R8 are all pull up resistors while

the R5 and R6 are pull down resistors. C6 is a 0.1μF bypass capacitor that placed right

next to the power pin.

Figure 3.24 ADS1115Figure 25

Table 3.6 ADS 1115 pin definition Table 7


ADDR I2C slave address select
ALERT/RDY Digital comparator output or conversion ready
GND Ground
VDD Power supply:2.0V-5.5V
AIN0-AIN3 Analog input
SCL Serial clock input: Clocks data on SDA
SDA Serial data: Transmits and receives data

The ADS1115 communicates with the Arduino microcontroller through an I2C

interface. The master provides a clock signal on the SCL pin and data are transferred

via the SDA pin. The ADS1115 never drives the SCL pin. ADDR pin is used to set the

42
I2C address, the pin can be connected to ground, VDD, SDA or SCL, allowing four

addresses (0x48,0x49,0x4A,0x4B) to be selected. Sensors’ analog pins are connected

with ADS1115’s AIN0, AIN1 and AIN2 pins. ALERT pin is not used in this system, it

is an output pin that can be either tied to ground or be left floating. In general, unused

input pins should be connected to ground; unused output pins can be left floating.

3.6 Software implementation

The basic structure of the Arduino programming language runs in three parts. The first

part includes importing required libraries, declaring variables and functions. The

second part is setup. The setup function runs only once and is used to perform

initialization steps, such as setting pin mode as input or output, initializing serial
43
communication, etc. The third part is loop function, this function is the core of

programming and the codes in the loop will be executed continuously.

Figure 3.25 Flow chart for monitoring air quality parameters Figure 26

Figure 3.25 shows the flowchart of the process that will occur during the operation of

the device. The basic structure of the software running on the Arduino board is shown

as flowing:

1. The first step is initialization and setup. This process includes declaration of any

44
required variables, setting up and initializing all the pins. For example, declaring using

float to define humidity value, setting pinmode, initializing serial communication, and

setting baud rate.

2. The loop function follows next and includes the actions of sensors that to be executed

by the controller continuously. In the loop, data collection proceeds in the following

sequence: rain, temperature and humidity, CO2, O2, PM2.5. This is an infinite loop and

will end when the device shuts down.

3. The measurement results are displayed on the OLED screen and sent to the serial

port.

4. We set a 30 seconds cycle for the microcontroller to take all the measurements. If the

time has not passed the 30 seconds cycle, there will be a delay. During the delay, only

the time is refreshed (at the rate of once per second) on the OLED screen and the serial

port.

In figure 3.25, Timershort and Timerlong are two delay indicators,which are used to

indicate if the 1 second or 30 seconds timeframe have passed respectively.

If Timershort is false, 1 second has not passed. The system has to delay 500ms before

checking the Timershort again. If Timershort is true, then Timerlong will be checked

next. If Timerlong is false, this means 30 seconds timeframe has not passed. The system

will perform three actions: system will print current time to serial port, the OLED

screen will be refreshed to show the new time,and Timershort is reset to false.

45
If Timerlong is true, the system will collect data from the rain、temperature and

humidity、CO2、O2、and PM2.5 sensors. At the same time, measurement results are

sent to the serial port. After finishing all the collection, the system moves forward to

following actions: the OLED screen will refresh to the show the new results, and

Timerlong is set back to False, new time will be print to serial port. Then the system

restarts the loop from the beginning.

Because we need to implement the time interrupt to perform a task at very specifically

timed intervals. We include FlexiTimer2 library to set precisely timed intervals at

500ms. “Timerfun” is a self-defined timer interrupt function that will be called by

Flexitimer2 every 500ms.

This “Timerfun” timer interrupt function, has two increment counters count the number

of 500ms delay. These two increment counters are Timercountshort and

Timercountlong. If Timercountshort = 2, 1 second is up; If Timercountlong= 60, 30

second is up.

46
Table 3.7 Timer function code Table 8
#include <FlexiTimer2.h> // import library
// Define timershort and timerlong indicators
int timercountshort = 0; // short increment counter
int b_timershort = false; //
int timercountlong = 0;// long increment counter
int b_timerlong = false;

#define TIMESHORT 2
#define TIMELONG 60

// timer interrupt function


void timerfun()
{
// increase counter
timercountshort ++; // add one

if(timercountshort == TIMESHORT)// check if counter is equal to 2


{
b_timershort = true;
timercountshort = 0; // reset short counter to 0
}
timercountlong ++; // add one
if(timercountlong == TIMELONG) // check if counter is equal to 60
{
b_timerlong = true;
timercountlong = 0; // reset long counter to 0
}
}

void setup() {
……………
// set 500ms as timer intervals,
FlexiTimer2::set(500, timerfun);
// function start
FlexiTimer2::start();
……………
}
void loop(){
if(b_timershort==true) // if timershort is ture, 1 second is up
{
if(b_timerlong==true) // if timerlong is ture, 30 seconds is up
{

47
Measuring function() ;
print_time(); // serial port print time
draw();// 12864 OLED display
b_timerlong = false;
}
else
{
print_time(); // serial port print time
draw();// 12864 OLED display
}
b_timershort = false; // reset to false
}
}

3.7 System output and end device

These are the two outputs from the system: first, the system has a 2.4" OLED screen as

output; second, the system can output results to a host computer through serial

communication with a USB to UART adaptor.

OLED stands for organic light emitting diode. The OLED technology is active meaning

that it is able to emit light unlike the LCD technology that is dependent on backlight

unit to create light. Light is emitted from the smaller OLED pixels with the help of a

very thin organic film layer [21]. A LCD (liquid-crystal display) does not emit light

directly, instead using a backlight or reflector to produce images in color. Therefore it

uses a lot of energy as the screen requires an external backlight to light up the whole

display underneath.

Because OLEDs emit light, they do not require a backlight .When electrical current is
48
applied, a bright light is emitted. OLED technology only uses electricity per pixel

because each pixel creates its own light. Compared with a LCD screen, an OLED

display has many advantages such as more efficient, thinner, better image quality and

better durability.

Figure 3.26 Screen displayFigure 27

The screen module consists of an OLED panel and a SSD 1309 driver. It has a black

background and displays characters in white. The dimension of the screen is 60.5×37

×2 mm. The resolution is 128×64 pixel.

Figure 3.27 Screen connection diagram Figure 28

Four pins are used in this module: GND, VCC, SCL and SDA. The SCL and SDA pins

of this screen are connected to the Arduino’s SCL and SDA. The Screen is

communicated with microcontroller via an I2C serial interface.

The proposed system can output results to a host computer through a USB to UART
49
adaptor CP2102 (figure3.32). Through serial communication, the measurements can be

received to a host computer. CP2102 is a highly-integrated USB-to-UART data adapter.

Figure 3.28 CP2102 USB to UART adaptor Figure 29

Figure 3.29 is a screenshot of a host computer showing that measurement results are

received by a professional debugging assistant software.

Figure 3.29 DATA received on a host computer Figure 30

Power for the board can come via an AC-DC adapter, or battery. Figure 3.30 shows a

12V power adapter currently used on the device. A Plug-in screw terminal block
50
connector is used for power entry connection. Figure 3.32 is the end device prototype.

The dimension of the prototype is 16×16×8 cm.

Figure 3.30 AC-DC Power adapter Figure 31

Figure 3.31 AA Battery holder (8 ×1.5V) Figure 32

Figure 3.32 Final prototype Figure 33

51
4. Experiment and results

This chapter will discuss experiments of various air parameters. Using these values as

input we can plot an air environmental condition chart of a particular area over time.

4.1 Twelve hours experiments

The device was placed outdoors and monitored temperature and humidity for a 12 hour

span from 9 AM to 9 PM on April 2nd. The results were read from the OLED screen.

Before taking the measurement, the device was given time to adjust to the outdoor

temperature because of the large temperature difference between the room temperature

and outside temperature that day. In the figure 4.1and figure 4.2, the green line

represents the temperature and humidity as measured by a thermometer and hygrometer.

The red line represent the measured value. The graph illustrates the two value are very

close.

52
Figure 4.1Temperature measurement
Figure 34

Figure 4.2 Humidity measurement Figure 35

The CO2 sensor module requires a pre-heat time before taking measurements. Because

of this, the device was powered on for about 2 hours before taking the first reading.

53
After the CO2 sensor was fully warmed up, the testing started. Both the O2 and CO2

measurements were taken simultaneously. The device was placed indoor and the whole

testing period was 12 hours from 10AM to 10PM. As can be seen from the figure 4.3,

the indoor CO2 concentrations were higher between 2PM and 7PM. The data shows

that the concentration reached a peak value of about 600 ppm at 5 PM. There might be

many factors leading to the increased value, such as the testing place being occupied

by more people or a home heating increase. As seen in the figure 4.4, the O2 content in

the air is very stable at about 21 percent.

CO2 Concentration (PPM)


600

500

400

300

200

100
10:00 11:00 12:00 13:00 14:00 15:00 16:00 17:00 18:00 19:00 20:00 21:00 22:00

Figure 4.3 CO2 measurement Figure 36

54
Figure 4.4 O2 measurement Figure 37

In Cleveland, the PM2.5 value is rarely above 100, but there are still some days in which

PM2.5 pollutants reach an unhealthy level. The figure below illustrates the PM2.5

pollutant value measured on March 25, 2017. The highest value was 105μg/m3 that day,

which would have respiratory effects on the sensitive population. During the

experiment, the device was placed indoors with an open window, the monitoring lasted

for 12 hours from 7 AM to 7 PM. The results were read every hour and a graphical chart

was then plotted in figure 4.5.

Compare figure 4.5 to a screenshot taken from Airnow on March 25th at 10:20 am. Both

measurements show a pollutant level that would be unhealthy to sensitive groups in the

greater Cleveland area (Orange colored area). The yellow color shows the suburbs of

Cleveland had a moderate pollutant level. Airnow provides air quality data with colors

to help people know how clean or polluted the air is.

55
PM2.5 (μg/m3) March 25
120
105
100
89
80
65 65 68
60
54 53
40 43

20
12 8 10 9 8
0
7:00 8:00 9:00 10:00 11:00 12:00 13:00 14:00 15:00 16:00 17:00 18:00 19:00

Figure 4.5 PM2.5 measurement Figure 38

Figure 4.6 Screenshot taken from Airnow Figure 39

4.2 PM2.5 sensor experiment

A test was run to illustrate the measurement capabilities of the PM 2.5 sensor. In the

series of images below, the PM 2.5 measurements is shown before, during, and after

smoke was blown into the sensor. Before adding smoke, the PM reading is 9, but once

the candle was lit and the smoke was blown into the device, the reading went to 107

and reached a peak of 287. The readings show the PM 2.5 levels decreasing as the air

56
was ventilated. The images show the reader decreasing to 64, but, ultimately, the PM

2.5 measurements returned to normal levels.

Figure 4.7 PM2.5 sensor experiment Figure 40

57
4.3 Rain sensor experiment

In the figure below, the rain sensor sensed a droplet of water and the weather indicator

changed from “sun” to “rain” on the OLED screen. The rain sensor has been included

for multiple short and long term reasons. Rain is understood to lower air toxicity levels,

so knowing that it is raining in any given moment allows an individual to predict if

there will soon be a decrease in pollutant levels. This would allow people to choose

safer times to go outside. In the long-term, analyzing these measurements can help

researchers understand the cause and effect relationships between all of the

environmental parameters and overall air quality.

Figure 4.8 Rain sensor experiment Figure 41

58
5. Summary and future work

5.1 Summary

This project was a valuable experience in the design, implementation, and testing of

environmental air parameters. The design process also helped raise awareness of the

quality of air that one breathes daily. In general, the design fulfills its intended objective,

which is a user friendly, low cost, portable, multifunctional environmental monitoring

device.

The measurement results were satisfactory in some aspects: PM2.5, O2, temperature

and humidity measurements reflects a relatively accurate value. The CO2 sensor would

work better after calibration; lacking a professional calibration equipment and condition,

the measured value only reflects the approximated trend of gas concentration, it does

not represent the exact gas concentration.

Over all, this portable system can give a real time measurement of 6 air parameters and

record the results for future long term air quality studies. Furthermore, its dual power

supply design and low consumption components make it more affordable for home

based users. The device is also designed in such a manner that it can have extended uses

in the future, by adding an extra sensor such as sensors for the measurement of the SO2

parameter or CO parameter.

59
5.2 Future work

There are some future improvements that could be made to this device, including the

robustness of the system, accuracy of the data produced by the sensors, wireless

network function, and the dimension of device.

1. The system’s robustness can be enhanced by modifying the hardware design as

explained on in the following:

 Adding power supervisory circuits to shut down components in case a power-

failure or a low battery is detected. For example, the ADM 708 supervisory

circuit is one example of a circuit suitable for monitoring the power supply. It

can be connected to the power supply rails of CO2 gas sensors and

continuously monitor the voltage level. If the voltage drops below 6V, the

supervisory circuit generates a delay or resets to power up the sensor.

 Adding one TVS (Transient Voltage Suppressor) to protect electronic devices

against overvoltage.

 Adding ESD protection circuit. The SRV05-4 is recommended for its ability

to protect sensitive components that are connected to data and transmission

lines from overvoltage caused by electrostatic discharge (ESD), electrical fast

transients (EFT), and lightning.

2. The size of the device can be reduced by optimizing the hardware PCB layout

design.

3. The function of the system can be enhanced by adding a wireless network function.
60
For example, the device sit outside and the data gathered by sensors can be sent to

a base station using wireless communication technology, so that anyone at base

station can read the measurements.

4. The system can be modified by building a solar powered module to achieve greater

levels of energy efficiency and reduce power consumption. Solar energy is the free

source to recharge a battery. As illustrated in figure 5.1, we can use a solar panel

to power the board and to charge a rechargeable battery (e.g. nickel metal hydride

(NiMH) or Li Ion battery).

Figure 5.1 Solar module connection diagram Figure 42

61
Appendix

A. Project schematic

Figure A.1 System schematic Figure 43

62
B. Print circuit board

Figure B.1 Print circuit board Layout Figure 44

Figure B.2 Print circuit boardFigure 45

63
Figure B.3 Completely assembled circuit board without attached external components.Figure
46

C. Project budget

The cost of this project was calculated based on materials and components spent on

design and fabrication of the prototype.

Table C.1 Hardware cost Table 9


Hardware Component Price
Arduino MEGA 2560 $18.80
AM2302 DHT sensor $7.65
MG811 CO2 sensor $49.95
PMS1003 PM2.5 Sensor $41.89
KE-50 O2 sensor $88.99
FC-37 Rain sensor $5.99
SSD1309 OLED screen $9.99
CP2101 USB-to-UART adapter $6.99
Printed circuit board $45.00
Sum $268.26

64
Bibliography

[1] T. H. R. I. H. M. A. Ashish M. Husain, "Air Quality Monitoring: The Use of Arduino and

Android," Journal of Modern Science and Technology, vol. Vol 4, pp. Page 86-96, Sep.2016.

[2] "Air quality guide for particle pollution," U.S. EPA, 26 January 2016. [Online]. Available:

https://www.airnow.gov/index.cfm?action=pubs.aqguidepart.

[3] "Mission China website," U.S. Department of State, [Online]. Available:

http://www.stateair.net/web/post/1/1.html.

[4] A. P. J. C. P. &. I. B. A. Asmi, "A Study of Indoor Air Quality of Public Toilet in University's

Building," Humanities, Science and Engineering(CHUSER), pp. 403-408, Dec 2012.

[5] S. Taranovich, "Let’s clear the air: analog and power management of environmental sensor

networks," EDN Network, 2016.

[6] A. S. Berger, Embedded Systems Design: An Introduction to Processes, Tools and Techniques,

CMP Books, 2001.

[7] M. Rouse, "Techtarget website," Techtarget, [Online]. Available:

http://internetofthingsagenda.techtarget.com/definition/embedded-system.

[8] "Arduino Introduction website," Arduino, [Online]. Available:

https://www.arduino.cc/en/guide/introduction.

[9] S. S. B. B. B. Shrichippa, "Smart Home Monitoring System using ECSN," International

Journal of Innovative Research in Computer and Communication Engineering, vol. 4, no. 6,

65
pp. 10904-10909, 2016.

[10] K. V. Koziy, "WIRELESS HEALTH MONITOR DESIGN," ProQuest LLC, Fargo, 2012.

[11] "CO2METER Website," CO2 Meter, Inc., 2012. [Online]. Available:

https://www.co2meter.com/blogs/news/6010192-how-does-an-ndir-co2-sensor-work.

[12] A. Liberti, "Modern methods for air pollution monitoring," Pure and Applied Chemistry, vol.

44, no. No. 3, pp. 631-642, 1970.

[13] "Mantech electronics website," Mantech Electronics (Pty) Ltd., [Online]. Available:

http://www.mantech.co.za/datasheets/products/A000047.pdf.

[14] "Plantower website," Beijing Plantower Co., Ltd, [Online]. Available:

http://www.plantower.com/en/content/?106.html.

[15] A. F. I. T. M. D. O.-R. Nidal Hilal, in Membrane Characterization, Amsterdam, Elsevier B.V.,

p. 389.

[16] X. Li, "Miniaturized particulate matter sensor for portable air quality monitoring devices," in

Proc. IEEE SENSORS, Valencia,, 2014.

[17] "Figaro website," Figaro Engineering Inc., [Online]. Available:

http://www.figaro.co.jp/en/product/docs/KE_Product%20Infomation_rev02.pdf.

[18] "Sandbox Electronics," Sandbox Electronics , [Online]. Available:

http://sandboxelectronics.com/files/SEN-000007/MG811.pdf.

[19] "Texas Instruments," Texas Instruments, July 2015. [Online]. Available:

http://www.ti.com/lit/ds/symlink/tps73801.pdf.

[20] R. Gajjar, in Raspberry Pi Sensors, Brimingham, Packt publishing, 2015, p. 34.

66
[21] Z. Š. Srećko Kunić, "OLED Technology and Displays," in 54th International Symposium

ELMAR, Zagreb, 2012.

[22] "MakerPot," makerpot, 2 November 2015. [Online]. Available:

http://makerpot.com/articles/Pull-Up-and-Pul-Down-resistor/.

67

You might also like