Air Quality and Control System

October 2024 – (c) Stephen Swanson

Check it out on GitHub

Introduction

Hi! I’m Stephen, a 3rd-year student at Haaga-Helia UAS. Programming and creating IoT and embedded devices are recent hobbies of mine, which I picked up in summer 2024 after some friends (Alisa Dunaeva and David Gianadda) suggested I give it a try.

I came in with some programming experience, but circuits were completely new to me. Before diving into any projects, I took an online Udemy course to get up to speed on circuits, reading schematics, and other basics.

One of the projects I worked on over the summer was an air quality monitoring device for my apartment, which I later expanded into a more advanced system for my course project.

Ideas

As I mentioned, the system I created for the IoT experimental project course is a continuation of my personal air quality monitor project from the summer.
The idea came up when I was walking to dinner with my girlfriend. She asked if the air in our apartment was good enough for our cat, who has some breathing issues, or if we should have left a window cracked. This got me thinking about building a system to remotely monitor and control the air in our apartment.

The goal was to create a system that would let me monitor the air quality remotely and control my AC unit—whether to pull in fresh air, cool, or heat the apartment as needed.

What did you need to learn

Most of the project built on my previous experience with web hosting, port forwarding, React, Express, Node, and ESP32-based devices. It was just a matter of combining them into one cohesive system.

However, one new thing I had to learn was IR protocols, since I needed to send IR signals to control the AC unit. This was a challenging process, as the IR protocol for my AC remote was somewhat uncommon. I had to switch IRremote libraries a couple of times but eventually got everything working.

The building phase

The building phase technically started back in June with the construction and programming of my air quality monitor. This device uses an ESP32, a DHT11 temp and humidity sensor, an SGP30, and a TFT display panel.

Night view of the system
Night view of the system

The monitor collects temperature and humidity data, calculates the absolute humidity, and uses that value to calibrate the SGP30. After a short warm-up period, it displays the data in a grid on the bottom half of the screen. The top half shows a GIF sprite that I created in Aseprite and converted to an RGB565 header file using a tool from Maduinos. The GIF has 9 frames and loops through one frame every 200ms.

The second part of the system is the air control unit, which is much simpler. It consists of an ESP32, an IR LED, and a transistor. Building it was straightforward, but programming it was frustrating due to the earlier IR protocol issues. Once that was resolved, the rest of the programming and setup went smoothly.

The board
The board

The third item on the to-do list was configuring and deploying the web server, which I set up using Express and Node on Heroku. The server manages routes for devices to register their local IPs, get and post air quality data, and send IR commands.

After configuring the web server, I went back to the devices to make some tweaks for smoother communication. I adjusted the air control device’s API routes and server registration function. On the air quality device, I added a function to send data to the server. Finally, I set up a port forwarding rule on my router for the air control unit to allow the server to forward commands.

Once everything was connected and working properly, I created a basic React client hosted on GitHub Pages. The client serves as a control panel that displays the information and control buttons when the user is logged in. Authentication is handled via Google OAuth and is restricted to household members.

After logging in, users can view the air quality info and control the AC unit via the air control device. One final fun feature I added is the gif, but the gif starts crying when the CO2 and VOC levels exceed certain thresholds. Et voilà—remote home air monitoring and control system is born!

The outcome

Aside from learning about IR protocols, the main outcome is that I now have a cool system in my apartment that’s useful for daily life.

This project got me more interested in tinkering, and I even started another side project—an automatic plant watering and fertilizing system that uses sensors to monitor soil moisture and nutrient levels and pumps water or nutrients as needed. I’m currently waiting for parts to arrive from Alibaba. I think this will be a lifelong hobby and potentially a career path!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.