58 August 2015
Gas sensor collection and measurement occurs once
every 150 seconds for the duration of the collection
session. This is dedicated by the number of total samples
requested. Each 150 second collection cycle is marked by
a red LED active for the purge cycle, followed by a green
LED for the measurement cycle.
Prototype Operation
The air quality system application is implemented
using Raspberry Pi Python 2. 7 code with ISaAC, Tinker,
and SMTP, MYSQL, and File I/O Python libraries. Once
the application is launched under IDLE, a Monitoring and
Control GUI appears similar to what is shown in Figure 9.
The application was kept simple and built to help DIYers
understand and evaluate these new gas sensors for indoor
environments.
Measurements made during the application process
are automatically time tagged, converted to voltage, and if
optionally logged, PPM. The data can be maintained using
an MYSQL database to support analysis and trending.
Let’s clarify what is meant by a sample in our system.
A sample is a collection of all selected gas measurements
(both voltage and calculated PPM). It is comma delimited
and terminated with a carriage return and line feed. Each
sample starts with a full date/time string tag that captures
the start time of the first gas value in the sample.
The sample is ASCII formatted as follows (voltage and
PPM are in decimal): YYYY:MM:DD:MM:SS, CO voltage,
CO PPM, LPG voltage, LPG PPM, VOC voltage, VOC
PPM, CR, LF. If a gas is not selected, then a blank will exist
between the appropriate commas.
A good way to understand the application’s
functionality is to walk through the application’s applied
use of the Python Tinker GUI widget set and its associated
features. Notice, first of all, that the GUI display is broken
into four main sections: Gas Selection, Log Control,
Acquisition Control, and Advanced Control.
Let’s start with Gas
Selection. Here, check
boxes help you select
which of the three sensors
are candidates for
measurement.
The next section (Log
Control) provides a file
name where the session
measurements will be
stored (if the Enable Log
checkbox is selected). If it is
not selected, the session
will simply dump all the
measurements into the
Python shell for direct
viewing.
Acquisition Control sets the number of samples for
the collection session. The user sets this by typing a
sample number in the Entry box. Upon hitting the “Run”
button, an estimated completion time is automatically
displayed and logging commences if enabled. The
application will automatically set a file log name in the File
Name entry box. The file name uses the measurement start
time as an example: Gas_Log_YYYY_MM_DD_MM_SS.txt.
With each sample collected by the system, the
sample’s number box will decrement, and the collection
session will end at the zero sample.
Once the session ends, a user can view the file log by
hitting the “View Log” button. The file log content appears
as a scrollable text box widget. Under Advanced Control,
the log results can be stored in an MYSQL database
(gas_database.db) for long term archival by hitting the
“Update DB” button.
The user can also elect to send a copy of the log file
using the “Send Email” button to the recipient’s email
address listed in the email entry box address. The “from
address” in this email will be fixed to your DIY air monitor
system.
When in doubt about what is going on, examine the
outputs that are printed to the Python Shell; it captures all
the action going on “under the hood.” That is about it for
operation — simple enough!
Software Installation
A Python bundle for the entire system is available for
download at the article link. Just unzip within your main
Python folder and you should see:
• ISSACCOMVER2.PY (ISaAC Library)*
• GASGUIVER11.PY (main application operation and
GUI)
• SYSMAIL.PY (email function)**
• SQLITE_CREATE_DB.PY (SQLITE database install)
FIGURE 9. Air quality monitoring GUI.