Post on 09-Jun-2020
transcript
1
THE UNIVERSITY OF NEW SOUTH WALES
SCHOOL OF ELECTRICAL ENGINEERING AND TELECOMMUNICATIONS
“Haze Watch: Design of a wireless sensor board for measuring air
pollution”
James Carrapetta
Bachelor of Engineering
October 2010
Supervisor: Dr Vijay Sivaraman
Thesis title: Haze Watch: Design of a wireless sensor board for measuring air pollution Topic number: VR24 Student Name: James Carrapetta Student ID: z3220273 A. Problem statement Air pollution is responsible for 2.3% of Australian deaths each year and costs the government of NSW an estimated $4.7billion per year in health costs. With ever increasing levels of exposure to toxic air pollutants, significant health risks and issues are arising. Current air monitoring systems is Sydney are too few and far apart to be used in any reliable or accurate sense to determine the air pollution for a location between these fixed sites. A new air pollution monitoring system is needed that collects far more air pollution samples on a more regular basis and over a larger geographical area. B. Objective The objective of this thesis is to critically analyse the current air monitoring system in Sydney and demonstrate its ineffectiveness to model air pollution accurately. A design of a mobile sensor that can be used to measure air pollution in real time will be proposed and tested thoroughly. The benefits of an improved air monitoring system will also be realised. C. My solution A proposed design for a wireless sensor board that attaches to the external of motor vehicles and is able to measure carbon monoxide, nitrogen dioxide and ozone. This device will connect to a Smart Phone via a Bluetooth connect to transfer pollution measurements. The Smart Phone will record both the GPS co-ordinates and the time of the sample and upload it to a database on a server in real time. The wireless sensor board will be able to record measurements while the user drives collecting data over a large geographical region. D. Contributions (at most one per line, most important first) Designed and built a wireless sensor board that is able to take air pollution measurements and upload them to a central server in real time via a Smart Phone. Demonstrated that the current air monitoring system in Sydney is inaccurate and unreliable to use to model air pollution. Demonstrated that air pollution varies significantly in different parts of Sydney and that a more dense sensing network is required to accurately model air pollution Improved the accuracy of air pollution applications such as the iPhone application for personal exposure estimations. Improved the quality of information required to produce more accurate visualisation maps of air pollution in Sydney. E. Suggestions for future work - Improving the accuracy of gas sensors and improving calibration techniques - Accounting for other variables towards air pollution including temperature & speed - Creating a complete stand alone wireless sensor board independent of Smart Phones While I may have benefited from discussion with other people, I certify that this thesis is entirely my own work, except where appropriately documented acknowledgements are included. Signature: Date: 20 /10 /2010
(i)
6 Problem Statement 6 Objective
Theory (up to 5 most relevant ideas)
7 Air Pollution 8 Major Pollutants 9 Benefits from Air Monitoring 11 Existing Designs
Method of solution (up to 5 most relevant points)
14 - 18 Gas Sensors 19 - 22 Bluetooth Module + Message Structure
23 Smart Phone Application 24 - 29 Power Management 30 - 34 Printed Circuit Board (PCB) Design
Contributions (most important first)
12-33
Designed and built a wireless sensor board that is able to take air pollution measurements and upload them to a central server in real time via a Smart Phone.
38 – 40 44 - 46
Demonstrated that the current air monitoring system in Sydney is inaccurate and unreliable to use to model air pollution.
38 – 40 44 - 46
Demonstrated that air pollution varies significantly in different parts of Sydney and that a more dense sensing network is required to accurately model air pollution
41 – 45
Improved the accuracy of air pollution applications such as the iPhone application for personal exposure estimations.
41 – 45
Improved the quality of information required to produce more accurate visualisation maps of air pollution in Sydney.
My work
12,30 System block diagrams/algorithms/equations solved 35,
41 - 42 Description of procedure (e.g. for experiments)
Results
35 - 45 Succinct presentation of results 39 - 40 44 - 47
Analysis
46 - 47 Significance of results Conclusion
50 Statement of whether the outcomes met the objectives 48 - 49 Suggestions for future research
Literature: (up to 5 most important references) 7 [1] New South Wales Government. (2010, Jan.) 7,8 [2] World Health Organisation. (2006) 7 [4] State Government of Victoria. (2008, Nov.) 9,43,45,46 [5] A. Chow. (2010, Oct.) 9, 20 – 23, [6] N. Youdale . (2010, Oct.)
(ii)
2
Abstract
Fresh breathing air has always been a basic requirement for human beings, however with current
global trends we are beginning to lose this most basic privilege. Air pollution is a growing issue and a
significant risk to the state of our environment, our livelihood and future generations. Billions of
dollars are spent every year by all levels of government in health bills and other costs related to air
pollution. Motor vehicles are the largest contributors to air pollution in most urban environments and
there are no signs of this trend changing in the near future. Medical studies are continually showing
the importance of having clean air to breathe. Our environment is becoming polluted with toxic gases
such as ozone, carbon monoxide, nitrogen dioxide, sulphur dioxide and particulate matter. All these
toxic gases have the potential to cause mortality and significantly reduce the life expectancy of any
society. Current air quality monitoring systems are either too expensive or too few and far apart to
use in any reliable sense. A new style of air pollution monitoring system is proposed which brings the
monitoring units to motor vehicles, the main source of the toxic pollutants. With this new system in
action we can begin to take the first steps to an improved and healthier world.
This report will discuss the motivations behind the need for a more dense air pollution monitoring
system and outline the major air pollutants that endanger the environment and the health of humans.
Current air monitoring systems and devices will be critically analysed to further demonstrate the need
for mobile air pollution sensors. The detailed design of the wireless sensor board I built will be
explained and experimental results will be discussed. Results of experiments using the wireless sensor
board will further highlight the fundamental problems associated with current air monitoring systems
in Sydney. Furthermore, it will be realised that using the wireless sensor board to collect air pollution
samples will significantly improve applications such as personal exposure estimations and
visualisation maps. It is through these applications that individuals will be able to closely monitor their
personal exposure to air pollution and avoid areas of high concentration which are damaging to their
health.
3
Acknowledgements
I would like to acknowledge and personally thank Dr. Vijay Sivaraman, my thesis supervisor. He has
provided strong guidance, motivation and inspiration for my undergraduate thesis project. Dr.
Sivaraman has provided me with continual feedback that has allowed me to develop both my
technical engineering skills but also my time management abilities. I would also like to thank the other
team members who are part of the Haze Watch project: Nikolaus Youdale and Amanda Chow. They
have provided assistance and support throughout the overall project. Lastly I would also like to
acknowledge and thank the School of Electrical Engineering at the University of New South Wales for
providing me the facilities and funds required to complete this thesis project.
4
Contents Abstract .......................................................................................................................................................... 2
Acknowledgements ........................................................................................................................................ 3
1. Introduction ............................................................................................................................................ 6
2. Background Information ........................................................................................................................ 7
2.1 Air Pollution .......................................................................................................................................... 7
2.2 Major Pollutants .................................................................................................................................... 8
2.3 Benefits from Air Pollution Monitoring ................................................................................................ 9
2.4 Project Scope ...................................................................................................................................... 10
2.5 Existing Designs ................................................................................................................................... 11
3. Design Overview ................................................................................................................................... 12
3.1 System Design ..................................................................................................................................... 12
3.2 Microcontroller ................................................................................................................................... 12
3.3 Voltage Regulator ............................................................................................................................... 13
3.4 Triple LED ............................................................................................................................................ 13
3.5 Sensors ................................................................................................................................................ 14
3.6 Calibration of Gas Sensors .................................................................................................................. 17
3.7 Bluetooth Module ............................................................................................................................... 19
3.8 Message Structure .............................................................................................................................. 20
3.9 Smart Phone Application .................................................................................................................... 23
4. Power Management ............................................................................................................................. 24
4.1 Power Requirements .......................................................................................................................... 24
4.2 Batteries .............................................................................................................................................. 25
4.3 Battery Performance ........................................................................................................................... 27
4.4 Low Battery Detector .......................................................................................................................... 29
5. Printed Circuit Board (PCB) Design ...................................................................................................... 30
5.1 Electrical Schematic ............................................................................................................................ 30
5.2 Printed Circuit Board Design and Regulations .................................................................................... 30
5.3 External Casing and Mounting ............................................................................................................ 33
5.4 Bill of Materials ................................................................................................................................... 34
6. Experimentation and Results ............................................................................................................... 35
6.1 Experiment 1 ....................................................................................................................................... 35
6.2 Experiment 2 ....................................................................................................................................... 41
7. Discussion ............................................................................................................................................. 46
8. Future Developments ........................................................................................................................... 48
9. Conclusions ........................................................................................................................................... 50
10. Bibliography .......................................................................................................................................... 51
5
11. APPENDICES .......................................................................................................................................... 53
11.1 Appendix I ......................................................................................................................................... 54
11.2 Appendix 2 ........................................................................................................................................ 56
11.3 Appendix 3 ........................................................................................................................................ 57
6
1. Introduction
In a world where environmental issues are becoming more significant than ever before, the issue of
air pollution is constantly debated. Air pollution can severely impact the environment and the health
of humans if risks and dangers are not appropriately dealt with. The air monitoring system currently
being used in Sydney involves the use of 14 fixed air monitoring sites around Sydney. There are too
few of these sites and they are far too apart to be used with any accuracy or reliability for modelling
air pollution. As a result, a more accurate mobile sensor that can improve the density of air pollution
samples is needed.
This report will introduce the Haze Watch project that has arisen out of the need for a better air
monitoring system in Sydney. The Haze Watch project consists of three team members: Nikolaus
Youdale, James Carrapetta and Amanda Chow and is an initiative by the School of Electrical
Engineering at the University of New South Wales. The Haze Watch project aims to implement a
completely new air pollution monitoring system including a network of mobile air pollution sensors, a
database for all pollution samples, visualisation maps to easily display and understand air pollution
measurements and lastly an application for an iPhone to provide individuals an estimation of their
personal exposure to air pollution. Through the Haze Watch project it is believed that individuals will
be able to increase their own awareness about the risks and dangers of air pollution. With increased
awareness about air pollution in the public, improvements in the health of societies and
environments is expected.
The design of the wireless sensor board will be broken down into several blocks for detailed
explanation. This report will look at the various gas sensing technologies that are currently available
and through comparison of each type justify the chosen type of sensors used on the wireless sensor
board. Other aspects of the sensor board including the central processing unit and wireless
connectivity will also be thoroughly discussed. Techniques for calibrating each individual gas sensor
will also be explained.
The aims and methods of the several experiments that were conducted using the wireless sensor
board will be outlined and the results analysed in detail. Through these experiments the need for a
more detailed air monitoring system will be clearly shown. Furthermore, the benefits of using the
wireless sensor board for applications such as the personal pollution exposure iPhone application and
the visualisation maps will be realised. Lastly, the key areas that require further development and
improvement in order to ensure the Haze Watch project continues to grow will be discussed.
7
2. Background Information
2.1 Air Pollution Air pollution is responsible for 2.3% of Australian deaths each year and costs the government of NSW
an estimated $4.7billion per year in health costs [1]. In fact, air pollution is the cause of more
premature deaths in New South Wales each year than car accidents [1]. This is not only a serious issue
in Australia, but also worldwide. Air pollution is seen as a major environmental risk and has been
estimated to cause up to 2 million premature deaths worldwide per year [2]. Fresh breathing air has
always been a basic requirement for human beings. With ever increasing levels of exposure to toxic
air pollutants, significant health risks and issues are arising. Health affects include heart disease,
respiratory infections, lung cancer and poor blood circulation; all which can lead to mortality.
Figure 1 ‐ Sources of Air Pollution in the Sydney Region [3]
As can be seen in Figure 1, vehicle emissions are the largest contribution to air pollution in Sydney and
contribute to 75 per cent of Melbourne’s air pollution [4]. This indicates that areas surrounding busy
transport corridors such as roads and freeways will have the highest levels of air pollutant
concentrations. With Australia’s cities continuing to grow there are increasing trends for long distant
commutes from outer suburbs into city centres, increasing travel times. This leads to significant
increases in exposure to high levels of air pollutants while commuting to and from work on a daily
basis.
Despite the fact that many people are aware they are being exposed to such high levels of air
pollution, people often neglect to change any of their routines in an attempt to reduce such exposure
paths. It is a popular belief that personal exposure to poor air quality is uncontrollable by an individual
and thus individuals rely heavily on government bodies to act on such health risks. However, it is
thought that if an individual was able to monitor their own personal exposures they may begin to
alter their routines.
Commercial2%
Domestic‐Commercial
17%
Industrial7%
Off‐Road Mobile5%
On‐Road Mobile69%
Commercial
Domestic‐Commercial
Industrial
Off‐Road Mobile
On‐Road Mobile
8
2.2 Major Pollutants In New South Wales the Department of Environment,
Climate Change and Water (DECCW) has the
responsibility of monitoring the air quality of NSW. They
currently have 14 fixed sites around Sydney as can be
seen in Figure 2, which measure and update on an
hourly basis. The DECCW uses a system which is
referred to as the Regional Air Quality Index (RAQI)
system, monitoring five main air pollutants:
Ozone (O3)
Carbon Monoxide (CO)
Sulphur Dioxide (SO2)
Nitrogen Dioxide (NO2)
Particulate Matter (PM)
Ozone has been linked with several breathing problems such as shortness of breath, coughing, chest
pain and wheezing. It can also trigger asthma in many people and is the product of the interaction
between emissions from motor cars and industry, with sunlight.
Carbon monoxide is a very poisonous but colourless and odourless gas. It has been linked as the cause
of many health problems such as cardiovascular and respiratory diseases. Carbon monoxide is
produced when the carbon in fuels is not completely burnt but instead released into the environment.
The major source of carbon monoxide is the exhaust of motor vehicles including cars, buses and
trucks.
Sulphur dioxide is a colourless reactive gas that can have significant health effects on humans such as
the narrowing of airways, chest pains, shortness of breath and wheezing. At high concentrations it can
also cause irritation of the eyes and long term exposures can do significant damage to vital organs
including the lungs and heart. Sulphur dioxide is produced whenever minerals containing sulphur and
fossil fuels are burnt, for example coal.
Nitrogen dioxide is a toxic gas which causes significant inflammation of the airways and has long term
health effects such as reduced lung function and growth. Nitrogen dioxide is produced as a bi‐product
of the combustion of fuels, from either motor vehicles or industry applications such as power stations.
Particulate matter (PM) is the most dangerous air pollutant and causes more health risks then any
other air pollutant. PM refers to tiny particles of solid or liquid suspended in gas, which are small
enough to pass deep into the lungs and even into the blood stream. PM can largely change the
mortality and life expectancy rates of a city [2]. PM has the potential to cause severe health problems
such as heart disease, lung dysfunction and even lung cancer. Burning fossil fuels in vehicles is a major
contributor to particulate matter.
Figure 2 ‐ Location of Monitoring Sites in
Sydney [3]
9
2.3 Benefits from Air Pollution Monitoring As previously mentioned, in Sydney there are currently only 14 monitoring sites, which are spread
over a very large area. When there is a need to determine pollution levels for any region in between
these fixed locations, either very complex algorithms or inaccurate measures are used. This can lead
to applied uses of unreliable data, for example in medical studies, personal exposure calculations and
future development plans. To overcome such issues, further research could be undertaken into more
accurate modelling systems where the environmental topology, environmental conditions and
characteristics of the pollutant itself determine an approximation. Another approach would be to
increase the number of sensors. With an increase in the number of sensors, there is an increase in
spatial density of pollution measurements, which improves both accuracy and reliability of air quality
data.
With improvement of air pollution data, new applications such as a personal
air pollution exposure calculator could be used. Such an application would
allow an individual with a global positioning system to track their daily
commute and determine an estimation of their air pollution exposure. This
application has been developed for Smart Phones as seen in Figure 3, which
allows a member of the public to take more control over their personal
exposures and give them the opportunity to reduce such large exposures.
Another application could be real time air pollution monitoring maps, giving
a member of the public a quick, easy and informative view of the current air
pollution in their environment. Such an application could be accessed over
the internet with a simple web browser as seen in Figure 4.
Figure 3 ‐ Smart Phone Application [6]
Figure 4 ‐ Web Application for Real Time Monitoring of Air Pollution [5]
10
2.4 Project Scope Increased air pollution data has many advantages, including many medical benefits. The main
motivation behind any monitoring system is to improve upon its imperfections. Through the Haze
Watch project, we aim to monitor air pollution in order to improve the state of our environment and
the health of humans. Hence it is envisaged that an improvement in the current monitoring system
will allow for further improvement in human health and also sustainability of our environment.
A proposed solution is the introduction of a new style of measuring air pollution, where the sensors
themselves will be completely mobile and attached to motor vehicles, the source of the pollution. As
people use their cars to commute from place to place, they will be able to collect measurements of air
pollution while they drive. As seen in Figure 5, a wireless sensor board will be attached to the exterior
of a motor vehicle and through a Bluetooth connection data will be transmitted to a Smart Phone
within the car. From here, the Smart Phone can process the data, adding its GPS co‐ordinates and
time stamping the data. The Smart Phone will then upload this data in a real time process via the 3G
network to a central server on the internet. Once stored in a central place, various users and
applications will be allowed to access all the data.
The focus of this thesis was the development of the wireless sensor board as seen in Figure 6. The
aims of this thesis were to design and produce a piece of hardware which was able to accurately
measure various air pollutants and communicate these readings to the Smart Phone. The wireless
sensor board had to be completely mobile and as the project scope defines, must be able to be
attached to the exterior of a motor vehicle. Furthermore, this thesis proposed to develop a low cost
unit able to be reproduced in large numbers for distribution. Throughout this thesis project I worked
very closely with Nikolous Youdale to write an application for the Android phone operating system.
This application provided the interface between the Smart Phone and the wireless sensor board. I also
worked closely with Amanda Chow in her work of modelling the air pollution data on maps for
visualisation.
Figure 6 ‐ Haze Watch Project Scope
Figure 5 – Haze Watch
Wireless Sensor Board
11
2.5 Existing Designs There currently exist many devices on the market which measure air pollution,
such as the product by Honeywell as seen in Figure 7. This device allows
concurrent measurement of up to 5 gases, however does not record the GPS
co‐ordinates of where the measurements were sampled from. Furthermore
this product does not allow real time uploading of data and only once a trip is
completed can the data be uploaded.
There are also several research projects underway worldwide
attempting to construct a similar device to the wireless sensor board.
The MESSAGE project in the United Kingdom is developing small portable devices capable of
measuring concentrations for carbon monoxide, ozone and nitrogen dioxide whilst carried around by
humans. These devices are linked to their mobile phones via Bluetooth allowing real time data
uploads. This project is currently only in its development stages and the portable units that are
attached to the roof tops of cars are bulky and expensive.
Intel is also currently developing a product as part of the
Common Sense project. They have developed a prototype, as
seen in Figure 8, which is a portable handheld device capable of
measuring various air pollutants. This data can be uploaded in
real time and viewed on Google Maps. Furthermore, the
Common Sense project is currently running trials with these
devices attached to the rooftops of street cleaners in the city of
San Francisco.
In New York, Chillrud are currently running trials of their prototype the iSniff, which is a small and
portable air pollution sensor. Their main development has been to shrink the size of existing personal
pollution sensors from backpack size to small pocket size units. The main aims of this project have
been to create a device useable by children who have certain medical conditions and allergies, where
the device will be able to alert them of any such dangers. However, these units do not upload any
information to a central server, and are instead used for profiling personal exposure to air pollutants.
The MAQUMON project has similar aims to the Haze Watch
project with the development of a small wireless sensor
board for mobile air pollution monitoring. This project is only
in its early development stages and their prototype can be
seen in Figure 9. This prototype attempts to have an onboard
GPS and GSM unit in which it will be able to do all the data
processing and uploading of data independent of a Smart
Phone or PC.
All these research projects are in the early development
stages. There are no completely working designs available to
be purchased.
Figure 7 ‐ GasAlertMicro 5 [14]
Figure 8 ‐ Common Sense Project [15]
Figure 9 ‐ MAQUMON Prototype [16]
12
3. Design Overview
3.1 System Design The design of the wireless sensor board is
made up of 4 key main blocks as can be
seen in Figure 10. Inspired by the
MAQUMON design (Appendix 1), the
wireless sensor board is designed around
the microcontroller with all other blocks
connecting through it. The gas sensors
interface with the microcontroller through
an analogue to digital converter, where
voltage levels will be converted to a digital
value. It is the responsibility of the
microcontroller to concurrently measure
all connected gas sensors and process all
readings. Once the microcontroller has sampled
and recorded readings from all sensors, it then
assembles packets of data. These packets are
then sent to the Smart Phone for further processing via the Bluetooth interface. The wireless sensor
board uses replaceable batteries for its power source, which are rechargeable.
3.2 Microcontroller The microcontroller (MCU) is at the centre of the wireless sensor board design. The MCU interfaces
with every other component on the sensor board and contains all the logic required for operation.
The MCU has to read voltage levels from the various gas sensors and convert this into a digital value.
The MCU will then process these readings further and assemble a message with other critical
information about the unit and the specific gas sensors. Once all the information that is required to
assemble a message has been gathered the MCU will use a serial connection to send the data to the
Bluetooth module, ready to transmit to the Smart Phone. The MCU will also be constantly updating
the status LED’s that are on the sensor board, providing the user with useful information such as
power status, sending status and battery status.
The wireless sensor board uses a microcontroller similar to the one shown in Figure 11 by Microchip,
specifications (Appendix 2). The PIC16f690 is a 20 pin microcontroller which has 12 available channels
with analogue to digital converters for the multiple gas sensors. The PIC16f690 also has a Universal
Serial Asynchronous Receiver and Transmitter (USART) which allows for
simple serial communication with the Bluetooth module. Also, the
PIC16f690 has a 4MHz operating speed so that all sampling and
transmitting can be completed in a reasonable amount of time. There are
many microcontrollers that could have been used for this design,
however this particular MCU has been chosen as it is simple to program
and I have had previous experience using it.
Figure 10 ‐ Block Diagram of Wireless Sensor Board
Figure 11 ‐ PIC 16f690 [17]
13
The code for the microcontroller was written in C and the overall program was constructed from two
files (Appendix 3). The code was broken into two separate files: one for the declaration of all
constants and another file for all of the logic required to be executed. The constants required to be
declared are specific to each sensor board and vary between each board. These constants include the
unique board identification number, sensor coefficients, reference voltages and type of sensors in
use. The execution code is the same for each sensor board and executes logic according to
specifications set out in the declaration file. Breaking the overall program into two sections like this
makes programming various units easier and more efficient. Each sensor board has its own unique
declaration file which is modified accordingly and then simply compiled together with the execution
code. When changes need to be made to certain constants they can be changed in one location in the
declaration file and not in the various locations throughout the execution code. The code has been
designed to easily allow future expansion to more units without having to restructure the whole
program.
3.3 Voltage Regulator The wireless sensor board uses a 3.3V voltage regulator to provide voltage
protection to all components. Figure 12 shows the voltage regulator which
takes any voltage level greater than 3.3V and limits the output to a
constant 3.3V supply voltage. Limiting the power supply to only 3.3V is
important as several components on the sensor board have a maximum
voltage supply of 3.3V. Components such as the gas sensors and
Bluetooth module are easily damaged when their power supply voltage
exceeds their maximum operating voltage. Also a voltage regulator was
required to ensure that the same supply voltage was provided regardless
of the different type of batteries that may be used with the sensor board.
Different types of batteries, for example AA (NiMH) rechargeable (1.2 volts) and AA alkaline (1.5 volts)
batteries provide different supply voltages.
3.4 Triple LED Figure 13 shows the triple LED that was incorporated into the design of the
wireless sensor board to give the user an indication of the status of the device.
The triple LED features a green, blue and red light which can be used
individually or as a combination. The sensor board utilises the triple LED to
indicate one of three possible states that the device can be in. The LED will
flash the green LED periodically to indicate that the unit has power and is
operating. A constant blue LED will be activated when the sensor board is
transmitting data via its Bluetooth interface. A solid red LED will be used to
indicate that the batteries are running low and only have 4 hours of operation
left. This solid red LED will remain on, deactivating the other status LED’s until
the batteries have been recharged.
Figure 12 ‐ 3.3V Voltage [18]
Figure 13 ‐ Triple LED for Status Indication [18]
14
3.5 Sensors There are multiple types of sensing technologies available that could have been employed with the
wireless sensor board. One type of sensor is a catalytic bead gas sensor, where pollutant gas enters a
heating chamber. The gas is burnt and the produced heat is proportional to the level of pollution.
However such sensors do not exist for toxic gas monitoring. Another type of sensor is an infrared (IR)
gas sensor, where pollutant gas entering the IR chamber absorbs IR energy proportional to the level
of concentration, which the collector can detect. These types of sensors have a significant advantage
over many other sensors because they require very little calibration. However dirt and dust can enter
the IR chamber and cover the detector, compromising measurements. Furthermore, current IR
sensors are expensive and only available for specific gases.
Currently the most popular method used for measuring toxic gases such as
carbon monoxide and nitrogen dioxide is electrochemical gas sensors.
Pollutant gas passes through the inner membrane of the gas chamber where
it is oxidised, producing an electric current proportional to the level of
concentration. Sensors similar to the one seen in Figure 14 are typically very
accurate however are expensive (~$50 each) compared to other sensing
technologies.
There are also metal oxide semi‐conducting gas sensors which are designed for
toxic gas monitoring. A semiconductor material is heated and when a gaseous
pollutant is introduced into the chamber, electrons are freed from the
semiconductor. This decreases its effective resistance proportional to the level
of pollution. Sensors such as those shown in Figure 15 are cheaper (~$25 each)
compared to other sensing technology and are very small and compact.
However these sensors are not as accurate as electrochemical gas sensors.
Figure 14 ‐ Electrochemical Sensor [19]
Figure 15 ‐ Metal Oxide Semiconductor
Gas Sensor [19]
15
Table 1 ‐ Comparison of Available Gas Sensors
Gas Sensors
Gas Model Manufacturer Description Price Supply
VoltageSensitivity Physical Dimensions
Carbon
Monoxide
(CO)
MQ‐7 HANWEI
ELECTRONICS
Metal Oxide
Sensor $4.95 5V
20 to 2000
ppm
21.4 mm (D) x 24 mm
(H)
MiCS‐5521 E2V Metal Oxide
Sensor $24.65 2.35V
1 to 1000
ppm 9.5 mm (D) x 3.9 mm (H)
ec4‐500‐co E2V Electrochemical $46.36 5V 0 – 500 ppm 20 mm (D) x 16.6 mm
(H)
TGS2442 Figaro Metal Oxide
Sensor $36.00 5V
30 – 1000
ppm
9.2 mm (D) x 12.7 mm
(H)
2112B3000A City Tech ElectrochemicalNot
Available- 0 – 500 ppm
20 mm (D) x 16.6 mm
(H)
Nitrogen
Dioxide
(NO2)
MiCS 2710 E2V Metal Oxide
Sensor $24.65 1.92V
5 to 5000
ppm
9.5mm Diameter
14mm Height with pins
3NDH City Tech ElectrochemicalNot
Available ‐ 0 – 20 ppm
41.2 mm (D) x 17.8 mm
(H)
TDS031 Dynament Metal Oxide
Sensor
Not
Available3.0V
5 to 5000
ppm
20mm Diameter
20mm Height with pins
Ozone
(O3)
MiCS‐2610 E2V Metal Oxide
Sensor $25.35 2.35V 0 to 1 ppm 9.5 mm (D) x 3.9 mm (H)
3OZ CiTiceL Ozone CiTiceL ElectrochemicalNot
Available ‐ 0 to 2 ppm
21.4 mm (D) x 24 mm
(H)
MQ‐131 HANWEI
ELECTRONICS
Metal Oxide
Sensor $12.90 6.0V 0 to 2 ppm
21.4 mm (D) x 24 mm
(H)
*All prices correct as of 27th September 2010
A comparison between available gas sensors is shown in Table 1, which compares the type, price,
required voltage, sensitivity and physical dimensions of the various gas sensors. The price varies
considerably between different types of sensors and the manufacturer, with some sensors costing
between $5 and $50. As is shown in Table 1 the metal oxide gas sensors are considerably smaller than
the electrochemical sensors. Also a key difference between the electrochemical and metal oxide
sensors is the required supply voltage. The electrochemical sensors require a larger supply voltage in
the range of 5V, whereas some of the metal oxide sensors only require 2‐3V to operate. This is an
important characteristic for the gas sensors as the wireless sensor board will be powered by batteries
which will have a limited supply voltage.
16
Metal oxide semiconductor gas sensors were chosen for the wireless sensor board for several
reasons. Two key requirements for the wireless sensor board were the overall price and size of each
device. Metal oxide sensors are both smaller and cheaper than currently available electrochemical gas
sensors. As each sensor board will have multiple gas sensors it was also desired to use the same
manufacturer of gas sensors for the different gases. Using gas sensors from the same manufacture
simplifies the design of the printed circuit, as the same device footprint can be used and similar
external circuitry is required. As can be seen from Table 1, E2V manufactures O3, CO and NO2 gas
sensors, which are of the same size and have similar operating requirements.
As can be seen in Figure 16, these metal oxide sensors require a rather simple external circuit in order
to measure the concentration of the gas. The voltage Vs is measured by the MCU and from a graph
similar to Figure 17, a concentration level can be determined in standard units of parts per billion
(ppb).
Figure 16 ‐ External Circuit [20] Figure 17 ‐ Resistance Vs Concentration
Relationship [20]
17
3.6 Calibration of Gas Sensors Each gas sensor is manufactured slightly differently from others, which means that every gas sensor
must be calibrated individually. This process involves correlating the voltage output of a particular
sensor for a given air pollution reading. To correlate the sensors on the wireless sensor board a
commercially available gas monitor was used, the GasAlertMicro 5. This device is capable of
measuring both carbon monoxide and nitrogen dioxide. Both the wireless sensor board and the
GasAlertMicro 5 were exposed to a varying concentration of gas pollutants and samples were
recorded every second. Figure 18 shows the output of the two devices. The output of the sensor on
the wireless sensor board is a measured voltage while the GasAlertMicro 5 device gives a pollution
reading in parts per million (ppm).
As is clearly illustrated in Figure 18, the voltage at the
output of the sensor varies according to the amount of air
pollution (obtained from the GasAlertMicro 5 device). The
next step involves finding the correlation between these
two graphs, allowing us to assign a voltage to a specific
pollution reading. Figure 19 is a plot of the correlation
between the output voltage of the sensor on the wireless
sensor board and the pollution reading from the
GasAlertMicro 5 device. A quadratic line of best fit was
fitted to this set of data, which produced an equation in
the form of:
Figure 18 ‐ Measured carbon monoxide samples for calibration
Figure 19 ‐ Correlation between voltage and air pollution
18
This equation was then applied to the original voltage readings from the wireless sensor board to give
estimated air pollution measurements. Figure 20 shows the comparison between the calculated air
pollution from the wireless sensor board and the measured air pollution from the GasAlertMicro 5
device. As can be seen, both graphs are very similar and highly correlated.
Once each sensor has been calibrated, a unique mathematical equation will be associated with that
sensor. Every sensor will have a similar equation in the form of a quadratic, however the coefficient of
each term will vary from sensor to sensor. The microcontroller on each wireless sensor board will
have the unique equations corresponding to its particular sensors programmed.
Currently only the carbon monoxide and nitrogen dioxide sensors have been able to be calibrated on
the wireless sensor board. The commercial air monitoring device which has been used to calibrate the
gas sensors on the wireless sensor board is only able to measure carbon monoxide and nitrogen
dioxide. Unfortunately this means that the ozone sensor that is also incorporated into the sensor
board is unable to be used at the present time. However if a commercial ozone detector was used the
ozone sensors on the wireless sensor board would also be able to be used to collect data.
Figure 20 ‐ Comparison of estimated carbon monoxide pollution and measured pollution
19
3.7 Bluetooth Module The wireless sensor board communicates with Smart Phones via a Bluetooth connection. Bluetooth
was chosen as the communication technology for several reasons. Bluetooth offers a complete
wireless service for personal area networks within a 10m range. Bluetooth does not require a line of
sight path and has impressive low power performance. Furthermore Bluetooth is secure and offers
data rates up to 721kbps which is more than sufficient for the wireless senor board’s requirements.
Communication is only required in one direction from the microcontroller to the Smart Phone. The
Bluetooth module is used to transfer the data readings from the gas sensors taken by the
microcontroller to the Smart Phone. The microcontroller will interface with the Bluetooth module
using the USART interface which only requires two simple connections; a Clear to Transmit (CTS) and a
Serial Data Transmit (Tx). There are various different Bluetooth modules that are commercially
available as shown in Table 2.
*All prices correct as of 30th May 2010
All of the Bluetooth modules in Table 2 have similar functionality, electrical specifications and physical
dimensions. The wireless sensor board uses the ARF32 Bluetooth module from Adenuis as seen in
Figure 21. Although this module is not the cheapest module available, it has a very simple physical
interface and is easy to connect with the PIC16f690 microcontroller. Also this module was easy to
interface with the Smart Phone and can be easily customised for increased security and display
properties. Although the LMX9830 by National Semiconductors was significantly cheaper than the
ARF32, this module must be surface mounted, making interfacing with the microcontroller more
complex and difficult. For early development of the wireless sensor board the ARF32 module was an
appropriate choice, however if large scale production was to begin, further work should be spent on
incorporating the LMX9830 module as this would significantly reduce costs.
Figure 21 ‐ Bluetooth Module [21]
Table 2 ‐ Comparison of Bluetooth Modules
20
3.8 Message Structure For communication between the wireless sensor board and the Smart Phone an agreed message
structure was determined. Each message that is sent from the wireless sensor board contains
information including:
Format Version (1 byte)
Device identification number (2 bytes)
Number of sensors on the wireless sensor board (1 byte)
Calibration Coefficients (7 bytes)
Reference Voltage used for voltage reading (2 bytes)
Number of measurement readings being sent (1 byte)
Measurement Readings (2 bytes)
Checksum (1 byte)
There is a large amount of information that is included in every message. An agreed format between
the wireless sensor board and the Smart Phone is very important to ensure this process is successfully
and efficiently completed. Each piece of information requires a different number of bytes and there
may be a different number of measurement readings and calibration coefficients depending on the
settings. Other redundant information is included in every message such as a header and footer to
allow the Smart Phone to determine the start and end of every message. The complete format of the
message and the order in which the various bytes of information is sent is illustrated in Figure 22.
The format version number indicates to the Smart Phone what version of software is being used on
the sensor board. The version number informs the Smart Phone what the format of the rest of the
message will be. This design consideration is for future needs when new information may be required
to be sent to the Smart Phone from the wireless sensor board. The device identification number is a
two byte number that is unique to each wireless sensor board. This allows particular pollution
measurements to be associated with a particular unit and distinguished from other devices. Also,
being able to identify a particular unit from its data readings is important if problems occur and
specific units need to be isolated and recalibrated. Using a two byte number allows for over 65 000
unique codes and thus over 65 000 units.
The number of sensors on the unit is sent to the Smart Phone for administrative purposes only and
informs the phone of how many sensors it needs to record measurements for. Only one byte is
required as the sensor count will only be a single digit number ranging from one to five.
Figure 22 ‐ Message Format for Bluetooth Communication [6]
21
As discussed previously every gas sensor requires individual calibration and will have its own
coefficients. As the microcontroller is not able to evaluate the quadratic equation the Smart Phone is
required to calculate the corresponding pollution reading for a given voltage. This requires the
wireless sensor board to send to the Smart Phone both the voltage readings and the sensors
coefficients which are programmed into the microcontroller. The format of the equation that relates
the voltage to air pollution will be in the form:
The coefficient terms require floating point accuracy which is not achievable on the microcontroller. A
new data format was designed which allowed for easy representation of the range of numbers that
were likely to be dealt with. Each coefficient term required two bytes which were distributed as
shown in Figure 23.
The significand is represented by 12 bits and is a signed integer, allowing the representation of
numbers from ‐2048 to +2048. The exponent is a 4 bit signed integer allowing the representation of
numbers from ‐8 to +8. Overall this allows us to represent any integer number to four significant
numbers in the range of:
‐2048 x108 to 2048 x108
For decimal numbers, this structure allows the representation of numbers as small as:
1 x10‐8
This structure for representing floating point numbers should be more than sufficient for the range of
values required by the gas sensors calibration equations. This format allowed for air pollution
readings accurate up to eight decimal places. Each gas sensor requires its own calibration equation
and Figure 24 demonstrates how they are represented in the overall message.
Figure 23 ‐ Floating Point Format for Microcontroller [6]
Figure 24 ‐ Coefficients Format for Transmitted Message [6]
22
A reference voltage is required by the Smart Phone in order to determine the voltage that was
measured for each sensor. The analogue to digital converter inside the microcontroller converts the
voltage at an input pin into an eight bit number. This number can range from 0 to 255 with 255 equal
to the reference voltage. Two bytes of data is enough information to represent this number in the
same floating point format as the sensor coefficients.
The measured voltage for each sensor only requires one byte of information and is a number ranging
between 0 and 255. The resultant number after the analogue to digital conversion is simply a
percentage of the reference voltage. Because so much administrative information is required to
correctly calculate the air pollution reading and identify the device, sensor readings are sent in
batches rather than a sensor reading per message. This makes the communication between the
wireless sensor board and the Smart Phone far more efficient, saving both time and energy.
The number of sensor readings sent per message will vary depending on the setting programmed into
the microcontroller; the default value is ten readings and only requires one byte to inform the Smart
Phone. After each sampling period their will be N new measurements, where N is the number of
sensors on the wireless sensor board. The number of sample periods (T) between consecutive sending
periods to the Smart Phone will determine how many sensor values will need to be sent. There will be
a total of N*T number of sensor values to be sent. Figure 25 shows how these values are structured
with the sensor identification number before its value, to allow the Smart Phone to identify which gas
sensor the sample has been taken from.
For data verification a simple one byte checksum is added into the overall message. This checksum is
the eight least significant bits from the summation of all bytes sent excluding the header and footer.
Before sending the message this checksum is calculated and then added into the message. Once the
Smart Phone has received the whole message, it performs the same checksum operation and
compares its result with the sent checksum. If these are both equal it is assumed that no errors have
occurred and the data is then extracted and used. If the checksums do not match, the data is
disregarded and the Smart Phone will wait for the next transmission.
The whole message structure and format has been carefully designed to minimise the need to
restructure the entire message format if new or additional information is required to be sent to the
Smart Phone. For specific parts of the message where particular information has varying lengths,
extra information has been included to ensure that this can vary from sensor board to sensor board
with no change to the software on the Smart Phone. This added flexibility between differing sensor
boards is critical for future expansion where there will be many different devices with differing sensor
coefficients, device identifications and message format versions.
Figure 25 ‐ Format of Sensor Values for Transmitted Message [6]
23
3.9 Smart Phone Application With an agreed message format between the wireless sensor board and the Smart Phone, packets of
data can be transferred. Nikolaus Youdale wrote the application that runs on the Smart Phone which
uses the Android 2.2 operating system. There are several parts of this application including:
connecting with the wireless sensor board, receiving packets, processing data and uploading
measurements to the server.
The key requirement for the Smart Phone application when connecting to the wireless sensor board is
the user interface. The application was designed to allow any new user to simply start the application
and select which wireless sensor board they are using, without requiring any further user input. Figure
26 shows the initial screen when the application is started. The user can either choose to select their
unique device from a list of all devices or can perform a quick Bluetooth scan of all transmitting
devices within range to discover their device.
When a wireless sensor board is connected the application will continue to run, periodically receiving
packets from the sensor board every 15 to 30 seconds. The Smart Phone application extracts all the
information from the received packets based on the agreed message format between both devices.
The application converts the measured voltage outputs from each sensor to an equivalent pollution
reading according to the formulated calibration equation. During this process the Smart Phone
retrieves its current physical location through the GPS unit. The application then constructs a new
message which is uploaded to the server, which contains a database for all pollution measurements.
This message consists of the various pollution readings, GPS location and the current time. The Smart
Phone establishes a connection to the remote server through either a 3G connection or a wireless
network and uploads the message. The application also displays the current pollution readings along
with GPS co‐ordinates and time of sample on the phone’s display for the user’s interests as shown in
Figure 27.
Figure 26 ‐ Android Application ‐ Connection Screen [6]
Figure 27 ‐ Android Application ‐ Display of Pollution Readings [6]
24
4. Power Management
4.1 Power Requirements
Table 3 ‐ Requirements of Wireless Sensor Board
As there are several different components that make up the wireless sensor board, careful
consideration needs to be made in regard to the power requirements of the overall board. Each
component requires a different amount of current at different voltages as documented in Table 3.
Due to the nature of the metal oxide semiconductor sensors, they require a heater current of
approximately 38mA in order to operate; this will be where most of the power will be used on the
wireless sensor board. Each gas sensor has a different maximum voltage; exceeding this will cause
overheating and destroy the inner circuitry of the sensor. These different voltage levels were achieved
through a resistor network all fed from the same power supply.
To conserve power in the Bluetooth module, the wireless sensor board does not transmit for the
whole period of time while the device is switched on. The microcontroller will record up to 10 values,
over a period of 30 seconds, before transmitting all values in one transmission. This conserves a
considerable amount of power as large overheads are involved in sending a transmission. This
technique allows the cost of the overheads to be shared with multiple samples rather than just a
single sample. Using this technique it has been measured that the Bluetooth module is only
transmitting data for 5% of the time. For the remaining amount of time the module will remain in a
low power idle state.
There are three status LED indicators on the wireless sensor board, to indicate the unit’s current
status. The green LED indicator will flash to indicate power to the board and remains on for
approximately 40% of the time. The blue LED indicator is only used for approximately 5% of the time
whilst the Bluetooth is transmitting data. Lastly the red LED indicator will only be used to indicate the
batteries are running low.
The microcontroller is active for the whole time that the wireless sensor board is switched on.
However, due to the low power nature of the chip, it only consumes a small amount of power while in
operation. As calculated in Table 3 the wireless sensor board will consume on average a total of
117.65mA.
Component Quantity Supply Voltage
Supply Current Percentage of Usage Time
Total Supply Current
Carbon Monoxide Sensor 1 2.70V 38.1mA 100% 38.1mA
Ozone Sensor 1 2.70V 38.2mA 100% 38.2mA
Nitrogen Dioxide Sensor 1 1.90V 34.1mA 100% 34.1mA
Microcontroller 1 5V 1mA 100% 1mA
Green LED 1 2.7 6mA 40% 2.4mA
Blue LED 1 2.7 6mA 5% 0.3mA
Red LED 1 2.7 6mA 5% 0.3mA
Bluetooth Module 1 3.3V 65mA (Sending) 100 μA (Idle)
5% 3.25mA(Avg.)
Total Current 117.65mA
25
4.2 Batteries Once the power requirements for the wireless sensor had been calculated the next process involved
selecting the appropriate batteries. Four main criteria were considered when comparing the various
types and brands of batteries, including:
Physical Dimensions
Electrical Performance and duration
Ability to recharge and reuse the batteries
Cost
The physical dimensions are of key importance as the wireless sensor board should be as compact and
portable as possible. The physical dimensions of the battery will also have a large influence over the
shape and size of the external casing of the device.
The electrical performance of the batteries is also vital as this will determine how long the batteries
will last and hence how long the wireless sensor board can be used for. The wireless sensor board
should be able to last for a whole week (minium 14hours) without the batteries being recharged or
replaced. This minimum requirement was realised by considering the targeted users of the wireless
sensor board. A typical user should be one that experiences travel times of up to an hour per trip,
twice a day. This ensures that large amounts of air pollution data are captured and recorded each
usage. Furthermore it is very important to make sure that the batteries are able to supply enough
voltage to power all the various components on the sensor board.
It is also very important that the batteries used with the wireless sensor board are able to be
recharged and reused multiple times. The batteries should be able to power the sensor board for a
minimum of 14 hours. Based on predicted typical usage, the batteries will require charging every
week and hence it is desired to be able to simply recharge the batteries instead of having to replace
them.
Lastly, the cost of the batteries must also be considered when comparing the various batteries. The
wireless sensor board has been designed so that these devices can be produced at a reasonably low
cost. Hence the cost of batteries needs to be carefully considered such that the cost of the total
overall product remains relatively low.
It is clearly demonstrated in Table 4 that there is a trade‐off between these four criteria and no one
battery excels in all criteria. There is a significant difference in cost between alkaline batteries and
nickel‐metal hydride (NiMH) Rechargeable batteries. However if alkaline batteries were to be used,
they would have to be replaced on a regular basis and would incur a greater cost long term when
compared with rechargeable batteries. There is a performance trade‐off between alkaline batteries
and NiMH rechargeable, with alkaline batteries performing for a longer period of time with greater
voltage. However this trade‐off is considered acceptable as the small amount of performance loss is
worth the advantage of being able to recharge and reuse the same batteries.
Lastly it can be noted that there is a considerable difference in the physical dimensions of the
rectangular 9V batteries and the cylindrical AA batteries. The rectangular batteries are more compact
and ideal for use with the wireless sensor board, however they have poor electrical performance.
Using the 9V batteries in the wireless sensor boards would only achieve a few hours of operation
between required charges, which is not desired.
26
Table 4 ‐ Comparison of Standard Commercially Available Batteries
Size Type Brand QuantitySupply Voltage (Volts)
Milliamp Hours (mAh)
Physical Dimensions
Cost
AAA Alkaline Duracell 4 1.5V each 6V total
1200 14.5mm ‐ Diameter 50.5mm ‐ Height
$ 6.99
AAA Alkaline Energizer 4 1.5V each 6V total
1200
14.5mm ‐ Diameter 50.5mm ‐ Height
$ 6.76
AAA Nickel‐Metal Hydride (NiMH) ‐ Rechargeable
Duracell 4 1.2V each 4.8V total
850 14.5mm ‐ Diameter 50.5mm ‐ Height
$ 26.00
AAA Nickel‐Metal Hydride (NiMH) ‐ Rechargeable
Energizer 4 1.2V each 4.8V total
850 14.5mm ‐ Diameter 50.5mm ‐ Height
$ 25.82
AA Alkaline Energizer 4 1.5 each 6V total
2700 14.5mm ‐ Diameter 50.5mm ‐ Height
$ 7.45
AA Alkaline Duracell 4 1.5 each 6V total
2700 14.5mm ‐ Diameter 50.5mm ‐ Height
$ 6.99
AA Nickel‐Metal Hydride (NiMH) ‐ Rechargeable
Duracell 4 1.2V each 4.8V total
2300 14.5mm ‐ Diameter 50.5mm ‐ Height
$ 26.29
AA Nickel‐Metal Hydride (NiMH) ‐ Rechargeable
Energizer 4 1.2V each 4.8V total
2450 14.5mm ‐ Diameter 50.5mm ‐ Height
$ 23.50
9V Alkaline Duracell 1 9V 565 48.5mm ‐ Height 26.5mm ‐ Width 17.5mm ‐ Length
$ 5.79
9V Alkaline Energizer 1 9V 565 48.5mm ‐ Height 26.5mm ‐ Width 17.5mm ‐ Length
$ 6.87
9V Nickel‐Metal Hydride (NiMH) ‐ Rechargeable
Energizer 1 9V 175 48.5mm ‐ Height 26.5mm ‐ Width 17.5mm ‐ Length
$ 22.88
*All prices taken from http://www.homeshop.com.au/website/home.jsp and correct as of 26/10/2010
27
The Energizer AA nickel‐metal hydride (NiMH) ‐ rechargeable batteries were chosen to be used with
the wireless sensor board for numerous reasons. These batteries have good electrical performance,
offering up to 2450mAh. With the wireless sensor board requiring on average 117.65mA, this equates
to over 20 hours of continual operation between charges. This is greater than the minimum
requirement of 14 hours of usage previously discussed. A single AA NiMH battery is 1.2 volts and
hence 4 batteries are required to meet the minimum amount of supply voltage. The trade‐off with
these batteries is that they are not as compact as the rectangular batteries. Four AA batteries
connected in series will require a minium of 65mm x 55mm of free space which will influence the
casing of the overall device. These batteries are more expensive than the other batteries listed in
Table 4 however they will offer the greatest overall performance and hence are a long term cost
saving.
4.3 Battery Performance To test the performance of the Energizer AA nickel‐metal hydride (NiMH) – rechargeable batteries an
experiment was conducted. This experiment was designed to measure and profile the supply voltage
of the batteries throughout a whole cycle from a complete charge to a complete drain. The batteries
were attached to a wireless sensor board to ensure an appropriate discharge rate modelling how they
would be used in the final product. The wireless sensor board was also connected to a computer
through the Bluetooth module to guarantee correct power usage for all components. The results are
demonstrated in Figure 28 and Table 5.
As illustrated in Figure 28, the voltage level of the batteries slowly drops
off during the first 22 hours of operation. During this period the wireless
sensor board was completely functional. Similar to all battery discharge
curves there is a sudden exponential drop in supply voltage at a critical point. As can be seen in the
above graph, the supply voltage dropped off suddenly at approximately 23 hours of operation and
during this time, the Bluetooth stopped functioning and the wireless sensor board was inoperable.
This experiment demonstrated the performance of the Energizer (NiMH) rechargeable batteries and
assisted in determining when the low voltage alert should be activated.
Table 5 ‐ Discharge Values for NiMH Rechargeable Batteries
Figure 28 ‐ Discharge Curve for NiMH Rechargeable Batteries
28
The capacity loss over recharge cycles of rechargeable batteries also needs to be considered to
evaluate their overall lifetime expectancy. The capacity of a battery is the number of milliamp hours
(mAh) a battery can hold after a single charge. This is an important characteristic of any battery to
ensure that the battery will last when undergoing constant charging and discharging. As shown in
Figure 29 the capacity of a NiMH battery slowly deteriorates as the battery undergoes an increasing
number of charging and discharging cycles. After approximately 300 complete cycles a single battery
will have lost 10 to 15% of its original capacity. The batteries total capacity will continue to reduce
until the battery will be unable to sufficiently hold a reasonable amount of charge. If NiMH batteries
were to be used with the wireless sensor board with average use of a complete recharge cycle per
week, one set of batteries would last for over 500 weeks. This property of the Energizer AA (NiMH)
rechargeable battery makes it a good power supply for the wireless sensor board.
Figure 29 ‐ Capacity Deterioration of NiMH Rechargeable Batteries [23]
29
4.4 Low Battery Detector For user awareness, a low battery detector has been incorporated into the wireless sensor board. The
purpose of the low battery detector is to alert the user through a red solid LED when the batteries are
low on charge and require charging. As seen from Figure 28, the NiMH batteries experience a slow
discharge for a period of approximately 22 hours and then experience a quick sudden exponential
discharge. It is critical that the user is alerted before this period so they have adequate time to
recharge the batteries. The wireless sensor board becomes inoperable when the supply voltage falls
below 3 volts, occurring after approximately 24 hours of operation. To give the user sufficient time to
recharge the batteries, a low battery warning is given 4 hours before the device becomes inoperable,
at the threshold voltage. From Figure 28 it can be seen that the threshold voltage is approximately
4.20 volts after 20 hours of operation.
Using the analogue to digital converter (ADC) inside the microcontroller the supply voltage is able to
be monitored. The analogue to digital converter converts the voltage of the batteries into a digital
value which can be compared to the threshold voltage. As shown in Figure 30 this is simply achieved
by connecting a pin of the microcontroller containing the enabled ADC to the power supply. The
microcontroller is powered by a voltage less than the voltage of the batteries through the use of the
voltage regulator. A resistor network is required to ensure that the voltage at the connection of the
microcontroller is within the voltage range the microcontroller requires for the analogue to digital
conversion. The threshold voltage level can be adjusted through the software in the microcontroller
and is set to a default of 4.20 volts. When the supply voltage decays past the threshold the red LED is
activated on the wireless sensor board for user awareness.
Furthermore, as the supply voltage of the batteries is being constantly monitored, a real time battery
status and percentage of charge can be displayed on the Smart Phone. This is achieved by
transmitting the battery’s status to the user’s Smart Phone, where software on the Smart Phone
interprets this and displays the status on the phone. When the threshold voltage or percentage is
reached the phone will display an appropriate message alerting the user of the current battery status
and requirement for charge.
Figure 30 ‐ Low Battery Detector Circuit
30
5. Printed Circuit Board (PCB) Design
Once all the components had been chosen and the final circuitry of the wireless sensor board
realised, a printed circuit board was designed and then manufactured. This process involved several
steps including designing the electrical circuit schematic, the printed circuit board layout and also the
physical manufacturing of the board.
5.1 Electrical Schematic Before the electrical schematic was created the final circuit was built and thoroughly tested using a
demonstration board. This allowed every component to be tested individually for both voltage levels
and drawn currents. Resistor values were also checked to ensure they provided the correct voltage
drop throughout the circuit. Once the final circuit had been realised, the corresponding circuit was
created in the schematic editor and various electrical tests were conducted. These tests checked for
any short circuits, breaks in circuits and any incorrect pin matching. The final schematic can be seen in
Figure 31.
Figure 31 ‐ Wireless Sensor Board Electrical Schematic
5.2 Printed Circuit Board Design and Regulations The next step in the PCB design process involved creating the footprints for each individual
component. As most of the components that were being used were not standard components they
had to be manually created. This is a critical step which involved precise detail in making sure the
physical dimensions of the component matched the footprint exactly. If these dimensions were
slightly off, the connection pins of the component would not fit in the holes on the printed circuit
board. Furthermore, caution needed to be applied to ensure that each pin on the component
footprint matched up with the correct pin on the component, such that all connections were made to
the correct pin.
With all the footprints created the next process involved converting the electrical schematic to a
printed circuit board design. All the components had to be individually arranged on the PCB such that
they did not interfere with one another and that none of the tracks connecting components together
crossed. This was a complicated process as there were multiple tracks running in various directions
around the board. Furthermore, from an electrical and manufacturing perspective the PCB had to
comply with many other rules and regulations.
31
These regulations included:
A minimum hole size of 0.7mm and a surrounding solder pad of at least 1.8mm. This was to
ensure that an adequate amount of solder was applied to the pins to guarantee an electrical
connection between the component pin and the electrical track.
A minimum distance of 0.5mm between any two tracks. This constraint is for both
manufacturing and electrical purposes. In manufacturing the circuit board, a non conductive
groove surrounding the track is etched into the copper sheet. This groove breaks the electrical
connection between a track and the rest of the board, effectively creating an isolated track
between two holes. It also ensures that no electrical contact can be made with other tracks
running in parallel. Due to manufacturing machinery this
groove can be no smaller than 0.5mm.
When routing tracks, acute angles as seen in Figure 32 Part 1
should be avoided, as the tight corners can accumulate the
copper residual after it has been etched, bridging an electrical
connection with the copper sheet.
When a track has to be placed between two pads, the track
should be routed such that there is even space between both
holes and the track. This is demonstrated in Figure 32 Part 2.
Tracks should pass through the centre of a pad to ensure that
the solder completes a full electrical connection with the
track, as shown in Figure 32 Part 3.
The track should be such a size that it is considerably smaller
than the diameter of the solder pad. If this is not adhered to,
solder can run onto the track and may spill into the groove,
compromising the tracks isolation from the copper sheet. The
correct track size to pad diameter is illustrated in Figure 32
Part 4.
Other important design practices that were used include using round solder pads instead of square
solder pads in areas where several pads were close together. With round circular pads the distance
between pads is minimal, ensuring that when soldering, no solder leaks onto neighbouring pads,
bridging an electrical connection between two component pins. However rectangular or square solder
pads were used for specific components when large amounts of solder were required for large
component pins. Rectangular solder pads maximise the surface area of the solder pad to improve the
quality of the electrical connection.
For the wireless sensor board only a single layer board was required as the design wasn’t too complex
and had a minimal number of components. Using only a single layer printed circuit board reduced the
required manufacturing time as the board did not need to be rotated and could all be etched in one
configuration. The microcontroller was placed at the centre of the board as all other components
made at least one connection with the microcontroller. This simplified the design significantly and
made routing the tracks considerably easier. Furthermore, a 20 pin dip socket was soldered to the
board instead of the microcontroller, limiting the risk of damage to the internal circuitry of the
microcontroller during the soldering process. The three gas sensors were placed together as they all
involved similar circuitry and the one power supply could be shared between them.
Figure 32 ‐ Track Routing Rules and Regulations [22]
32
The final printed circuit board design can be seen in Figure 33 and Figure 34 along with the actual
manufactured board in Figure 35.
Figure 33 ‐ Wireless Sensor Board Printed Circuit Board Design with Track Routings
Figure 35 ‐ Wireless Sensor Board Prototype Figure 34 ‐ Wireless Sensor Board PCB
33
5.3 External Casing and Mounting The external casing of the wireless sensor board
plays an important role in the overall protection
and endurance of each unit. The external casing
needs to be designed to allow the gas sensors to
be exposed to the outside air but must also be
waterproof to ensure the electrical circuit and
sensors are not damaged or destroyed. A plastic
casing was used to house the wireless sensor
board and provided a cheap and easy solution to
this problem. The plastic casing used, seen in
Figure 36, was chosen due to its compact size and
ability to fit both the batteries and the sensor
board inside. This plastic casing also allowed the
user to simply open and close the casing to turn
the sensor board on or off with the switch. Several
holes were drilled through the outside of the
casing to allow the gas sensors to be exposed to
the outside air. This casing is unfortunately not
waterproof at the moment, limiting the use of the
wireless sensor board to dry conditions only.
A two part locking mechanism was then attached
to the outside of the casing to allow the user to quickly mount the sensor board on a vehicle. One part
of the locking mechanism remained permanently attached to the casing of the sensor board, whilst
the other half of the locking mechanism remained attached to the external of the motor vehicle. This
locking system allowed the wireless sensor board to be easily mounted and released from the car.
Figure 37 shows the wireless sensor board mounted securely to the outside of a car.
Figure 36 ‐ Wireless Sensor Board in External Casing
Figure 37 ‐ Example of Mounting the Wireless Sensor Board
34
5.4 Bill of Materials Table 6 ‐ Bill of Materials for Wireless Sensor Board
Bill Of Materials
Component Model Required
Number Supplier
Price Per
Component
Total Price Per
Unit
Bluetooth ADEUNIS ‐ ARF7044A 1 Farnell.au $51.46 $51.46
CO ‐ Sensor MICS ‐ 5521 1 e2V $24.65 $24.65
NO2 ‐ Sensor MICS ‐ 2710 1 e2V $24.65 $24.65
O3 Sensor MICS ‐ 2610 1 e2V $25.35 $25.35
Microcontroller PIC16f690 1 School Workshop $3.00 $3.00
20pin DIP Socket MILL MAX ‐ 20WAY 1 Farnell.au $1.91 $1.91
Triple LED YSL‐R596CR3G4B5C‐C10 1 Sparkfun $1.90 $1.90
Rocker Switch SCHURTER ‐ 1301.9206 1 Farnell.au $1.40 $1.40
Header Pins PRT‐00116 9 Sparkfun $0.06 $0.56
Voltage Regulator LD1117V33 1 Sparkfun $1.95 $1.95
Batteries Energizer Rechargeable
AA 4 Woolworths $5.88 $23.50
Battery Holder PH9282 1 Jaycar $2.95 $2.95
PCB Manufacturing 75 Holes 1 $2.75 $2.75
Casing
1 TEK's $2.50 $2.50
Resistors
11 School Workshop $0.01 $0.11
Total Price Per Unit $168.65
A complete list of all the component information (costs, suppliers, model numbers and quantities)
required to make the wireless sensor board is shown in Table 6. A complete device can be made for
just over $168. A large amount of the cost is the wireless sensors and the Bluetooth module, where
the cost is heavily dependant on the quantity of order. If large scale production (approximately 100
units) was to occur, the cost of several components would significantly reduce and a total wireless
sensor board unit could be produced for less than $150.
35
6. Experimentation and Results After a complete and working wireless sensor board unit was built, several experiments and tests
were conducted. These tests were designed to measure the performance of the wireless sensor board
and also to ensure that this part of the Haze Watch project functioned well with other stages of the
overall project.
6.1 Experiment 1 In the first experiment the wireless sensor board was attached externally to a car along with the
commercially available GasAlertMicro 5 air monitor as seen in Figure 38 and Figure 39. The car was
then driven from Mosman across Sydney to Menai. This trip involved several lengthy tunnels where
air pollution was expected to be higher than the average recommended exposure set out by the
Department of Environment, Climate Change and Water (DECCW). This particular route was also
chosen as it came within close proximity of several of the government fixed air monitoring sites
around Sydney. This allowed us to compare the measurements taken by both the wireless sensor
board and the GasAlertMicro 5 with our estimation based on the results from these fixed monitoring
sites.
There were two main objectives of this experiment. The first objective was to check that the wireless
sensor board produced similar air pollution readings as the commercial GasAlertMicro 5 device. The
second main objective was to demonstrate that air pollution can vary significantly between small
changes in location, which is not represented in the estimations made from the fixed air monitoring
sites alone. During this experiment both carbon monoxide and nitrogen dioxide were measured every
second by both devices. This driving test was conducted on the 28th August 2010 and started at
approximately 1.54pm and ended at 2.37pm. The exact route was recorded with a GPS track stick and
can be seen in Figure 40. This trip passed through Sydney Harbour Tunnel, Domain Tunnel, Eastern
Distributor, Cleveland Street underpass, Airport Tunnel, Cooks River Tunnel and the M5 South West
Motorway Tunnel. Also shown on the map in Figure 40 are red markers. These indicate the location of
the various fixed air monitoring sites monitored by the DECCW.
Figure 39 ‐ Haze Watch and GasAlertMicro 5 Devices externally attached to motor vehicle
Figure 38 ‐ Close up of the Mounting of Haze Watch and GasAlertMicro 5 Devices
36
Figure 41 is a graph of the recorded carbon monoxide readings from both the wireless sensor board
and the GasAlertMicro 5 device. The red line is the output voltage recorded from the carbon
monoxide sensor on the wireless sensor board. The blue line is the recorded samples from the
GasAlertMicro 5 and is a direct measure of the carbon monoxide concentration in parts per million
(ppm). Figure 42 is a similar plot for nitrogen dioxide taken at the same time and location as the
carbon monoxide samples. As can be seen by both these figures there is a clear correlation between
the voltage output of the gas sensors on the wireless sensor board and the pollution readings taken
from the commercially made air monitor, the GasAlertMicro 5. These graphs also show the ability of
the wireless sensor board to take many samples in short periods of time to ensure no critical data is
missed between sample points. As illustrated in the graph, there are large variations in the voltage
readings within small periods of time. The ability to take many samples in a short period of time is a
key requirement of the wireless sensor board as air pollution in real environments can vary
significantly over small distances. It is important that all fluctuations in pollution readings are
recorded to ensure a true representation of the pollution can be shown.
Figure 40 ‐ GPS Route Taken for Experiment 1
37
Figure 41 ‐ Plot of Carbon Monoxide Samples from Wireless Sensor Board and GasAlertMicro 5 Device
Figure 42 ‐ Plot of Nitrogen Dioxide Samples from Wireless Sensor Board and GasAlertMicro 5 Device
38
Using the calibration equations that had been predetermined for these exact sensors, the voltage
measurements taken from the sensor outputs could then be converted into equivalent pollution
readings. For this particular wireless sensor board the calibration equations for both carbon monoxide
and nitrogen dioxide are:
. . .
. . .
The equivalent carbon monoxide and nitrogen dioxide concentration levels from the wireless sensor
board are plotted in Figure 43 and Figure 44 respectively. The orange plot is from the wireless sensor
board and the blue plot was the air pollution reading taken by the GasAlertMicro 5 device. The green
plot is the Government data estimation (ppm).
Figure 43 ‐ Plot of Carbon Monoxide Samples from Wireless Sensor Board and GasAlertMicro 5 Device
39
Figure 43 demonstrates the accuracy of the wireless sensor board in measuring carbon monoxide. The
pollution readings from the wireless sensor board are a very close approximation to the recordings
taken from the commercially available air monitor. However the gas sensors on the sensor board
became inaccurate when exposed to large concentrations of air pollution as shown in Figure 43, when
the sensor board travelled through the M5 Tunnel. The sensor board gave readings that were greater
than what the commercially available device recorded. This is because the calibration equations for
the gas sensors are in a quadratic form, which do not exactly match the response of the gas sensors.
However this problem is only evident at large concentrations which aren’t expected to experienced
regularly.
There is discrepancy in Figure 44 between the pollution measurements from the sensor board and the
GasAlertMicro 5 device. The two plots do not follow each other as closely as the carbon monoxide
graph, mainly due to the lack of sensitivity in the GasAlertMicro 5 device. This device is only able to
measure nitrogen dioxide to an accuracy of 1 part per billion and often requires a minimum
concentration of 2 parts per billion before a reading is registered. This is shown in Figure 44 with the
GasAlertMicro 5 device recording a nitrogen dioxide concentration of zero for most of the
experiment.
The green plots in both of these figures are an estimated concentration level for the given experiment
GPS route. The estimation is based only on the pollution readings from the fixed air monitoring sites
around Sydney, maintained by the DECCW. A pollution reading is determined for a specific location
based on two characteristics: the distance between the specific location and the fixed air monitoring
sites and secondly the time at which the sample was taken at the fixed air monitoring site [5]. The
recordings taken by the fixed air monitoring sites are only updated every hour. This means the
DECWW predictions are only based on one set of pollution measurements from all of the fixed sites.
Figure 44 ‐ Plot of Nitrogen Dioxide Samples from Wireless Sensor Board and GasAlertMicro 5 Device
40
Figure 43 and Figure 44 both demonstrate an important issue with current air pollution monitoring
systems in Sydney. The fixed air monitoring sites located around Sydney are far apart and unable to
correctly determine a pollution level for locations in between. From both the wireless sensor board
and the GasAlertMicro 5 plots in Figure 43 and Figure 44, it can be shown that the air pollution varies
significantly over small changes in location. Therefore, using only the fixed air monitoring sites to
estimate a pollution reading for locations in between is unreliable and inaccurate. The other smaller
peaks in Figure 43 are when the car had stopped at busy intersections along the route; this shows that
air pollution varies significantly around busy suburban areas. It is these areas which are of most
interest as they are highly populated areas and the air quality cannot be correctly modelled by data
from the fixed air monitoring sites alone.
Furthermore, as can be seen clearly in Figure 43 there is considerable difference between the
pollution measurements taken by both mobile devices and the readings from the fixed air monitoring
sites. The estimation for carbon monoxide based on only the fixed air monitoring sites ranged
between 0.21 and 0.25 ppm, while the pollution levels from the mobile devices vary from 0 to 80ppm.
The fixed air monitoring sites are located in suburban areas away from major roads. This results in the
fixed air monitoring sites not recording air pollution concentrations commonly experienced by a
regular commuter. These figures are further evidence that a more detailed air monitoring system is
required to produce an accurate model of air pollution.
41
6.2 Experiment 2 The second experiment that was conducted using the wireless sensor board was a complete test of
the Haze Watch system. Firstly this involved testing if the wireless sensor board worked with the
Smart Phone to upload pollution samples in real time. Secondly this experiment aimed to test
whether the server could handle data continually being uploaded in real time. Thirdly this experiment
tested if the air pollution model would work correctly for large amounts of sample points, to correctly
model the air pollution. Lastly the iPhone application created by Nikolaus Youdale to estimate an
individual’s personal exposure was also tested throughout this experiment. The iPhone application
would allow any individual who had an iPhone to record their GPS trace over a particular period such
as a car trip, a certain event or a whole day. With this GPS trace the individual’s exposure to air
pollution for their whole trip can be estimated from data calculated by the air pollution model[6].
This experiment was also designed to further evaluate the effectiveness of more sample points in the
air pollution model compared to just using the fixed air monitoring sites in determining a pollution
estimate for an exact location.
This experiment involved driving with the sensor around a large loop of Sydney starting at the
University of New South Wales to collect air pollution samples. The loop then continued on the M5
South West Motorway towards Roselands, through Homebush and Ryde, past Chatswood and then
on the Warringah Freeway through the Sydney Harbour Tunnel and Eastern Distributor Tunnel back
to the University of New South Wales as shown in Figure 45. This route was chosen specifically to
encircle as many of the fixed air monitoring sites as possible. As can be seen by the red markers in
Figure 45, choosing this route allowed our air pollution model to use five of the fixed air monitoring
sites for the pollution estimation. This allowed comparison of the air pollution recorded by the
wireless sensor board and the estimation based on only these fixed air monitoring sites.
Figure 45 ‐ Map of Driving Route for Experiment 2
42
This experiment was conducted in two sessions with two cars taking the same route as shown in
Figure 45 half an hour apart starting at 1.45pm on the 7th October 2010. The first car had a wireless
sensor board mounted outside the car. The wireless sensor board was connected to the Smart Phone
running the Android application inside the car. The Smart Phone received readings and global position
system (GPS) coordinates from the sensor board and uploaded them to the database contained on
the server in real time.
The second vehicle left half an hour later. It took the same route and had an iPhone running the
personal air pollution exposure application as well as the commercially available air monitor, the
GasAlertMicro 5 device recording pollution levels. The second car was used to evaluate the accuracy
of the iPhone application by comparing the estimated air pollution exposure calculated by the iPhone
application with the samples recorded by the GasAlertMicro 5. Measurements taken by the
GasAlertMicro 5 represented the individual’s real exposure during the experiment. The second car did
not have a wireless sensor board and did not upload any data to the server throughout the
experiment.
The iPhone application computed the pollution exposure for the experiment route twice. The first
exposure estimation was based only on measurements from the fixed air monitoring sites maintained
by the DECCW. The second exposure estimation was calculated with all the data which the wireless
sensor board collected in the first vehicle and also the data from the fixed air monitoring sites. These
two exposure estimations were then compared to the recordings taken by the GasAlertMicro 5, to see
which method gave a closer approximation to an individual’s true pollution exposure. The objective of
this experiment was to determine how effective more sample points of air pollution taken by a device
such as the wireless sensor board have on an air pollution model.
The wireless sensor board in the first car was taking measurements for both carbon monoxide and
nitrogen dioxide. Figure 46 is a plot of the carbon monoxide samples in parts per million (ppm) taken
for the whole route that were uploaded directly to the server by the Android application running on
the Smart Phone.
Figure 46 ‐ Carbon Monoxide Recordings from Wireless Sensor Board during Experiment 2
43
As can be seen in Figure 46, large concentration levels were recorded at specific locations along the
route, in particular in the tunnels and at major intersections. These readings were uploaded directly
to the server which allowed them to be plotted on a map as seen in Figure 47, which overlays
different colours depending on the amount of carbon monoxide. The green markers are the exact
geographical location of every sample that was uploaded to the server. The red marker indicates
where the largest recording was taken and the blue marker is where the smallest reading was
recorded. The coloured overlay scale ranges from blue (low pollution) to green (medium pollution),
then yellow (high pollution) to red (extreme pollution). As can be seen in Figure 47, various areas are
different colours indicating the significant change in air pollution over geographical locations. The
yellow and red regions on the map in Figure 47 coincide with the peaks on the graph in Figure 46,
which are the major roads, tunnels and intersections.
The map in Figure 47 also represents the complete Haze Watch system fully functioning. Pollution
samples were correctly taken by the mobile sensor, measurements were uploaded in real time via the
3G network and were correctly stored on the database for visualisation maps to use. The Smart Phone
was easily interfaced with the wireless sensor board which ran continuously without any further user
input for the entire experiment. The Smart Phone correctly extracted the voltage readings from the
messages sent by the sensor board and converted these into equivalent pollution readings. The Smart
Phone then recorded the GPS location and uploaded the samples to the server. The database
functioned flawlessly in receiving multiple pollution readings continuously for over one and a half
hours. The visualisation maps were able to convert these pollution readings into an appropriate
overlay colour and display them on Google maps.
Figure 47 ‐ Carbon Monoxide Readings Plotted on a Visualisation Map [5]
44
The second part of this experiment was to test the iPhone application and effectiveness of more data
samples when calculating an estimated pollution reading using the air pollution model. The iPhone
application produced two personal exposure readings for the same route which are shown in Figure
48. The green plot in Figure 48 is the first exposure calculated by the iPhone application based on
fixed air monitoring sites only. The orange plot in Figure 48 was the second exposure estimation
based on all measurements including samples taken by the wireless sensor board. The blue plot in
Figure 48 is the measurements taken by the commercially available GasAlertMicro 5.
As shown in Figure 48 there is a considerable difference in the estimation by the iPhone application
when differing input data is used. When only the fixed air monitoring sites are used a slow varying
estimation of exposure is produced. This is mainly due to two reasons. Firstly the fixed air monitoring
sites are only updated every hour and secondly the location of the fixed sites are in suburban areas
which have low air pollution concentrations. This has a significant impact on the accuracy of the
estimation of an individual’s personal exposure. Without the ability of the fixed air monitoring sites to
identify specific areas which have high levels of air pollution, an individual’s true air pollution
exposure can not be estimated with any accuracy or reliability.
The orange plot in Figure 48 is a much closer approximation to an individual’s true air pollution
exposure compared to the exposure calculated with only the fixed air monitoring sites. This
demonstrates the need for more data samples required by the air pollution model to accurately
represent realistic air pollution concentrations. The orange plot is much closer to the individual’s true
exposure due to several reasons. Firstly far more data samples (over 50) were used in computing the
orange estimation compared to only the 5 used for the green estimation. Secondly these data
samples were taken from a wider range of locations, including areas of high concentrations. Most of
the samples that were used for the orange estimation were taken by the wireless sensor board while
on a busy road, intersection or in a tunnel. This gives a more realistic representation of a commuter’s
exposure as individuals would also be exposed to these high concentrations. With the air pollution
model using the samples taken from the wireless sensor board the various fluctuations in the
individual’s exposure is better represented.
Figure 48 ‐ Comparison of Carbon Monoxide Estimations from Experiment 2
45
The discrepancy between the orange plot and the blue plot in Figure 48 can also be explained. The
individual’s true exposure was represented by the measurements the GasAlertMicro 5 device
recorded throughout the route. This commercially available device is not as sensitive compared to the
wireless sensor board to low concentrations and only registers readings for concentrations above
5ppm. This is evident as for most of the route the GasAlertMicro 5 device recorded a zero
concentration reading. Furthermore due to the fundamental problem of GPS not working inside
tunnels, the samples that the wireless sensor board recorded inside the tunnels are recorded as
readings at the last known GPS location which is at the beginning of the tunnel. This explains the
difference in time between the peaks in Figure 48 at 2.09pm for the iPhone application estimation
and at 2.15pm for the true exposure. When the iPhone application requests an air pollution
estimation at the location just before the tunnel, the air pollution model uses the high concentration
samples that the wireless sample board recorded inside the tunnel. This results in the iPhone
application producing peaks prematurely compared to the true exposure measurements.
The comparison between Figure 47 and Figure 49 further illustrate the need for the wireless sensor
board in improving the representation of air pollution in visualisation maps. Figure 47 uses all the data
collected from the wireless sensor board and the fixed air monitoring sites to determine the overlay
for the visualisation map. Figure 49 is a visualisation map that was determined only using the fixed air
monitoring sites. There is significant difference in the detail between the two figures, with specific
regions of high concentration only identified when the wireless sensor was used. When only the fixed
air monitoring sites were used, the complete overlay is roughly the same value everywhere, indicating
a constant air pollution level for all of Sydney. As both experiment 1 and experiment 2 have clearly
shown this is incorrect and air pollution can vary significantly in different locations around Sydney.
Figure 49 ‐ Visualisation Map of Experiment 2 with only Fixed Air Monitoring Sites [5]
46
7. Discussion As a result of the previous experiments a lot of information can be taken from the Haze Watch project
and in particular the need for a device such as the wireless sensor board. From the first experiment it
was evident that the wireless sensor board can measure both carbon monoxide and nitrogen dioxide
levels with enough detail to be able to identify areas of high air pollution. From this experiment it was
also very clear that there is a major problem with the current air monitoring system in use in Sydney.
The 14 fixed air monitoring sites around Sydney are too far apart, resulting in lack of data required to
accurately calculate the level of air pollution between locations.
Experiment 1 showed that the location of these fixed sites is also a major concern. These sites are
located in suburban areas away from any main roads or intersections and as a result rarely record
high pollution readings. This means that the estimation for the air pollution around any main road or
intersection is significantly less than the true pollution concentration. The results of experiment 1
demonstrated that the air pollution around major tunnels, roads and intersections is significantly
greater than suburban areas. Furthermore these results also illustrated the need for a more detailed
air monitoring system to truly represent these large changes in air pollution between small changes in
location.
Experiment 2 demonstrated the functioning of the complete Haze Watch system from the mobile
wireless sensor, to the Smart Phone uploading samples in real time, to the visualisation maps
correctly and quickly turning these samples into easily interpreted and understood overlays for
Google Maps. Experiment 2 showed how the iPhone application can give an estimated personal
exposure reading from just a GPS trace. Through this application the need for a more detailed air
monitoring system was realised. The exposure calculations created by the iPhone application varied
significantly when only the fixed air monitoring sites were used compared to when samples from the
wireless sensor board were also used. When the data from the wireless sensor board was also used in
the exposure calculations, the iPhone personal exposure estimation was a much closer representation
of the individual’s true pollution exposure as determined by a commercial air monitoring device.
As can be easily seen from Figure 50, there is a significant difference in the output of the air pollution
model when samples from the wireless sensor board are also used. Map 1 in Figure 50 is the output
of the air pollution model when only the readings from the fixed air monitoring sites are used. Map 2
is the output of the air pollution model when over 50 samples from the wireless senor board around
Sydney were also used.
Figure 50 ‐ Comparison of Visualisation Maps: (1) With only Fixed Site samples and (2) Samples from the Wireless Sensor Board (2) [5]
47
From all of the results in both experiments the need for a more detailed air monitoring system such as
Haze Watch can be seen clearly. Having mobile sensors collecting far more samples than just the fixed
air monitoring sites maintained by the government brings huge benefits. With more pollution
readings taken in more locations, a more realistic representation of air pollution can be modelled. Air
pollution varies considerably in different locations and a more detailed monitoring system is required
to correctly model air pollution. With a more accurate air pollution model, applications such as the
iPhone personal pollution exposure application will produce more reliable results, closer to the
individual’s true air pollution exposure. Furthermore the visualisation maps are more useful and
accurate with more data samples in more locations. It can be concluded that there is real need for a
device such as the wireless sensor board.
48
8. Future Developments The Haze Watch project is only in its initial stages. There is still far more research to be done and
developments made to expand this project. In particular there are many aspects of the wireless
sensor board that could be improved to further improve the overall performance of the device:
The accuracy of the gas sensors
The calibration methods for the gas sensors
Adding different gas sensors to the wireless sensor board
Battery performance
The external casing of the wireless sensor board
Easy mounting system for attaching to cars
The best position to mount the wireless sensor board
Reducing the overall costs to produce a complete unit
Effects of temperature and speed on pollution readings
Creating a complete stand alone wireless sensor phone independent of Smart Phones
There were a range of different sensing technologies that could have been used for the wireless
sensor board, as discussed earlier in the design overview section (page 14). The current wireless
sensor board design uses metal oxide semiconductor gas sensors as they are small, cheaper and
easier to use than electrochemical sensors. However electrochemical sensors are far more accurate
and are the most popular sensing technology used in commercial devices such as the GasAlertMicro 5.
Before the Haze Watch project is to expand with more mobile sensor devices it would be strongly
recommended to further investigate the trade‐off between accuracy and cost between the two
sensor technologies. Furthermore it would also be recommended investigating if a system which had
lower quality sensors but more devices is more beneficial than having fewer mobile sensors which are
more accurate.
The calibration of the gas sensors poses the greatest challenge for the long term outcome of the
wireless sensor board. The current calibration techniques used for calibrating the sensors on each unit
are not completely accurate and are the main cause of incorrect pollution readings throughout the
conducted experiments. As discovered in experiment 1, due to the calibration equations not correctly
representing the response of the sensors, exaggerations of air pollution concentrations were
occurring at high concentrations. If significantly more sensor boards were to be produced it would be
recommended to invest in a commercially used calibration machine. A calibration machine offers a
more controlled and accurate recording of air pollution concentrations. This would offer a far more
accurate method for calibrating the gas sensors. Furthermore another challenge faced by the Haze
Watch project is the constant need for recalibration of gas sensors. Unfortunately due to the nature
of the components, gas sensors change over time, resulting in sensors requiring recalibration every
few months.
Currently the wireless sensor board only has three gas sensors incorporated into its design: carbon
monoxide, nitrogen dioxide and ozone. For a complete air monitoring system to be useful other
important toxic pollutants would also have to be monitored. This would include sulphur dioxide and
particulate matter, one of the more dangerous air pollutants. Currently the sensing technology for
these pollutants is not advanced enough for sensors of these pollutants to be placed on the wireless
sensor board. However once a sensor able to measure these pollutants and suitable for use on the
wireless sensor board is produced, it would not require too much redesigning of the sensor board to
incorporate these sensors.
49
Currently the wireless sensor is only able to last just over 20 hours under constant operation on a
single battery charge. This does equate to over a full weeks worth of operating at the average usage
specifications. However the process of having to recharge the batteries at the end of every week is
very inconvenient for the end user. If the wireless sensor was to further develop, more research and
experimentation would have to be undertaken on increasing the battery performance. Incorporating
a rechargeable circuit into the wireless sensor board could also be investigated. This would minimise
the inconvenience placed on the user by having to remove the batteries in order to charge them.
Future designs of the wireless sensor board could also explore the possibility of hard wiring the power
supply of the sensor board into the car’s electronics, such that no batteries are required.
The external casing of the wireless sensor board plays an important role in the overall protection and
endurance of each unit. The external casing needs to be designed to allow the gas sensors to be
exposed to the outside air whilst making sure it is also waterproof to ensure the electrical circuit or
sensors are not damaged or destroyed. Design of the external casing faces the difficult challenge of
allowing air to flow through without letting water in. Currently the wireless sensor board’s external
casing is not waterproof, limiting the use of the sensor board to only dry conditions. Before any
further devices are to be made considerable time should be spent in specially designing and
manufacturing external cases.
Incorporated into the external case design could be a simple mounting system that could be used to
easily attach the wireless sensor board onto the exterior of a car. With an easy and quick attachment
mechanism user inconvenience would be minimised.
Another important issue that needs to be explored is the ideal location on a motor vehicle for the
wireless sensor to be located. The mounting position of the sensor board can have a significant
impact on the measurements that are recorded. If the device is located too close to road, the sensor
board would be exposed directly to the fumes from other vehicles, resulting in biased and unrealistic
measurements.
To improve the overall accuracy and quality of the measurements that the wireless sensor board
produces, all of the variables that can affect the air pollution readings need to be accounted for. With
a mobile air pollution device, both the outside temperature and speed of the vehicle need to be taken
into consideration. These issues require large amounts of research to calculate the direct correlation
between these variables and final results. The calibration equations would have to be reformulated to
account for these variables. A temperature and humidity sensor could be easily incorporated into the
wireless sensor board with small and compact modules currently commercially available. The speed of
the car could be easily determined through calculations involving the difference in consecutive GPS
locations.
Finally the long term aims of the Haze Watch project are to have the sensor board devices deployed
on vehicles on the road for large periods of time. Ideally the sensor board would be attached to
vehicles such as buses or taxis that cover large amounts of geographical areas over long periods of
time. However in order for this to occur a new version of the wireless sensor board would have to be
created. A complete stand alone unit would need to be designed that requires no user input or
configuration in order to function. This involves the design of the wireless sensor board 2, which is
completely independent of the Smart Phone. Without the Smart Phone the wireless sensor board 2
would have to have its own GPS module to determine its location, a 3G or GSM module to upload
samples in real time, a more complex and powerful microprocessor that would be able to process all
this information and finally a hard wired power supply. The wireless sensor board 2 requires
significant developments from the wireless sensor board but should be able to be technically
achievable with current technology but with increased cost.
50
9. Conclusions
The presence of high air pollution which may impose serious risks on humans and on our environment
has been demonstrated throughout this report. It has been mentioned that there are 5 main air
pollutants that need to be monitored in order to obtain a realistic understanding of the dangers that
air pollution could cause. Several benefits from having a greater resolution of air pollution data have
been discussed including the several applications that may arise from such improvements.
This report has introduced the Haze Watch project and shown how it can significantly improve
Sydney’s air pollution monitoring system. Through the use of a network of mobile air pollution
sensors, database for all pollution samples, visualisation maps and an iPhone application it is believed
that the awareness of the risks and dangers about air pollution will be increased. With increased
awareness about air pollution in the public, improvements in the health of societies and
environments is expected.
The focus of this report was the fundamental problem with current air pollution monitoring systems
and the design of a mobile wireless sensor board. The design of the wireless sensor board was
thoroughly explained and every design decision justified. The various gas sensing technologies,
wireless communications, central processing units and power management were all critically
analysed. Several experiments were conducted using the wireless sensor board demonstrating the
need for a more detailed air monitoring system. The results of these experiments showed that air
pollution does vary significantly in different locations and can not be accurately or reliably estimated
using only the fixed air monitoring sites currently in use. The effectiveness of the wireless sensor
board in measuring various air pollutants and uploading samples to the server in real time via a Smart
Phone was shown. Furthermore the benefits of using the wireless sensor board for applications such
as the personal pollution exposure iPhone application and visualisation maps were realised.
This report and the current work undertaken by the Haze Watch project have formed the basis for a
mobile sensing system. The wireless sensor boards can be easily adapted to integrate most forms of
sensors including humidity, temperature, speed and moisture sensors to build a dense monitoring
system for various applications. With the current air pollution sensors integrated into the wireless
sensor board a more detailed and accurate representation of air pollution can be modelled. Through
this significant advancement in air pollution monitoring the general health and safety of humans and
surrounding environments can be improved.
51
10. Bibliography
[1] New South Wales Government. (2010, Jan.) New South Wales Government ‐ Health. [Online].
http://www.health.nsw.gov.au/PublicHealth/environment/air/air_pollution.asp
[2] World Health Organisation. (2006) World Health Organisation . [Online].
http://whqlibdoc.who.int/hq/2006/WHO_SDE_PHE_OEH_06.02_eng.pdf
[3] State Government of New South Wales. (2010, Apr.) Environment, Climate Change and Water.
[Online]. http://www.environment.nsw.gov.au/air/
[4] State Government of Victoria. (2008, Nov.) Better Health Channel. [Online].
http://www.betterhealth.vic.gov.au/bhcv2/bhcpdf.nsf/ByPDF/Pollution_air/$File/Pollution_air.pdf
[5] A. Chow, "Haze Watch: Data Modelling and Visualisation using Google Maps," University of New
South Wales Undergraduate Thesis, Oct. 2010.
[6] N. Youdale, "Haze Watch: Database Server and Mobile Applications for Measuring and Evaluating
Air Pollution Exposure," University of New South Wales Undergraduate Thesis, 2010.
[7] Delphian Corporation. (2010) Delphian. [Online]. http://www.delphian.com/sensor‐tech.htm
[8] L. Peeples. (2009, Sep.) Scientific American. [Online].
http://www.scientificamerican.com/article.cfm?id=air‐pollution‐monitoring‐sensor‐asthma‐black‐
carbon&page=2
[9] Mazzarello Media and Arts. (2009) Community Sensing. [Online].
http://www.communitysensing.org/
[10] Mobile Environmental Sensing System Across Grid Environments. (2008) Mobile Environmental
Sensing System Across Grid Environments. [Online]. http://bioinf.ncl.ac.uk/message/
[11] P. V. A. L. e. a. W. Hedgecock, "Mobile Air Pollution Monitoring Network," in Symposium on
Applied Computing. New York: Association for Computing Machinery, 2010, pp. 795‐796.
[12] J. Colls, "Air Pollution," in Air Pollution. London: Spon Press, 2002, pp. 1‐224.
[13] E. Health, "Air Pollution Health Alerts," in Air Pollution Health Alerts ‐ What They Mean To You.
Sydney: New South Wales Government, 2004, pp. 1‐2.
[14] Honeywell. (2010, May) BW Technologies. [Online]. http://www.gasmonitors.com/
[15] Intel. (2010, May) Common Sense ‐ Mobile Sensing for Community Action. [Online].
http://www.communitysensing.org/index.php
[16] Institute for Software Integrated Systems. (2008, Jan.) Mobile Air Quality Monitoring Network.
[Online]. http://www.isis.vanderbilt.edu/projects/maqumon
[17] Programmer PIC16F84. (2007, Oct.) How to Make Programmer PIC16F84. [Online].
52
http://programmer‐pic16f84.blogspot.com/2007/10/how‐to‐make‐programmer‐pic16f84.html
[18] Sparkfun Electronics. (2010, Jan.) Sparkfun Electronics. [Online]. http://www.sparkfun.com
[19] e2v. (2010, Jan.) Technology Solutions for High Performance Systems. [Online].
http://www.e2v.com/
[20] e2v. (2008, Jan.) MiCS‐2610 O3 Sensor Datasheet . Datasheet.
[21] Adeunis RF. (2007, Aug.) ARF32 Bluetooth Modules ‐ User Guide. Datasheet.
[22] M. D. W. a. A. W. H. H. Mr Leon Dearden. (2009, Sep.) Printed Circuit Board Design. Lecture Notes.
[23] smallpower.com. (2009, Jun.) NiMH BATTERY FREQUENTLY ASKED QUESTIONS. [Online].
http://4gdo.com/batfaq.htm
[24] Honeywell. (2010) GasAlertMicro 5. Image.
[25] Common Sense. (2009) Mobile Sensing for Community Action ‐ Handheld Device. Image.
[26] C. Woodford. (2008) Explain That Stuff. [Online].
http://www.explainthatstuff.com/airpollution.html#cars
53
11. APPENDICES
54
11.1 Appendix I
55
� 2008 Microchip Technology Inc. DS41262E-page 1
PIC16F631/677/685/687/689/690
High-Performance RISC CPU:• Only 35 Instructions to Learn:
- All single-cycle instructions except branches• Operating Speed:
- DC – 20 MHz oscillator/clock input- DC – 200 ns instruction cycle
• Interrupt Capability• 8-Level Deep Hardware Stack• Direct, Indirect and Relative Addressing modes
Special Microcontroller Features:• Precision Internal Oscillator:
- Factory calibrated to ± 1%- Software selectable frequency range of
8 MHz to 32 kHz- Software tunable- Two-Speed Start-up mode- Crystal fail detect for critical applications- Clock mode switching during operation for
power savings• Power-Saving Sleep mode• Wide Operating Voltage Range (2.0V-5.5V)• Industrial and Extended Temperature Range• Power-on Reset (POR)• Power-up Timer (PWRTE) and Oscillator Start-up
Timer (OST)• Brown-out Reset (BOR) with Software Control
Option• Enhanced Low-Current Watchdog Timer (WDT)
with On-Chip Oscillator (Software selectable nominal 268 Seconds with Full Prescaler) with Software Enable
• Multiplexed Master Clear/Input Pin• Programmable Code Protection• High Endurance Flash/EEPROM Cell:
- 100,000 write Flash endurance- 1,000,000 write EEPROM endurance- Flash/Data EEPROM retention: > 40 years
• Enhanced USART Module:- Supports RS-485, RS-232 and LIN 2.0- Auto-Baud Detect- Auto-wake-up on Start bit
Low-Power Features:• Standby Current:
- 50 nA @ 2.0V, typical• Operating Current:
- 11 μA @ 32 kHz, 2.0V, typical- 220 μA @ 4 MHz, 2.0V, typical
• Watchdog Timer Current:- <1 μA @ 2.0V, typical
Peripheral Features:• 17 I/O Pins and 1 Input-Only Pin:
- High current source/sink for direct LED drive- Interrupt-on-Change pin- Individually programmable weak pull-ups- Ultra Low-Power Wake-up (ULPWU)
• Analog Comparator Module with:- Two analog comparators- Programmable on-chip voltage reference
(CVREF) module (% of VDD)- Comparator inputs and outputs externally
accessible- SR Latch mode- Timer 1 Gate Sync Latch- Fixed 0.6V VREF
• A/D Converter:- 10-bit resolution and 12 channels
• Timer0: 8-bit Timer/Counter with 8-bit Programmable Prescaler
• Enhanced Timer1:- 16-bit timer/counter with prescaler- External Timer1 Gate (count enable)- Option to use OSC1 and OSC2 in LP mode
as Timer1 oscillator if INTOSC mode selected
• Timer2: 8-bit Timer/Counter with 8-bit Period Register, Prescaler and Postscaler
• Enhanced Capture, Compare, PWM+ Module:- 16-bit Capture, max resolution 12.5 ns- Compare, max resolution 200 ns- 10-bit PWM with 1, 2 or 4 output channels,
programmable “dead time”, max frequency 20 kHz
- PWM output steering control• Synchronous Serial Port (SSP):
- SPI mode (Master and Slave)• I2C™ (Master/Slave modes):
- I2C™ address mask• In-Circuit Serial ProgrammingTM (ICSPTM) via Two
Pins
20-Pin Flash-Based, 8-Bit CMOS Microcontrollers withnanoWatt Technology
11.2 Appendix 2
56
unsigned char Software_version = 0x01; // version 1unsigned char board_identifierH = 0x03;unsigned char board_identifierL = 0xEC; //Board Identify 1004
unsigned char sensor_count = 0x03; // 3 sensors on unit
unsigned char Ref_VoltageH = 0x14;unsigned char Ref_VoltageL = 0xAE ; // Reference Voltage = 3.33 Voltsunsigned char Number_ofSamples = 0x0A;
unsigned char Ozone = 1;unsigned char Nitrogen_Dioxide = 1;unsigned char Carbon_Monoxide = 1;
unsigned char Sensor_Location1 = 1; // Ozoneunsigned char Sensor_Location2 = 2; // Nitrogen Dioxideunsigned char Sensor_Location3 = 3; // Carbon Monoxide
//************ For Sensor 1 - Ozone ****************//// uncalibrated //
unsigned char Sensor1_C0_Byte1 = 0x00;unsigned char Sensor1_C0_Byte2 = 0x00;
unsigned char Sensor1_C1_Byte1 = 0x00;unsigned char Sensor1_C1_Byte2 = 0x00;
unsigned char Sensor1_C2_Byte1 = 0x00;unsigned char Sensor1_C2_Byte2 = 0x00;
//************ For Sensor 2 - Nitrogen Dioxide **********//// 1.0082x^2 - 0.4234x + 0.4416 //
unsigned char Sensor2_C0_Byte1 = 0x3F;unsigned char Sensor2_C0_Byte2 = 0x0B;
unsigned char Sensor2_C1_Byte1 = 0xE5;unsigned char Sensor2_C1_Byte2 = 0x1B;
unsigned char Sensor2_C2_Byte1 = 0x1B;unsigned char Sensor2_C2_Byte2 = 0xAB;
//************ For Sensor 3 - Carbon Monoxide **********//// 545.74x^2 - 164.24x + 11.738 //
unsigned char Sensor3_C0_Byte1 = 0x22;unsigned char Sensor3_C0_Byte2 = 0x2C;
unsigned char Sensor3_C1_Byte1 = 0x99;unsigned char Sensor3_C1_Byte2 = 0x6B;
unsigned char Sensor3_C2_Byte1 = 0x49;unsigned char Sensor3_C2_Byte2 = 0x6A;
11.3 Appendix 3Constant Declaration File for Unit 1004
57
#include <htc.h>#include "Unit1004.h"
__CONFIG(MCLREN & UNPROTECT & BORDIS & WDTDIS & PWRTEN & INTIO); //configuration code for the microchip
void delayus(unsigned char);void delayms(unsigned char);void delaysecond(unsigned char);void onesec (void);void SendVoltage(unsigned char dataValue,unsigned char SensorID,unsigned char SampleNo );void SendUART(unsigned char dataValue);void SendUART_checksum(unsigned char dataValue);void SetupUART(void);void SendSensorID ( unsigned char SensorID);void SendSensorConstants(void);void SendHeader(void);void SendFooter(void);unsigned char check_battery (void);
unsigned char checksum = 0x00;
void main(){
unsigned char Sensor1;unsigned char Sensor2;unsigned char Sensor3;
unsigned char voltage1;unsigned char voltage1_one;unsigned char voltage1_two;unsigned char voltage1_three;unsigned char voltage1_four;unsigned char voltage1_five;unsigned char voltage1_six;unsigned char voltage1_seven;unsigned char voltage1_eight;unsigned char voltage1_nine;unsigned char voltage1_ten;
unsigned char voltage2;unsigned char voltage2_one;unsigned char voltage2_two;unsigned char voltage2_three;unsigned char voltage2_four;unsigned char voltage2_five;unsigned char voltage2_six;unsigned char voltage2_seven;unsigned char voltage2_eight;unsigned char voltage2_nine;unsigned char voltage2_ten;
unsigned char voltage3;unsigned char voltage3_one;unsigned char voltage3_two;unsigned char voltage3_three;unsigned char voltage3_four;unsigned char voltage3_five;
58
unsigned char voltage3_six;unsigned char voltage3_seven;unsigned char voltage3_eight;unsigned char voltage3_nine;unsigned char voltage3_ten;
unsigned char counter = 1;unsigned char battery_status;
ANSEL = 0b00001111; // setting pins RA1 and RA0 as analogue inputsANSELH = 0b00000000;TRISA = 0b00011111; // setting pins RA1 and RA0 as inputsTRISB = 0b00000000; // Setting all of PORTB as outputs TRISC = 0b00000000; // Setting all of PORTC as outputs andADON = 1; // Enable the ADCSetupUART(); // Set up the UART
PORTC = 0b00000000;
while (1){
counter = 1; RC0 = 0; battery_status = check_battery();
while(counter<=10){ RC1 = 0; if(battery_status == 0x00 && ( counter == 2 || counter == 4 || counter == 6 || counter == 8 || counter == 10 )){ RC1 = 1; }
ADFM = 0; // setting the format of the ADC conversion VCFG = 0; // setting the voltage reference at Vdd ADCON0 = 0b00000011; // setting ADC on pin RA0 and starting the conversion
ADCON0 = 0b00000011; // setting ADC on pin RA0 and starting the conversion while ( ADCON0 == 0b00000011) { // wait for conversion process to finish for sensor 1\ }
Sensor1 = ADRESH; delaysecond(1);
ADCON0 = 0b00000111; // setting ADC on pin RA1 and starting the conversion while ( ADCON0 == 0b00000111) { // wait for conversion process to finish for sensor 2 } Sensor2 = ADRESH; //PORTC = voltage2; // display voltage reading on LED's delaysecond(1);
ADCON0 = 0b00001011; // setting ADC on pin RA2 and starting the conversion while ( ADCON0 == 0b00001011) { // wait for conversion process to finish for sensor 3 } Sensor3 = ADRESH;
if (Sensor_Location1 == 1){ voltage1 = Sensor1; } else if(Sensor_Location1 == 2){ voltage2 = Sensor1; }
59
else if(Sensor_Location1 == 3){ voltage3 = Sensor1; }
if (Sensor_Location2 == 1){ voltage1 = Sensor2; } else if(Sensor_Location2 == 2){ voltage2 = Sensor2; } else if(Sensor_Location2 == 3){ voltage3 = Sensor2; }
if (Sensor_Location3 == 1){ voltage1 = Sensor3; } else if(Sensor_Location3 == 2){ voltage2 = Sensor3; } else if(Sensor_Location3 == 3){ voltage3 = Sensor3; }
if (counter == 1){ voltage1_one = voltage1; voltage2_one = voltage2; voltage3_one = voltage3; }
if (counter == 2){ voltage1_two = voltage1; voltage2_two = voltage2; voltage3_two = voltage3; }
if (counter == 3){ voltage1_three = voltage1; voltage2_three = voltage2; voltage3_three = voltage3; }
if (counter == 4){ voltage1_four = voltage1; voltage2_four = voltage2; voltage3_four = voltage3; }
if (counter == 5){ voltage1_five = voltage1; voltage2_five = voltage2; voltage3_five = voltage3; }
if (counter == 6){ voltage1_six = voltage1; voltage2_six = voltage2; voltage3_six = voltage3; }
if (counter == 7){ voltage1_seven = voltage1; voltage2_seven = voltage2;
60
voltage3_seven = voltage3; }
if (counter == 8){ voltage1_eight = voltage1; voltage2_eight = voltage2; voltage3_eight = voltage3; }
if (counter == 9){ voltage1_nine = voltage1; voltage2_nine = voltage2; voltage3_nine = voltage3; }
if (counter == 10){ voltage1_ten = voltage1; voltage2_ten = voltage2; voltage3_ten = voltage3; }
counter = counter + 1; battery_status = check_battery();}
// send data over USART RC1 = 0;
if (battery_status == 0x00){ //battery is above critical level RC2 = 1; // Turn Blue Led on to indicate sending status! }
checksum = 0x00; // reset the checksum
SetupUART();RB6 = 1; // Set Clear to Send to 1SendHeader();SendUART_checksum (Software_version);SendUART_checksum (board_identifierH);SendUART_checksum (board_identifierL);SendUART_checksum (sensor_count);SendSensorConstants();SendUART_checksum (Ref_VoltageH);SendUART_checksum (Ref_VoltageL);SendUART_checksum (Number_ofSamples);
//**** Voltages - One ******//SendVoltage (voltage1_one,1,1);SendVoltage (voltage2_one,2,1);SendVoltage (voltage3_one,3,1);
//**** Voltages - Two ******//SendVoltage (voltage1_two,1,2);SendVoltage (voltage2_two,2,2);SendVoltage (voltage3_two,3,2);
//**** Voltages - Three ******//
SendVoltage (voltage1_three,1,3);SendVoltage (voltage2_three,2,3);SendVoltage (voltage3_three,3,3);
61
//**** Voltages - Four ******//SendVoltage (voltage1_four,1,4);SendVoltage (voltage2_four,2,4);SendVoltage (voltage3_four,3,4);
//**** Voltages - Five ******//SendVoltage (voltage1_five,1,5);SendVoltage (voltage2_five,2,5);SendVoltage (voltage3_five,3,5);
//**** Voltages - Six ******//SendVoltage (voltage1_six,1,6);SendVoltage (voltage2_six,2,6);SendVoltage (voltage3_six,3,6);
//**** Voltages - Seven ******//SendVoltage (voltage1_seven,1,7);SendVoltage (voltage2_seven,2,7);SendVoltage (voltage3_seven,3,7);
//**** Voltages - Eight ******//SendVoltage (voltage1_eight,1,8);SendVoltage (voltage2_eight,2,8);SendVoltage (voltage3_eight,3,8);
//**** Voltages - Nine ******//SendVoltage (voltage1_nine,1,9);SendVoltage (voltage2_nine,2,9);SendVoltage (voltage3_nine,3,9);
//**** Voltages - Ten ******//SendVoltage (voltage1_ten,1,10);SendVoltage (voltage2_ten,2,10);SendVoltage (voltage3_ten,3,10);
SendUART(checksum);
SendFooter();RB6 = 0; // Set Clear to Send to 0delayms(100);;
RC2 = 0; // Turn off Blue Led to indicate not sending
}
}
void delayus(unsigned char delay){ while(delay--);}
void delayms(unsigned char delay){ while(delay--){ delayus(149); }}
void onesec (void){delayms(254);delayms(254);
62
delayms(254);delayms(254);}
void delaysecond(unsigned char seconds){
while (seconds > 0){onesec();seconds--;}}
void SendHeader(void){unsigned char x = 4; while (x > 0){ SendUART(0xFF); // 1 delayus(149); x = x - 1; }}
void SendFooter(void){unsigned char x = 4; while (x > 0){ SendUART(0xEE); // 1 delayus(149); x = x - 1; }}
void SetupUART(void){ SPBRGH = 0; SPBRG = 25; //9600 bps TXSTA = 0x24; //8-bit, Transmission enabled, High Speed RCSTA = 0x80; //Disable Reception, Enable UART module CREN = 0; //Disable receiver SREN = 0; BAUDCTL = 0; //8-bit, Auto Baud disabled }
void SendUART(unsigned char dataValue){ TXREG = dataValue; //Start transmission delayms(200);}
void SendUART_checksum(unsigned char dataValue){ TXREG = dataValue; //Start transmission delayms(200); checksum = checksum + dataValue;}
void SendSensorID ( unsigned char SensorID){
if (SensorID == 1){ SendUART_checksum(0x01); // 1 delayus(149); }
if (SensorID == 2){ SendUART_checksum(0x02); // 2 delayus(149); }
63
if (SensorID == 3){ SendUART_checksum(0x03); // 3 delayus(149); }delayms(20);
}
void SendVoltage(unsigned char dataValue,unsigned char SensorID,unsigned char SampleNo ){ if(SampleNo <= Number_ofSamples){ if((SensorID == 1 && Ozone == 1) || (SensorID == 2 && Nitrogen_Dioxide == 1) || (SensorID == 3 && Carbon_Monoxide ==1)){ SendSensorID(SensorID); SendUART_checksum (dataValue); } }}
void SendSensorConstants ( void){
if (Ozone == 1){ SendSensorID(1); SendUART_checksum (Sensor1_C0_Byte1); SendUART_checksum (Sensor1_C0_Byte2); SendUART_checksum (Sensor1_C1_Byte1); SendUART_checksum (Sensor1_C1_Byte2); SendUART_checksum (Sensor1_C2_Byte1); SendUART_checksum (Sensor1_C2_Byte2); } if (Nitrogen_Dioxide == 1){ SendSensorID(2); SendUART_checksum (Sensor2_C0_Byte1); SendUART_checksum (Sensor2_C0_Byte2); SendUART_checksum (Sensor2_C1_Byte1); SendUART_checksum (Sensor2_C1_Byte2); SendUART_checksum (Sensor2_C2_Byte1); SendUART_checksum (Sensor2_C2_Byte2); } if (Carbon_Monoxide == 1){ SendSensorID(3); SendUART_checksum (Sensor3_C0_Byte1); SendUART_checksum (Sensor3_C0_Byte2); SendUART_checksum (Sensor3_C1_Byte1); SendUART_checksum (Sensor3_C1_Byte2); SendUART_checksum (Sensor3_C2_Byte1); SendUART_checksum (Sensor3_C2_Byte2); } }
unsigned char check_battery (void){ unsigned char status; unsigned char batt_level = 0xA0;
ADCON0 = 0b00001111; // setting ADC on pin RA4 and starting the conversion while ( ADCON0 == 0b00000011) { // wait for conversion process to finish for sensor 1 } ADCON0 = 0b00001111; // setting ADC on pin RA4 and starting the conversion while ( ADCON0 == 0b00000011) { // wait for conversion process to finish for sensor 1 }
ADCON0 = 0b00001111; // setting ADC on pin RA4 and starting the conversion while ( ADCON0 == 0b00001111) { // wait for conversion process to finish for sensor 1
64
}
status = ADRESH;
if (status < batt_level){ // battery below critical level RC0 = 1; return(0x01); } if (status > batt_level){ // battery above critical level RC0 = 0; return(0x00); }return(0x00);}
65