You are on page 1of 5

CONSTRUCTION OF A RASPBERRY PI-BASED DATA STORAGE AND RETRIEVAL –

CAPABLE AIR POLLUTION DATALOGGER
G.A.G. FABIA & L.M.N. CRUZ
CATEGORY: COMPUTATIONAL SCIENCE
SUBCATEGORY: COMPUTER SCIENCE, ELECTRIC AND ELECTRONICS ENGINEERING
REGION, CITY/MUNICIPALITY: REGION III, CLARK FREEPORT ZONE
CORRESPONDING AUTHOR’S EMAIL: giandreifabia@gmail.com

ABSTRACT
Information gathering and dissemination is important in air pollution mitigation. Existing information
gathering methods are limited and may be too complex for citizen science. Government data can be unlocalized,
vague, and complicated. Previous open-source air pollution dataloggers lack a comprehensive documentation;
contain a minimal amount of sensors, or datalog on a intermittent basis. This project aims to provide air pollutant
data (APD) through a datalogger built on Raspberry Pi hardware and open-source software with cloud storage
capabilities, an expandable base amount of sensors, and real-time data logs. Necessary equipment was acquired. An
iterative design loop followed, where designs were continuously revised. Sensors for light levels, temperature,
relative humidity, carbon monoxide and carbon dioxide concentrations were wired to an externally powered
Raspberry Pi. The sensors accessed it through its GPIO pins and an analog to digital converter, if the sensor sends
out analog values. The Pi was then programmed to read sensor data. Data was then passed to a GSpread script to
log sensor data. The data can then be viewed over the Internet or through the Pi’s files. After the alpha version was
completed, the sensors were subjected to accuracy tests by running the device beside a standard air quality monitor,
exposing the sensors to quantized amounts of substances they sense and comparing the resulting data using the ttest for two independent samples. The beta model was then completed and debugged. The Raspberry Pi can be
utilized to construct a working air pollution datalogger.

INTRODUCTION
Air pollution is an environmental problem
that affects people globally, regardless of geopolitical
situation or socioeconomic status. It needs to be
addressed urgently, especially now when pollution
sources are everywhere, from factories and
commercial establishments, to cars and households
worldwide. According to a World Health
Organization (WHO) press release dated 25 March
2014, one in eight global deaths in the year 2012
resulted from exposure to air pollution.
To be able to take action, the public needs to
be informed about this looming global threat.
Information about air pollution, however, isn't easy to
obtain. Localized data from the government is
unreliable for small or isolated locales and other
places not yet covered by air pollution monitoring
programs. Current major real-time air quality
forecasting techniques have limitations (Baclanov,
Bocquet, Mallet, Seigeur & Zhang, 2012), and most
are too complicated or tedious to be performed by

citizen scientists. A possible way of informing the
public is to bring the data to them — that is, to
provide them with a means to collect and transmit air
pollution data that they can monitor.
Some attempts have been made to provide
this means; one is the Air Quality Egg from
Sensemakers, which is a small, stationary, cloudcapable hobbyist datalogger with sensors for nitrous
oxide and carbon dioxide. Some concerns have been
raised on multiple issues, among them compatibility,
durability and design (Kickstarter, 2012) (Hart-Davis,
2013). Another is iKair, which has a wider variety of
sensors, powered by proprietary software. Concerns
have been raised by multiple parties concerning the
neutrality of the data produced by iKair to
government interference (The Wall Street Journal,
2014) (International Business Times, 2014).
The goal of this study is to create an air
pollution datalogger built on the Raspberry Pi
platform capable of storing and retrieving real-time
data.
1

The product of this revision is called the alpha revision. The QRO-401 Automotive Emissions Analyzer 2 . The outputs were converted to parts per million so that comparisons to the testing apparatus could be made. This ratio was then used to look up the equivalent amount in parts per million using a sensitivity characteristic curve. In this iteration of the study. The alpha revision’s code was thoroughly searched for software bugs and errors through tracing the print statements created by the software. an HDMI enabled monitor screen. and revised to remove potential bugs. Designs for the device will again be drafted. In this study. Equipment included a Raspberry Pi Model B computer. The following is the sensitivity characteristic curve for the MQ-7 sensor. The beta revision’s code will again be thoroughly searched for software bugs and errors through tracing the software’s print statements. The resulting revision will be then assembled for testing. ??? is the voltage of the load resistance. carbon dioxide and carbon monoxide levels. an SD card with at least 8 gigabytes (GB) of memory. implemented and revised in a second iterative design loop to remove potential bugs. implemented by building and operating the design.METHODOLOGY Prototyping equipment was acquired. and ?? is the circuit voltage of the sensor. producing the beta revision. the QRO Tech QRO401 Automotive Emissions Analyzer was used as a standard device. a Type A USB keyboard and mouse. a DHT22 / AM2302 measured temperature and humidity. Designs for the device will be drafted. a process similar to the debugging of the alpha revision. an MQ7 measured carbon dioxide levels. Both devices gathered data simultaneously. The MQ7 sensitivity characteristic curve Figure 1. a Pi Cobbler board and cable. The initial output from both sensors are in millivolts (mV). The sensor resistance was obtained using the following formula: ?? = (?? − ??? )(?? ) ??? Where ?? is the surface resistance of the sensor in gas. Figure 2. a USB keyboard and mouse. A test vehicle idled in order to be tested by both the standard and the device. This was divided by the surface resistance of the ? sensor in clean air ( ? ) to obtain the change ratio of ?? sensor resistance. The project then entered an iterative design loop. ?? is the load resistance of the sensor. solder and soldering iron. and sensors for light levels. a 5 volt Micro B USB power source. temperature and humidity. The device was powered on and prepared to gather data. The device was tested beside an emissions testing apparatus. and a MQ135 measured carbon monoxide concentrations.

f.3 10000 11:56:49 12/4/2014 42459. = 13).f. d. is 13.3 % 11:57:30 12/4/2014 12364.3 % 11:57:35 12/4/2014 12364. To confirm a hypothesis. The statistical hypotheses are: Null There is no significant difference between the means of the data.6 11200 90.2 10000 11:56:44 12/4/2014 42459.761.f.6 12400 100. = 13 is 1.3 % 11:57:25 12/4/2014 12364. therefore. Alternative The means of the data are significally different from each other.6 % 23. The value for the MQ7 measurements is 0. the sensor’s data isn’t consistent with actual readings. therefore.3 % 11:56:45 12/4/2014 12364.This is the sensitivity characteristic curve for the MQ135 sensor.3 % 11:57:40 The critical values for α = 0.6 12400 100. the t-test for two independent samples will be used.3 % 11:57:10 12/4/2014 12364.5 % 23.6 11200 90. The means. the sensor’s readings are consistent with the actual readings.6 12400 100.6 12400 100.3 % 11:57:05 12/4/2014 12364. Table 2: MQ135 test run results Timestamp MQ135 QRO-401 readings readings (ppm) (ppm) 12/4/2014 37681. from which conclusions were made.05. The readings from the datalogger were compared to readings from the testing apparatus through the t-test for two independent samples. Timestamp MQ7 % QRO-401 Precision readings readings (ppm) (ppm) 12/4/2014 12364. the sensor’s readings are consistent with the actual readings.6 12400 100.3 % 11:57:00 12/4/2014 12364. MQ-135 sensitivity characteristic curve.3 % 11:56:55 12/4/2014 12364.3 10000 % Precision 26.6 11200 90. The null hypothesis ?1 ?2 fail to be accepted if is less than the The t-value will be compared to the appropriate critical value (? = 0.761.6% 11:56:40 12/4/2014 12364. therefore the null hypothesis is accepted.6 12400 100.051630.6 12400 100.6 12400 100.6% 11:56:50 12/4/2014 12364.6 % 3 . RESULTS AND DISCUSSION The following contains data from the test runs: Figure 3.6 11200 90.6 12400 100.05 and d.6 % 11:56:35 12/4/2014 12364. Table 1: Carbon Monoxide sensor (MQ7) results.critical value.6 12400 100.3 % 11:57:20 12/4/2014 12364. number of samples and standard deviations from the two sets of values will be plugged into the following equation: ?1 − ?2 ?= will be compared with the? 2critical ?22 value when and √ 1 +will d.6% 11:57:15 12/4/2014 12364. which is less than 1.

6% 12:02:50 12/4/2014 12:02:55 12/4/2014 12:03:00 12/4/2014 12:03:05 12/4/2014 12:03:10 26. the sensor may not be reliable for accurate measurements in the long term.3 10000 23.5% Possible sources of error are data handling issues with the Raspberry Pi.6 % 42459.8°C 52. the higher its temperature becomes due to the heating coil used to reset the device.9 10000 23.6 % 42459.7 % 42459.4% 12:02:35 12/4/2014 26.2°C 54. The longer the sensors are operated.9°C 51.11:56:54 12/4/2014 11:56:59 12/4/2014 11:57:04 12/4/2014 11:57:09 12/4/2014 11:57:14 12/4/2014 11:57:19 12/4/2014 11:57:24 12/4/2014 11:57:29 12/4/2014 11:57:34 12/4/2014 11:57:39 12/4/2014 11:57:44 12/4/2014 11:57:49 42459.1% 12:02:15 12/4/2014 27. to refrain from using the MQ135 sensor for CO2 datalogging with the Raspberry Pi. which is greater than 1.0 % 42456. It is recommended to replicate the project using more accurate sensors.6 % 37889. Also.3 30000 70.0 % 42459. upon installation of various libraries and modules.8°C 51.9% 26.7 % 42459. CONCLUSION The Raspberry Pi.0 % 38268.3 31000 73.9% 12:02:00 12/4/2014 27.3 10000 23.0 % The t value for the MQ135 measurements is 6.3 10000 26. since Python documentation for integrating libraries is minimal.5% 12:02:05 12/4/2014 27.6 31000 81.0% 12:02:20 12/4/2014 27.4% 12:02:40 12/4/2014 26. its accuracy is limited depending on the sensors used to implement it. but it is difficult to express their data in parts per million because that output depends on “clean air” measurements and temperature data from the DHT22. The data from both MQ7 and MQ135 can be readily expressed in millivolts or ohms.2°C 53. to integrate the datalogging libraries and code into a single file or library.761. the sensor’s data isn’t consistent with actual readings. Thus.348.0 % 42456.0% 12:02:45 12/4/2014 26. This longterm inaccuracy is caused by the influence of the temperature of the sensors to their readings.8% 26.9°C 51.2°C 53.9°C 51. these processes are contained and run separately.3 30000 70. the exposure of the sensors to excessive moisture and high temperatures from the exhaust pipe of the test vehicle. thus adversely influencing the readings.0% 12:02:25 12/4/2014 26.8°C 51. therefore the null hypothesis failed to be accepted.1°C 54. and to examine the reliability and accuracy of the device when deployed as a stationary datalogger.Short-term measurements from the MQ7 and the MQ135 sensors are accurate.0°C 53.8 31000 73. Timestamp Temperature Relative Humidity 12/4/2014 27.4 % 42456.8°C 51. Table 3: DHT22 test run. the scripts for both datalogging processes are not yet unified. can be utilized to construct a working air pollution datalogger. It is highly recommended to replicate this project using other sensors of possibly higher quality to ensure the integrity of the device. However.2% 26.3% 12:02:10 12/4/2014 27.9% 12:02:30 12/4/2014 26.9°C 52. Ambient temperature is at 27°C. 4 . This increase in temperature affects the sensitivity of the sensors.3 31000 73.9°C 51.8 31000 73.1°C 53.

MQ135/resources/SNSMQ135.). WHO | 7 million premature deaths annually linked to air pollution.uk/note-on-AirQuality-Egg-REVIEW. Mallet.).com/datasheets/Senso rs/Biometric/MQ-7.kickstarter.org/faqs International Business Times.Earth Notes. air pollution data . Retrieved from https://www. techniques.China real time report WSJ..edu/lab-researchsafety/laboratory-safetymanual/Pages/index.org/licenses The Wall Street Journal. A note on the Air Quality Egg (AQE): review . (n. Y. November 10). A.int/mediacentre/news/releas es/2014/air-pollution/en/ 5 . Atmospheric Environment.sparkfun. Bocquet. Retrieved from https://www. and current status. Retrieved July 1. 2014. (2013. Retrieved from http://www.20110708. (2014.. (2014). Retrieved July 1. Open Source Licenses | Open Source Initiative. (n. Ltd.. 124. Retrieved from http://blogs. November 10). C. #AirQualityEgg by #Sensemakers — Kickstarter.PDF₩ Kickstarter.com/proj ects/edborden/air-quality.d. Retrieved from http://sp.). Lenox rosin core lead free solder [Material Safety Data Sheet]. part I: History. Technical data – MQ135 gas sensor.cornell.mscdirect. Real-time air quality forecasting. 2014.html Kester.wsj. from http://www. Retrieved from http://www.d. (2012. (2012). M. from http://www. May 5). Retrieved from https://www. Retrieved from http://www1. Seigneur.d.com/MSDS/MSDS0 0026/07104441.ehs. (2014.pdf Open Source Initiative [OSD].olimex.REFERENCES Baclanov. China censors US pollution data during APEC meeting in Beijing. March 25).org. Inc. Cornell University.pdf Hart-Davis. With Obama in town.egg/comments Olimex..who.com/chinarealtime/2014/11/ 10/with-obama-in-town-beijingcensorsu-s-air-pollution-data/ World Health Organization.earth. (n.com/china-censors-uspollution-data-during-apecmeetingbeijing-1721414 Hanwei Electronics Co.). Beijing censors U.S. Laboratory safety manual and chemical hygiene plan. (n. Retrieved from http://opensource.raspberrypi. (2014.d. March 28). V. (October 2007). D. Technical data – MQ7 gas sensor.com/Products/Compone nts/Sensors/SNS. & Zhang.aspx FAQs| Raspberry Pi.ibtimes.