A project for tracking environmental factors like air quality, temperature, humidity, pressure, and light.
  • C 93.2%
  • CMake 6.8%
Find a file
2026-07-12 10:23:19 -04:00
include dev: add interface for opt4048 lux/colour sensor 2026-07-04 15:42:45 -04:00
src opt4048: update main loop to query OPT, ongoing change to non-blocking i2c 2026-07-12 10:23:19 -04:00
.gitignore credentials: cleaned git history, put creds in separate file 2026-06-30 06:41:50 -04:00
CMakeLists.txt cpu: switch to RP2350 from RP2040, should still work on either 2026-07-12 10:22:39 -04:00
LICENSE initial commit of project 2026-06-15 15:03:54 -04:00
README.md readme: add link to tio 2026-07-06 16:08:00 -04:00

ENSAHT

What?

A firmware for the Raspberry Pi Pico W to grab data from a few environmental sensors and then log them to Adafruit IO (or the MQTT service of your choice).

Why?

I dunno, cause I wanted to play with these sensors and keep track of the air quality in my room. But eCO2 is pretty inaccurate, and I suspect I have a fake ENS sensor because the readings seem almost random.

Instructions

Prep

You need to have the pico-sdk installed. I have it installed in ~/workspace/rp2040/pico-sdk and this is currently hard-coded into CMakeFiles.txt. I'm not sure if exporting an environment variable overrides this by default, but you can always just edit it to point to wherever you have it installed.

You also must create a file in include/ called credentials.h in the following format:

#ifndef CREDENTIALS_H
#define CREDENTIALS_H

// Replace these placeholders with your actual credentials
#define ADAFRUIT_IO_USERNAME "your-username"
#define ADAFRUIT_IO_KEY      "your-adafruit-io-key"
#define WIFI_SSID            "wifi-ssid"
#define WIFI_PASSWORD        "wifi-password"

#endif // CREDENTIALS_H

This keeps your credentials separate from the git history in case you want to make/submit changes. The build will fail if you don't create this file and define those four things.

You'll also need to edit src/main.c and change the MQTT topic names to whatever you are using.

Build

Create a new directory in the project called build. Move into that directory and run:

cmake ..
make

and if you have a picoprobe or RasPi debug probe installed (or other CMSIS-DAP compatible probe) you can then directly write to the Pico with

make flash

or, you can hold down the BOOT button on the Pico W while plugging it in. It will appear as a USB drive. Then copy the ensaht.uf2 file from the build/ directory to that USB drive. It'll take a second, then it'll disappear. You may need to manually reset the Pico (or unplug/replug it). Open a serial terminal (I used to recommend minicom until I found tio, which is much better), probably something like

tio /dev/ttyACM0

and it will print out sensor values. It will also log these to whatever MQTT server you have set up, assuming it was able to connect to Wi-Fi. And that's it!

License

Unlike most software I write, this is released under MIT instead of under MPL. So, follow the MIT license if you wanna reuse it!