Street Sense

Portable electronic device to measure air and noise pollution

Public Chat
Similar projects worth following
Street Sense is a project to build a portable, battery-powered sensor unit to measure:

Air Quality: Ozone, NO2, Particulates
Noise Pollution
Environment: Temperature, Humidity

There are two NGO sponsors. They require a sensor that can help them answer some important questions:
1. What air and noise pollution effects are experienced by people at the street level?
2. Can we quantify the changes in street level pollution resulting from a capital infrastructure project?

The project name "Street Sense" seems appropriate - sensing the environment at the street level in the urban landscape

Prototype as of September 2019

Street Sense Features:

  • Measurement sensing:
    • ozone, in ppb
    • NO2, in ppb
    • PM2.5 particulates
    • audio recording for post analysis
    • temperature and humidity
  • Measurement recording
    • on-board micro SD Card media
    • continuous recording of audio stream to WAV file
    • air quality measurements logged to files
    • SD Card removable to enable file download
    • recorded data is time-stamped
  • Power
    • battery or USB powered
    • minimum 8 hours operation time on battery
    • USB rechargeable without battery removal
  • Enclosure
    • weatherproof
    • simple attachment to a street level structure such as a lighting pole
    • allows air flow thru 
  • Connectivity
    • WiFi for pushing sensor data to an internet cloud database
  • User Interface
    • on-board display to view readings and verify operation
    • simple operation requiring minimal training
  • 100% Open
    • Open Hardware - schematics, BOMs, etc
    • Open Software - written in MicroPython - all code hosted on public github account

Stretch ambitions:

  • on-board audio sample processing to calculate real time dB
  • open API to allow customization using MicroPython

Project Parts Budget:  USD $225


Functional Block Diagram showing major components

"Need Help" Section:

This section describes areas where I am having difficulties and could use some help from Hackaday experts.  Please consider commenting if you have ideas on any of these problems.  thanks!

April 2019:

1.  Oscillations from Spec Sensor ozone and NO2 sensors.  I think it is caused by noise in the 3.3V rail power supplied to both the sensors and ADC.  The initial breadboard proto no doubt contributes to this problem.  Described in this project log.   Any ideas appreciated!  e.g.   LC filtering to create cleaner analog power rail?   Is it worth trying to make a soldered proto?   Or, is a custom PCB the only way to improve this?

2.  SDCard write delays.   The 10GB card that I am using (SanDisk Ultra 16GB) claims to be a class 10 device.  But, some 512Byte sector writes take a really long time...e.g.  >50ms.  And, there can be multiple back-to-back writes > 50ms.  These long SDCard write block the waiting coroutines in the cooperative multitasking asyncio design.  My main need is fast writes.  Fast reads don't matter for this application.  Are there better choices for SD Cards that support fast writes?

Adobe Portable Document Format - 33.40 kB - 09/13/2019 at 15:05


Adobe Portable Document Format - 70.13 kB - 09/09/2019 at 18:43


Adobe Portable Document Format - 44.90 kB - 08/01/2019 at 14:39


Street Sense Schematic-V08.pdf

Version 8 of Street Sense air and noise pollution sensor unit - added separate analog supply - reading ADC using ADC ~DRDY signal and uPy interrupt

Adobe Portable Document Format - 74.90 kB - 05/14/2019 at 16:16


Adobe Portable Document Format - 69.76 kB - 03/25/2019 at 16:52


View all 10 files

  • Laser Cut Enclosure

    Mike Teachman09/23/2019 at 20:19 0 comments

    The next step involved designing a laser cut enclosure for mounting all the PCBs and all other electronic components.  3mm clear extruded acrylic is used for the first version of the enclosure.

    Design in Fusion 360

    Fusion 360 was used to design the acrylic panels that are assembled into an enclosure.   I've used Fusion 360 for some simple design projects, but nothing this complex.  It was a steep learning curve, aided by a few excellent YouTube tutorials, for example:

    Learn Fusion 360 or Die Trying LESSON 3: Understanding Constraints
    Fusion 360: How to Export as DXF File

    The enclosure is composed of 2 main sections:

    1. Three acrylic panels that carry the sensor PCBs and will fit inside the Accurite vented enclosure
    2. Six acrylic panels that carry the CPU PCB and components for the user interface, such as the display and buttons.

    The 3 KiCad designed PCBs were exported as DXF files so that the standoff mounting holes could be pulled into Fusion 360.

    Here are a couple of screenshots of the enclosure in Fusion 360

    A browser viewable version of the Fusion 360 design is here

    Laser Cutting

    The 3mm acrylic sheet was cut on a 50W laser cutter at Victoria Makerspace

    "Days to design, minutes to cut"  - the laser cutting time was trivial, maybe 20 minutes.  

    A T-slot technique is used to connect the panels


    Final assembly, with PCBs and components mounted to the acrylic panels.   The front face has the display, on/off, reset, and two buttons for the user interface

    On the bottom is the SD Card slot, jack for DC power, and opening for the I2S microphone (seen below, left to right)

    The T-slot approach allows the side panels of the cube section to be removed.  This facilitates taking measurements on the CPU PCB.  The top section shows the Ozone and NO2 Spec Sensor modules, mounted downwards so dust does not fall onto the active sensing surface.

    Finally, a view with the sensor section installed inside the Accurite weather shield

  • A Slimmer Power Conditioning Module

    Mike Teachman09/13/2019 at 15:02 0 comments

    I decided to redo the power conditioning PCB module.  For these reasons:

    1. Make a slimmer version that will allow space for the LiPo battery to fit inside the vented enclosure
    2. Add 4 mounting holes for standoffs
    3. Add more test points and jumpers to facilitate voltage and current measurements
    4. Get more experience using KiCad for Stripboard layouts

    Using KiCad, it was straightforward to iterate the stripboard layout to reduce the PCB width by about 25%.  This task would have been more difficult and time consuming using hand layout methods

    The first version of the power conditioning module is described in an earlier project log

    Here are photos of the new, slimmer power conditioning module

    LiPo battery and module now fit side-by-side inside the vented enclosure

    25% slimmer compared to the first version of the power conditioning module (on right)

    Layout in KiCad

    The schematic is here

    As with all aspects of this project, it's 100% open software and hardware.  The KiCad files can be found in the Street Sense GitHub repository

  • Designing a CPU Module

    Mike Teachman09/09/2019 at 18:42 0 comments

    The next transformation from breadboard to PCB is the CPU Module.  If you look at the schematic it might be better called a "connector module" or a "glue module".

    This hardware module serves to connect all the peripherals and other hardware modules to the ESP32 microcontroller.  Some connectors terminate at switches and buttons which will be mounted on a user accessible panel.  Other connectors terminate at the sensor units:  I2S microphone and the PCBs holding the air quality sensor units.

    The PCB construction uses stripboard techniques with KiCad as the layout tool.

    Some notable PCB design considerations:

    • jumpers for the battery and USB inputs - to allow measurement of current for various operating modes.  
    • test points on all power and ground signals
    • three connectors are placed on the back side of the PCB.  These connectors service hardware modules that are located inside the external enclosure.  This construction choice exploits a key benefit of plated through-hole stripboard construction - the ability to place components on both sides of the PCB.


    Populated board

  • Revisiting Stripboard Techniques

    Mike Teachman08/01/2019 at 14:34 0 comments

    I ran across an interesting blog post on using KiCad to layout a stripboard design.

    Designing professional looking stripboards using Kicad

    So far I've been using manual layout methods for my stripboard prototypes.  The layout approach using KiCad appears to offer a better way to make an efficient layout.

    I decided to rework the sensor board layout using KiCad.  As well, I'm splitting apart the schematic into 3 separate schematics, one for each physical module.  The new schematic for the Spec Sensor module is here.

    As part of this journey I had some stripboard manufactured by JLCPCB, with the stripboard layout done in KiCad.  5 quality stripboard PCBs (10cm x 10cm) can be manufactured for USD $2.00 plus USD $8.09 shipping to Canada.

    The results were excellent.  I decided that this work was worthy of a separate HD IO project called Stripboard Meets KiCad

    Here is the completed sensor module using the JLCPCB stripboard 

  • Designing an Ozone and NO2 Module

    Mike Teachman06/26/2019 at 19:07 0 comments

    Continuing with stripboard construction methods, the ozone and NO2 sensor module was built.  This module also contains a LDO voltage regulator, the 24-bit ADC, and a temperature sensor.  The readings from the two sensors will need to be compensated wrt temperature - that is the reason to locate the temperature on this module.   An overview of the modules is described in an earlier project log From Breadboard to Enclosure - Part 1.

    This stripboard module can be considered a stepwise improvement.  Compared to the boardboard prototype it should give improved performance for the Spec Sensor modules, but will still be lacking compared to a properly laid out PCB.

    The module includes the major components U6, U8, U9, U10, U11 found in the schematic.

  • Designing a Power Conditioning Module

    Mike Teachman06/19/2019 at 14:13 0 comments

    Building the power conditioning module for the particulate sensor is the subject of this log.   The components in this module include all of the MOSFETS, transistors, diode, and the DC-DC boost converter.   An overview of the modules was described in Modular Design Concept

    The purpose of this module:

    1. Provide 5V power to the particulate sensor, for both USB and Battery power
    2. Provide a 3.3V compatible digital signal that will allow the MicroPython code running on the ESP32 the ability to turn off the DC-DC converter.  Turning off the DC-DC converter eliminates the power consumption and noise of the particulate sensor

    The components are shown below.  The full schematic is here:  schematic.

    A soldered protoboard will be used for construction.  For protoboard, I either use Adafruit Perma-Proto (left in photo below) or a generic stripboard (right in photo), cut to a custom size.

    The Adafruit product is high quality - the through holes are accurately drilled and plated.  The stripboad is somewhat lower quality - no though hole plating and inconsistent drilling which can lead to track lifting if there is any rework.  The photo below shows some of the off-center drill holes on the stripboard.

    Sloppy drilling in stripboard

    However, compared to a Perma-Proto board a stripboard module can be designed with a denser component layout, leading to a smaller module.  In the end, the need for a small module size led to the selection of stripboard.  

    Related stripboard idea:   There is high quality stripboard that is available, but it comes a significant price premium.  I think it might be possible to design a stripboard in KiCad and then have it built by a custom PCB manufacturer.  I am seeing low-cost PCB manufacturers offering 3 PCBs (10cm x 10cm) for USD $10 + shipping.   These PCBs would have plated through holes and solder resist between the holes, and hopefully accurate hole placement.  I might explore this avenue and document the results in a Hackaday project.

    The completed power conditioning module is shown below.  I am using polarized JST connectors for connection to the particulate sensor and cpu module.    

  • Modular Design Concept

    Mike Teachman06/02/2019 at 21:56 0 comments

    It's time to transform the Street Sense breadboard implementation into something more permanent.   Over the next month my ambition is to get all of the electronics and sensors into a weatherproof enclosure so I can start some field trials

    The selection of the enclosure wasn't difficult.  I'm going to house the electronics in the same enclosure used in the SensorUp Smart City Starter Kit.  I am a participant in the SensorUp Smart City pilot project and have a one of their beta sensor units mounted on my back porch, measuring PM2.5 particulates, since August 2018.  My measurement site is called "Fernwood" in the air quality map of Victoria.   This enclosure seems to work well.  My only issue was a spider that nested inside the enclosure.  The SensorUp enclosure is a commercially available unit, made by AcuRite.  

    The sensors and electronics will be located inside the enclosure cavity.  The dimensions of the cavity are:

    Bottom opening:  5cm x 9cm
    Depth:  12cm

    Packaging Goals:

    1. Protect electronics and sensors from wind and rain.  
    2. Allow airflow across sensors
    3. Removal of electronics as a single unit, to facilitate desktop development.  

    I would like to build some sort of carrier frame, to mount the electronics, that would fit inside the AcuRite enclosure cavity.  Here is a paper prototype sketch of the carrier frame for the electronics and sensors.

    3 circuit boards are planned, implemented with veroboard:

    1. Ozone + NO2 sensors, ADC, power conditioning for sensors
    2. Power conditioning for PM2.5 sensor 
    3. Processing board.  ESP32 + RTC 

    The Lipo battery needs to go somewhere as well.  Not sure where it will be located at this time.

    The frame will likely be constructed with acrylic, laser cut at Victoria Makerspace, where I am a member.  The 3 circuit boards will be attached to the frame with standoffs and bolts.  Then the whole assembly will slide into the cavity of the AcuRite enclosure.  Some sort of latched attachment mechanism needs to be conceived to securely hold the frame to the AcuRite enclosure - another TBD design topic.

  • Improving Ozone and NO2 Sensor Performance

    Mike Teachman05/14/2019 at 17:07 0 comments

    This project update outlines some incremental improvements to the ozone and NO2 sensor performance.

    A separate analog power supply was created on the breadboard to provide 3.3V to the ADC and Spec Sensor modules.  The idea is to isolate these sensitive analog components from the noisy 3.3V digital power supply.   The battery provides power to the input of an ultra-low dropout linear regulator which then feeds the ADC and Spec Sensor modules.   Luckily, the combined current consumption of the Spec Sensor modules and ADC are low enough that the Lolin D32 Pro battery charging circuit is not affected.  The analog power supply circuit can be found in the version 8 schematic.

    The method of reading the sample values from the ADC is another significant change.  Previously, the ADC was polled using I2C in single-shot mode to detect every new sample.  The polling with I2C was factor in creating unwanted noise into the Vgas outputs of the Spec Sensors.  This noise was appearing while the ADC was performing the conversion - not good.  Now, the ADC runs in a continuous conversion mode and the ~DRDY signal is used to run an ISR in the MicroPython code.  The ISR reads the sample value.  This is arrangement is better for two reasons:

    1. I2C polling during ADC conversion is eliminated = less noise is seen by the sensitive op-amp circuits in the Spec Sensor modules
    2. The MicroPython code is more efficient - no more polling is need to detect the end of ADC conversion

    The MicroPython code for this change is documented with this github commit.

    Here is what the breadboard prototype looks like now.  You'll spot the new voltage regulator which sits just below the two orange tantalum capacitors.

    Here are some ozone measurements that were published to Adafruit IO using the MQTT protocol, every 2 minutes.  The units are parts-per-billion (ppb).  The goal is to have a resolution of 10ppb. You can see that the readings still bounce around.  It is significantly better with the changes.  But, there is still work to be done to improve measurement stability.  

    These latest changes seem like the end-of-the-road for improvements to the breadboard prototype.  Breadboards have so many other limiting factors such as capacitance between metal connection strips and stray inductance.  Future improvements in sensor measurement performance will need to come from  other means, such as soldered connections and likely a custom PCB.

  • Publishing sensor data with MQTT

    Mike Teachman04/07/2019 at 18:47 0 comments

    The next iteration of the prototype involves taking advantage of the built-in WiFi feature of the ESP32 microcontroller to publish sensor to an internet database such as Adafruit IO or Thingspeak.  The MQTT protocol will be used.

    Publishing data to a cloud database with WiFi and MQTT protocol is something I've done in other projects.  But, there is an added technical challenge in this project - that is publishing data and simultaneously recording audio to SDCard without creating audio gaps.  If the MQTT task blocks for too long at any point, the DMA buffering used in by the audio recording task will "overrun" leading to gaps in the recorded WAV file.

    To overcome this risk I used a non-blocking asyncio version of MQTT written by Peter Hinch.   This version uses a non-blocking sockets implementation and will not block other asyncio co-routines from running (like the microphone recording task) when WiFi goes down or the MQTT broker is unreachable.   An additional pause/resume feature was added by Kevin Köck that allows WiFi to be turned off when the device is not actively publishing.   This turns off the WiFi radio which reduces the power consumed by the ESP32 - the end result is a longer battery life.  There is a discussion on the MicroPython forum describing how this enhancement was realized.  Sensor data will be published every 15 minutes in the final design.  

    A 2 hour test was run, publishing sensor data to Adafruit IO.  Below is a plot from Adafruit IO showing 2 hours of PM2.5 particulate data.  This shows a very clean air day on the west coast of Canada!  This publish period was reduced to 2 minutes for this test.  

    Some diagnostic information in the microphone task showed that there were two audio gaps in the 2-hour SD Card audio recording.   The was a unwelcome result.  More debugging code will be needed to determine the root cause of the audio interruption.  The audio sample rate in the test was 10kHz.     

  • Temperature and Humidity Sensor

    Mike Teachman03/25/2019 at 17:20 0 comments

    The next step in the project is rather unremarkable - adding a temperature and humidity sensor.  I chose the Si7021 sensor,  packaged in a convenient breakout board by Adafruit.  The sensor specification claims ±0.4 °C temperature accuracy.  Temperature measurements from the sensor will be recorded periodically to the SD card and will be used for temperature compensation of the ozone and NO2 sensor readings.

    I have used this breakout board in other MicroPython projects so I was expecting a simple integration with the Street Sense MicroPython code.  But, I once again stumbled on a breaking interface change in the Loboris ESP32 port.  The Si7021 driver that I use with the mainline of MicroPython does not work in the Loboris port - caused by a breaking change in the I2C interface API.

    Fortunately, I was able to source a different Si7021 MicroPython driver from Github for this sensor that works with the Loboris I2C implementation.

    The V07 schematic shows the addition of the sensor.

    The sensor is mounted in the breadboard to the left of the OLED display

View all 24 project logs

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates