Sensor nodes built using ESP32 and Sensirion sensors

Tags: #<Tag:0x00007f327124a770> #<Tag:0x00007f327124a5e0>


Since a while I am using MicroPython to read out various sensors and send the sensor data to Home Assistant via MQTT. Typically a sensor node consists of a breadboard, a ESP32, one, two or more sensors, and some wires to connecting it all together.

To simplify my scripts I wrote the library micropython-ha-mqtt-device which allows to expose the sensors from MicroPython to Home Assistant via MQTT. I then have a set of home grown and home specific MicroPython scripts which ties this library and sensor drivers together depending on the sensor node I build. Usually I use sensor modules from Sensirion (e.g. the SCD30 CO2 sensor) or modules from Aliexpress (e.g. the SHT31 boards).

Recently Sensirion added a new version of their VOC (volatile organic compounds) sensor, the SGP40. Unfortunately no (cheap) modules are available yet… So I went ahead and created my own SGP40 breakout boards. Since the VOC sensor requires temperature and humidity for compensation anyways, I designed a SHT35-D (temperature and humidity sensor) onto the same PCB as well. The PCBs finally arrived a couple of days ago and I went ahead and assembled them:

The MicroPython driver micropython-sgp40 can read raw values from the sensor. The sensor values then need to be processed by Sensirion’s VOC algorithm (available in C) which I was able to build as a MicroPython native module.

To make this series of sensor nodes a bit more pretty I also designed a case for them. Since the sensor need air from the environment to do their work I just mount them on the outside.

And the 3D printed version of it:

It was a fun project to learn KiCad (for the PCB design) and FreeCAD (for the 3D printed case). Since this is kind of a one-off project there are little caveats everywhere (e.g. the SGP40 VOC sensor has a heating element, and it seems the temperature sensor picks up on that a bit, so they are too close. Probably can be fixed by using a fixed offset). Also the MicroPython scripts are rather hacky at the moment. I was also thinking about using ESPHome instead, but there is no SGP40 driver yet. I do have some spare sensor modules, so if someone would like to write a SGP40 driver for ESPHome, please contact me.

Best regards,