Publishing Particulate Matter Sensor Data to Adafruit IO With Maker Pi Pico and ESP-01S
Introduction: Publishing Particulate Matter Sensor Data to Adafruit IO With Maker Pi Pico and ESP-01S
This article shows how to publish data from three low-cost particulate matter sensors to the Adafruit IO IoT service using the Cytron Maker Pi Pico running a CircuitPython program transmitting the sensors' outputs over Wi-Fi with an ESP-01S module running AT firmware.
The WHO identifies PM2.5 particulate matter as one of the greatest environmental risks to health with 99% of the world's population living in places where the WHO air quality guidelines levels were not met in 2019. It estimates 4.2 million premature deaths were caused by this in 2016.
The three particulate matter sensors shown in this article are:
* the Plantower PMS5003 using a serial connection;
* the Sensirion SPS30 using i2c;
* the Omron B5W LD0101 with pulse outputs.
These optical sensors are similar to the ones found in one type of domestic smoke alarm but they differ in their attempt to count particles of different sizes rather than just alarm at a threshold concentration.
The red laser-based PMS5003 is a commonly used hobbyist sensor and can be found in the PurpleAir PA-II air quality sensor. The SPS30 is a more recent sensor using the same principle and can be found in the Clarity Node-S air quality sensor. The infrared LED-based B5W LD0101 sensor has a more primitive interface but is useful for its ability to detect particles larger than 2.5 microns - the other two sensors cannot reliably measure these.
Adafruit IO offers a free tier with a limited number of feeds and dashboards - these are sufficient for this project. The free tier data is retained for 30 days but the data can easily be downloaded.
The Maker Pi Pico board in this article is a sample Cytron kindly sent to me to evaluate. 152
The only difference to the production version is the addition of passive components to debounce the three buttons.
The ESP-01S module is likely to need an AT firmware upgrade. This is a relatively complex, fiddly process and may be time-consuming. Cytron sell the module with the appropriate AT firmware on it.
The Omron B5W LD0101 sensor is unfortunately being discontinued by the manufacturer with last orders in March 2022.
Supplies
* Cytron Maker Pi Pico - Digi-key | PiHut
* ESP-01S - Cytron's board comes with appropriate AT firmware.
* ESP-01 USB adapter/programmer with reset button - Cytron.
* Breadboard.
* Female to male jumper wires, maybe 20cm (8in) minimum length.
* Plantower PMS5003 with cable and breadboard adapter - Adafruit
* or Plantower PMS5003 + Pimoroni breadboard adapter - Pimoroni + Pimoroni
* Sensirion SPS30 - Digi-key
+ Sparkfun SPS30 JST-ZHR cable to 5 male pins - Digi-key
+ 2x 2.2k resistors.
* Omron B5W LD0101 - Mouser
* Omron cable described as a harness (2JCIE-HARNESS-05) - Mouser
* 5 pin male header (for adapting cable to breadboard).
* solder - crocodile (alligator) clips could work as an alternative to soldering.
* 2x 4.7k resistors.
* 3x 10k resistors.
* 0.1uF capacitor.
* Battery power for Omron B5W LD0101:
+ 4AA battery holder for rechargeable NiMH batteries (better choice).
+ or 3AA batter holder for alkaline batteries.
* A USB power pack may be useful if you want to run outside away from a USB power source.
Step 1: USB Programmer for Updating Flash on the ESP-01S
The ESP-01S module is unlikely to come with appropriate AT firmware on it unless it is from Cytron. The easiest way to update it is to use a Windows desktop or laptop with a USB adapter which write-enables the flash and has a reset button. Unfortunately a very common, no-brand adapter often described as something like an "ESP-01 Programmer Adapter UART" does not have buttons or switches to control these. The video above shows how this can be quickly retrofitted with some improvised switches made from two male-to-female jumper wires cut in two and soldered onto the pins on the underside of the programmer board. 1003