HackSpace_-_April_2020

(Frankie) #1

TUTORIAL


Monitoring Air Quality


ackSpace magazine is edited in
Bristol, and like many cities around
the world, Bristol has a problem
with clean air. Currently, the council
is considering an outright ban on
privately owned diesel cars. However,
is this needed? Is air quality a problem? If so, what
should we do about it? We think the first step with
this, as with many things, is to understand the
problem – that starts with understanding the data.
As with most cities in the UK (and elsewhere),
there is a range of air monitoring stations that
provide information about the current state of the
environment. You can view live and historical data
at hsmag.cc/Dwoa1w.
We wanted a way to subtly keep an eye on
air quality without having to go to the website to
check it. We took inspiration from Google's Paper
Signals project, which uses servos and bits of paper
to display live information. Bristol air quality is not
supported by Paper Signals, so we had to build
our own.
Although this build uses a data feed that's
specific to Bristol, there are similar feeds for other
geographical areas, and different types of data,

so you can use this process to display a range of
different things.
There’s an API which lets us download the data in
a machine-readable format (in this case, JSON), and
even an API builder tool which helps us create the
right request to get the data at hsmag.cc/qPoqTK.
Using this, we can limit the results to just the air
monitoring station closest to our office (AURN St
Paul's), and only get the latest reading. The final
URL for retrieving this data is:
https://opendata.bristol.gov.uk/api/records/1.0/
search/?dataset=air-quality-data-
continuous&rows=1&sort=date_time&facet=date_
time&facet=location&facet=current&refine.
location=AURN+St+Pauls

The 's' at the end of HTTPS shows that this is
using encrypted data transfer, and this is both a
good and bad thing. It’s good because it means
that we’re taking advantage of modern security,
but it’s bad because microcontrollers can struggle
with encryption as it’s a bit RAM and CPU heavy.
Fortunately, the ESP32 is powerful enough to handle
it, so that’s our hardware of choice for this project.
Now, let’s look at getting the data first.

Keep an eye on what you breathe with an ESP32 and a servo


H


Monitoring Air Quality


Ben Everard
@ben_everard

Ben is a maker and
keen cyclist which
means he has a keen
interest in the air
around him and the
skills to find out what's
in it.


Above
Our final data display
sitting on our desk as
a constant reminder
that our health is
inextricably linked
to the quality of air
around us
Free download pdf