/Air-Quality-IoT

Indoor air quality sensor box IoT project with 3D-printed housing!

Primary LanguagePython

😷 Home Indoor Air Quality Sensor IoT Project 🫁

Welcome to my open-source Air Quality Sensor IoT Project! This project monitors your home's indoor air quality in real-time using IoT technology and feeds you data in JSON over a web server.

This project includes:

  • A data sampling and upload script, written in MicroPython, running on a Raspberry Pi Pico W.
  • An ENS160 Digital Metal Oxide Multi-Gas Sensor, used for monitoring Carbon Dioxide (CO2), Total Volatile Organic Compounds (TOVC), and the Air Quality Index (AQI) of your home via the I2C protocol.
  • An AHT21 Integrated Temperature and Humidity Sensor, used for monitoring ambient temperature and humidity of your home via the I2C protocol.
  • A 3D-printed housing box for the Raspberry Pi Pico W and sensors (optional).

I am using a single breakout board that contains both an ENS160 and AHT21 on one board, found here.

The Raspberry Pi Pico, along with the ENS160 + AHT20 sensor breakout board live neatly in a small 3D-printed enclosure: plugged in

How does this work?

You can easily move this source code to a Raspberry Pi Pico W, hook that Pico W up to an ENS160 & AHT21 sensor, and deploy. The source code will:

  1. Validate and set up the ENS160 and AHT21 sensors.
  2. Connect to your wifi network (using credentials you specify in the settings.py file)
  3. Take air quality and condition measurements from the ENS160 and AHT21 sensors.
  4. If the air quality measurements were unsuccessful, restart these sensors and troubleshoot until they are operational.
  5. Upload these readings via HTTP POST request to an endpoint you define in the settings.py file.
  6. Wait for a predefined amount of time, specified in the settings.py file (default is one minute).
  7. Repeat steps 3-6 in an infinite loop, sampling and uploading data at a regular interval!

There is a watchdog timer implemented to ensure long-term functionality is preserved.

3D Printed Housing

I modeled a simple housing tray for the microcontroller and sensors required for this project. You can download the 3D Model (STL file) here directly from this GitHub repo. 3d printed housing tray

May 2024 Update

In May 2024, I changed the core functionality of how the Raspberry Pi Pico W performs: instead of being a server, responding to HTTP requests, it now instead samples data at a regular interval and uploads this via POST request to a defined endpoint.

All of the code and literature behind this old version can still be found by reverting to commit 3d04d5e89972443a98873347cb8421cb2e6d45a3.