Environmental Sensing using an eInk Display and CircuitPython

Measure CO2, temperature, humidity and send that data to the cloud, while displaying results on an 2.9″ e-ink display.

My first choice was to use the display vertically.
It feels a bit less like a price tag in this orientation.

e-ink display showing temperature, humidity, co2, pressure, altitude, and battery level
e-ink displays maintain their data even when power has been disconnected.

This past August 18th marked CircuitPython day, a celebration of Python on Microcontrollers.
CircuitPython is an off-shoot of MicroPython maintained by Adafruit which aims to ease the use Python on constrained devices with limited RAM and Flash memory, reduced CPU.
AKA Microcontrollers.

This project uses:
Adafruit 2.9″ Grayscale eInk / ePaper Display FeatherWing
Adafruit ESP32-S2 Feather
Adafruit SCD-40 – True CO2, Temperature and Humidity Sensor
Adafruit BMP280 Pressure & Altitude Sensor
As well as a small LiPo battery

Adafruit 2.9" Grayscale eInk / ePaper Display FeatherWing
Adafruit ESP32-S2 Feather
Adafruit SCD-40 - True CO2, Temperature and Humidity Sensor
Adafruit BMP280 Pressure & Altitude Sensor
As well as a small LiPo battery
These sensors are easily connected with Stemma/Qwic I2C connectors.
No soldering required.

All of the code is open source and can be found at https://github.com/somenice/EnviroIOT

Beside indoor sensing of CO2, temperature, and humidity I’m also using the ESP32-S2 with Adafruit Requests library to fetch an XML file hourly from my local weather service for current outdoor temperature and humidity. Some challenges include when this xml feed changes due to weather events and warnings. I’ve included lots of try:except: blocks for each step of the Requests, Socket pool, Parsing to find where it was sometimes failing.

This BMP280 library also contains code I have happily contributed to which helps set the altitude of the sensor. Changes in pressure are registered as atmospheric rather than altitude.

E-ink is awesome for it’s low power. Combined with the ESP32-S2 deep-sleep capabilities I’ve managed to get hourly updates for days on a tiny 150mha battery.

All of the data is shared hourly to Adafruit IO. A cloud service which provides dashboards, alerts, events, and recording of historical data.

Online dashboard for environment sensing
Wildfire smoke has forced windows closed and thus high CO2 vlaues

The majority of work was laying out the e-ink display and data labels using the CircuitPython displayio library. Two separate fonts are used separating Inside vs Outside data.

One cool feature is using a spritesheet for the temperature, humidity, and battery icons.
The data depends which icon gets shown:

As a serious microcontroller user or single board computer enthusiast, I have the choice to program with Arduino, C++, Python with Raspberry Pi, CircuitPython, JS etc. More often than not given this choice I choose CircuitPython.

Here is why I personally prefer it:
1) Mountable drive with code.py file – Plug in the device and it mounts like a thumbdrive on Windows, Mac, or Linux. Any text editor can immediately read and change the code running on the board. Not something that is immediate with Arduino.

2) The REPL – Or Read, Evaluate, Print, Loop on the command line.
This allows you to test and run small bits of code without committing permanent changes.

3) Circup – A command line package manager that manages and updates libraries found on any board plugged into the computer.

4) The community – So many great people contributing and sharing in a very welcoming environment.

I have a couple ideas for a case or mount but happy so far and I wanted to share for CircuitPython day.