Skip to content
This repository has been archived by the owner on Apr 17, 2020. It is now read-only.

GeorgetownMakerHubOrg/air-quality

Repository files navigation

GUAQ Logo

Georgetown University Air Quality Initiative (STIA 436)

alt text

Improvements on the STIA315 course.

These include:

  1. Code written in Micropython
  2. Integrated battery shield and Expressif ESP32 WROOM-32 circuitry on single board (Lolin D32)
  3. Stevenson case to improve air flow
  4. Crisp wiring that leverages the I2C bus
  5. Full deep-sleep & wake cycling
  6. Significant cost reduction (66% reduction)
  7. Lithium Ion Battery with 20% greater mAh at 87% cost savings over LiPo
  8. Optional four (4) 16bit Analog Channels for ADC sensors
  9. Voltage monitoring on a ADC channel

Prototype Components

The prototype has the following components:

  1. LOLIN D32 ESP32 Board
  2. Stevenson enclosure from Acurite
  3. I2C-based Sensors:
  4. Two (2) Plantower PMS-A003 Particle Sensors
  5. Optional USB connected Solar Panel
  6. Optional 3000mAh 18650 Lithium Ion Battery

Open Actions/Areas of Investigation & Improvement:

  1. This repo has migrated to the ESP32 MCU. There are minor implementation differences that we'll need to manage through (eg. sleep or upgrade method).
  2. Better understanding of the accuracy and target purpose of the PMS-A003 and Bosch BME680 Sensors. Super interesting paper on the Plantower sensors. We're on the right track with our sensors - check this out.
  3. Integration with other IoT sites - ThingSpeak, Wunderground. As a class, we also need to come to some resolution as to how we want to integrate the collection of data from multiple sites. Does each site have its own IOT service? Do we have a single IOT account and assign each sensor to be its own channel (thingspeak) or group (adafruit.io)? The latter would require that we share a single API key with all interested parties. Might not be a bad thing to do since we're collecting non-sensitive, non-critical data over the past 60 days.
  4. More and more articles are appearing on this subject of Consumer Grade Air Quality Monitoring such as this. Volatile Organic Compounds are nasty! A decent listing of AQ sensors is, of course, in China. A DIY site where you can register your device.
  5. Continue to evaluate power usage using the DC Power Supply in the Hub. Are sensors unnecessarily draining the battery?
  6. Let's track low power options like nanoPower which uses the nrf chipset from Norway.
  7. More details on this monitor's design and roadmap are described in this Google document.

Data Collection choices:

Why Adafruit.IO is arguably better than ThingSpeak:

- Great documentation
- Solid REST & MQTT support
- You can download all data from the push of one button
- Fields can be set up as Key/Value pairs e.g "Temperature", 32
- You can create fields on the fly
- You can create groups (monitors) on the fly
- You can set alerts using IFTTT webhooks to alert for events (high particulate matter sensor readings when battery hits a threshold).

Notes

  • You will need the following tools with this project:

    1. esptool.py - for flashing MicroPython on the ESP32 Lolin/Wemos Pro
    2. ampy - for uploading/downloading/list files to/from the ESP32.
    3. MicroPython - if you're up for building from source!
    4. WebREPL files to access the ESP wirelessly
  • The "utilities" directory contains the following scripts and executables for:

    1. Basic hardware testing to ensure that sensors are properly connected and minimally operating (hwtest.py)
    2. Confirming that connectivity to Adafruit IO is working properly (to be run on a laptop running Python) (testiot.py)
    3. Automatically creating an Adafruit IO group unique to each monitor (setgroup.py)
    4. Installing Micropython binary v. 1.10 for the ESP32 using esptool.py (esp32-[version].bin
    5. Building an ESP with all the necessary AQ module and installing micropython from scratch (upload). Be sure to rename the file main~.py to main.py - this is done so that you can access the ESP32 and do minor testing via the REPL interface before main.py automatically runs the AQ code on boot up.
  • This code base leverages several other important MicroPython repositories including but not limited to:

  • Setting up a static dhcp address for the monitor on the router will greatly reduce the network connection latency (from 4-6 seconds to 2) while increasing consistency on runtimes.

AQ sites worth tracking

Code Still To Do

  • Port ESP8266 upgrade code in main~.py to ESP32

Installation

These instructions are provided for Georgetown students who wish to build GUAQ from scratch in the Maker Hub. These installation steps are a work in progress but have been tested on Linux and Mac OSX systems:

  1. Before you install MicroPython - Have you:

    • Confirmed access to Wifi and have obtained the Wifi SSID and password?
    • Located your Adafruit IO Key and Username?
    • Identified how you will power the unit with a USB cable?
    • Located a site suitable for hosting this monitor?
    • Checked that Python Version 2 or Version 3 has been installed on your computer.
    • Downloaded CoolTerm for the Mac or Putty for the PC and configure it to support the ESP32.
      • CoolTerm Configuration: Options->Terminal-"115200", Check "Filter ASCII Escape Sequences" and "Handle BS and DEL Characters" boxes.
    • Chosen a text editor that you're comfortable using to modify Python files. Sublime Text is a great choice.
    • Bookmarked http://docs.micropython.org/en/latest/esp32/quickref.html. MicroPython is a rich, vibrant development environment. You should definitely bookmark the following documentation which goes into far more detail than I can cover here.
  2. With these basics out of the way:

    • Install esptool.py and ampy.py tools on your system by following the instructions in the links below. Understand how to invoke them from the command line.
    • Download/Clone this Git repository to a directory of your choice on your computer.
    • Unzip this archive which will create a directory called "air-quality-master".
    • Fetch the required Python library modules listed below from their Git repositories and put these libraries into the current 'air-quality-master' directory. As a minimum, this must include BME280, BME680, and smbus modules (bme680 and usmbus have library sub-directories)
    • Configure the config-generic.py with the configuration information specific to your site and rename it config.py - these changes will include Wifi credentials and Adafruit IO username and key. Optionally, you can configure the Access Point SSID and password as well.
    • Edit the wake.py file to selectively measure from the attached sensors. The stub.py can be used when no sensors are available but you want to test the ESP32 and its connectivity to the IOT service.
    • Optionally remove those MicroPython modules that are not required for this monitor - eg. DHT11, analog.py, stub.py, and enviro.py.
    • Use the utilities/upload script to install Micropython 1.10 on the ESP32 and upload the air quality files. You will only need to change a single line in this script to identify the port used by your computer to connect to the ESP. On a macintosh, it's usually /dev/tty.usbserial-xxxx.
    • Run hwtest.py to confirm that the ESP32 can communicate with the sensors: import hwtest
    • Rename the main~.py file to main.py so that it runs automatically at boot time.
  3. Report any issues to me - [email protected]