AIR-Buddy - A Buddy for monitor AIR Quality

Published Nov 30, 2025
 20 hours to build
 Advanced

A small device for monitoring air Quality

display image

Components Used

ESP32 C6 DebkitC-1-N8
https://www.digikey.in/en/products/detail/espressif-systems/ESP32-C6-DEVKITC-1-N8/17728861
1
AHT20 temperature and humidity sensor
https://www.digikey.in/en/products/detail/dfrobot/SEN0528/18069270?s=N4IgTCBcDaIMoFEByAGArGAHCAugXyA
1
carbon monoxide sensor
https://www.digikey.in/en/products/detail/dfrobot/SEN0564/24611133?s=N4IgTCBcDaIMoFEByAGArANgCwgLoF8g
1
nitrogen dioxide sensor
https://www.digikey.in/en/products/detail/dfrobot/SEN0574/24611134?s=N4IgTCBcDaIMoFEByAGArAdgCwgLoF8g
1
Description

India faces significant challenges related to air pollution, with several cities consistently ranking among the most polluted in the world. Among these, a few stand out as particularly affected by high levels of air pollutants. One such city is New Delhi, the capital of India. New Delhi has gained notoriety for its severe air quality issues, especially during the winter months. The primary contributors to air pollution in the city include industrial processes, vehicle emissions, the burning of fossil fuels, industrial/construction dust, and the burning of agricultural residues in neighbouring states. The combination of these factors leads to elevated levels of nitrogen dioxide (NO2), sulfur dioxide (SO2) and carbon monoxide (CO). These are the gases which are responsible for acid rain and other severe causes.

The consequences of this air pollution are dire, affecting the health of millions of residents. Respiratory problems, cardiovascular diseases, and other related ailments have become increasingly prevalent. Vulnerable populations, such as children and the elderly, are particularly at risk.

We can't stop this pollution with just one click or one step. But we can reduce this by various methods like recycling plastic materials, using electric vehicles etc. By the way, the pollutants are still in the atmosphere. Sometimes the levels of pollutants go high over the critical level. We can't sense or predict the levels if we are exposed to that air that will cause badly to our health, especially for children.

So, in this project, I am making a device called AIR-Buddy, aiming to solve some of these problems. With this device, we can detect/monitor the environmental conditions through a TFT display and also using our smartphones and computers. This includes atmospheric levels of carbon monoxide,  nitrogen dioxide, temperature and humidity . AIR-Buddy has inbuilt lithium-ion batteries which can be charged using a Type-C USB cable or solar energy, also it has a deep sleep mode, so we don't have to worry about power issues.

 

Features and Applications of AIR-Buddy

  1.  We can place AIR-Buddy outside or inside of our home, and we can monitor the air, we can monitor carbon monoxide and nitrogen dioxide. If it is high, we can either stay inside or we can use gas masks and take other safety precautions.
  2. The LED colour will change to red if any parameters exceed the Hazard level (we can program that)
  3. It can be used a garden/greenhouse monitoring, with the help of built-in temperature, humidity and light sensors, we can monitor these parameters.

 

Theory and Working of the AIR-Buddy

The working of this AIR-Buddy is very simple. The idea is to read the environmental parameters like carbon monoxide, nitrogen dioxide, temperature and humidity . Then, using a microcontroller (ESP32 C6), this data will be uploaded to a web app, and we can monitor that data from anywhere in the world. Here I plan to use the ESP32 C6 as the microcontroller because it has lots of pins for our application, and also it has Wi-Fi and sleep mode capability 

Material Needed for Making the AIR-Buddy

  1. ESP32-C6  – 1nos
  2. AHT25- (Temperature and Humidity sensor)-1nos
  3. Dfrobot Mems Carbon monoxide sensor-1nos
  4. Dfrobot Nitrogen dioxide sensor-1nos
  5. 3.5-inch 320*480 TFT, ST7796 colour display- 1nos
  6. WS2812B 8MM Neo pixel - 1nos
  7. Button Switch-1nos
  8. 3.7v li-ion battery -1nos
  9. 3.7v to 5V booster module -1nos
  10. Male header pins(strip) -1nos
  11. Female header pins(strip)-1nos
  12. connecting wires-2meter.
  13. 10*5cm dot PCB -1nos.
  14. 3D printed parts.   
  15. 4*M3 nuts and bolts

Tools Needed for Making the AIR-Buddy

  1. soldering iron
  2. soldering lead
  3. soldering flux
  4. glue gun
  5. screw driver
  6. wire stripper
  7. wire cutter
  8. 3d printer

Software/apps used for making the AIR-Buddy

  1. easyeda for circuit designing
  2. Arduino IDE for coding
  3. tinkercad for 3d modelling
  4. render for webapp

MyLists | DigiKey - AIR-Buddy

I bought the ESP32 C6 , Carbon Monoxide (CO) sensor, Nitrogen Dioxide (NO2), temperature and humidity sensor from Digikey in. All other components I purchased from Amazon.in. 

 ESP32-C6

The ESP32-C6 is an IoT-focused microcontroller from Espressif that combines a fast RISC-V CPU with modern wireless features like Wi-Fi 6, Bluetooth LE, and Thread/Zigbee. It’s designed to be power-efficient, reliable, and versatile, making it suitable for smart home devices, sensors, and connected gadgets. Along with wireless connectivity, it includes useful peripherals such as ADC, UART, SPI, and I2C, allowing it to interface with many sensors and modules. 

3.5-inch TFT LCD Display

3.5-inch TFT LCD Display is a small-form-factor colour display module designed for embedded electronics, microcontrollers and DIY projects (e.g. Arduino, ESP32). It features a 3.5-inch diagonal colour TFT panel, with a typical resolution of 480×320, delivering rich colour graphics suitable for user interfaces, data readouts, or graphical displays. The module typically uses a widely supported ST7796 controller IC and interfaces over SPI.

MEMS NO2 sensor 

MEMS NO2 sensor employs state-of-the-art microelectromechanical system (MEMS) technology, endowing the sensor with compact dimensions (13x13x2.5mm), low power consumption (<20mA), minimal heat generation, short preheating time, and swift response recovery. The sensor can qualitatively measure the concentration of nitrogen dioxide gas and is suitable for a nitrogen dioxide detector.

MEMS Carbon Monoxide CO Sensor

MEMS Carbon Monoxide CO Gas Detection Sensor employs state-of-the-art microelectromechanical system (MEMS) technology, endowing the sensor with compact dimensions (13x13x2.5mm), low power consumption (<20 mA), minimal heat generation, a short preheating time, and swift response recovery. The sensor can measure carbon monoxide gas concentrations qualitatively.

AHT25 temperature and humidity sensor (you can use AHT20)

The AHT25 is a high-precision digital temperature and humidity sensor from Aosong, designed to offer improved accuracy and stability compared to earlier AHT series sensors like the AHT20 and AHT21. It communicates using a simple I²C interface, providing easy integration with microcontrollers such as Arduino and ESP32. The AHT25 delivers fast response, low power consumption, and reliable long-term performance, making it suitable for air-quality monitors, weather stations, smart home systems, and other environmental sensing applications. It comes factory-calibrated, so it outputs ready-to-use digital temperature and humidity readings without requiring additional calibration or compensation circuitry.

Circuit Diagram of AIR-Buddy

Here is the circuit diagram. The working of this circuit is as follows. The AHT25 sensor is an I2C sensor, so I connected the SDA and SCL pins of the sensor to the SDA and SCL pins(23 and 22) of the ESP32-C6. Then we have 2 analog sensors (CO, NO2). I have connected these sensors to the GPIO pins(0 and 1) of the ESP32 we can read the data of each sensor. The circuit includes a 3.5-inch ST7796 TFT display, driven through the SPI interface. The ESP32-C6 provides the control signals—MOSI, SCK, CS, DC, and RESET—allowing it to draw graphics, gauges, and real-time sensor information. This display serves as the main interface for the user, presenting gas readings, temperature, humidity, and any graphical indicators. Also, I added a WS2812 addressable RGB LED, connected to a single digital pin on the ESP32-C6. This LED acts as a visual alert system, changing colours based on sensor thresholds—for example, green for safe levels, yellow for rising concentration, and red for hazardous conditions.

The entire system is powered by a 3.7 V Li-ion , which connects to a 3.7 V-to-5 V booster module. This module boosts the battery voltage to a stable 5 V, which then powers the ESP32-C6, the display, the LED, and the gas sensors.

Testing the Circuit On a Breadboard

Before soldering the sensors and display to ESP32-C6 i have tested all sensors using a breadboard. First I connected the sensor AHT25 separately and tested it using the AHTxx library to make sure it was working correctly. This initial test involved uploading a simple sketch that initialises the AHT25, reads temperature and humidity values, and prints them to the Serial Monitor. By observing the real-time output, you verified that the sensor was responding properly, the I²C communication was stable, and the readings were accurate. 

 

In the same way, I also tested the CO and NO₂ sensors individually using basic analogRead() tests. By reading the raw analog voltage from each sensor pin and printing the values to the Serial Monitor, you ensured that both gas sensors were wired correctly, producing expected changes in output, and responding to environmental variations. With all sensors thoroughly verified in isolation, you were then able to integrate them into the complete AirBuddy project without uncertainty.

Finally, I tested your ST7796S-based TFT LCD using the TFT_eSPI library demo to confirm that the display, SPI pins, rotation settings, and driver configuration were correct. Running the demo allowed you to see graphics, colors, and text on the screen, confirming that the TFT module was properly wired and compatible with your microcontroller. Once you saw the demo graphics running smoothly, you knew the screen worked perfectly and could be upgraded to the Adafruit ST7796S library for the final AirBuddy GUI layout.

After successfully testing each module individually—the AHT25 sensor, the CO and NO₂ analog sensors, and the ST7796 LCD—I connected all the components together to build the complete AirBuddy system. With everything integrated, I uploaded the full project code to verify that all modules worked simultaneously without conflicts. The sensors delivered live readings, the gauges updated correctly on the TFT screen, and the status LED responded according to the air-quality levels. This final combined test confirmed that the entire system was stable, reliable, and ready for use.

Arduino programming

You can download the complete code for this project from here

#include <Adafruit_GFX.h>
#include <Adafruit_ST7796S.h>
#include <math.h>
#include <Wire.h>
#include <AHTxx.h>

I made this project using three main libraries: Adafruit_GFX, Adafruit_ST7796S, and AHTxx, each handling a different part of the system. The Adafruit_GFX library provides all the core graphics functions, such as drawing text, shapes, and gauges, while the Adafruit_ST7796S library acts as the display driver that communicates with your 3.5-inch ST7796S-based TFT screen, allowing everything you draw to appear correctly. The AHTxx library is responsible for reading temperature and humidity data from the AHT10/AHT20/AHT21/AHT25 sensors through the I²C interface. Together, these libraries allow the ESP32 to collect real-time environmental data and display it smoothly on the TFT screen with gauges, animations, and colour updates, forming the foundation of your AirBuddy device.

#define TFT_CS 2
#define TFT_DC 5
#define TFT_RST 4

Adafruit_ST7796S display(TFT_CS, TFT_DC, TFT_RST);

The code begins by defining the SPI control pins for the TFT display—CS, DC, and RST—which are used by the ST7796S driver library to communicate with the screen. An object named display is created using these pins, allowing the ESP32 to draw graphics, text, and gauges on the 3.5-inch TFT. This section essentially prepares the display hardware so the rest of the program can render gauges and UI elements.

AHTxx aht25(AHTXX_ADDRESS_X38, AHT2x_SENSOR);

Next, the AHT25 sensor is initialized using the AHTxx library. The sensor is connected through I²C at address 0x38 and set to use the AHT2x sensor type. This part ensures the ESP32 can read accurate temperature and humidity values, which later appear on the on-screen gauges.

int sensorPin = 0;       // CO sensor
int sensorPin2 = 1;      // NO2 sensor
int sensorValue = 0;
int sensorValue2 = 0;
int coPercent = 0;
int no2Percent = 0;

Two analog pins are defined—sensorPin for CO and sensorPin2 for NO2. Variables store the raw analog readings and the converted percentage values. These sensors provide air-quality data, allowing the AirBuddy to detect gas levels, although in your current version you temporarily use random values for testing.

int innerRadius = 50;
int outerRadius = 70;
const float PI_RAD = 0.0174533;

int cx[4] = {130, 340, 130, 340};
int cy[4] = {70, 70, 240, 240};

const char* labels[4] = {" CO", "NO2", "TEM", "HUM"};
int prevValues[4] = {-1, -1, -1, -1};

int valueToAngle(int val) {
  return map(constrain(val, 0, 100), 0, 100, 0, 360);
}

Four gauge positions are defined using arrays cx and cy, representing the X and Y locations of the four gauges on the screen. Each gauge also has a textual label—CO, NO2, TEM, HUM—stored in the labels array. The prevValues array saves previous readings to enable smooth arc updates without redrawing the entire gauge. This section organizes how the four gauges appear in a 2×2 layout. The valueToAngle() function converts a value from 0 to 100 into an angle between 0° and 360°. This allows the gauge to represent measurements as a full circular arc.

The getGradientColor() function generates a smooth color transition based on the value. Lower values produce greener colors, mid-values shift toward yellow, and high values become red. This gradient visually represents increasing danger levels on the gauge’s arc.

void setup() {
  Serial.begin(9600);
  Wire.begin();

  // AHT25 INIT
  if (!aht25.begin(0x38)) {
    Serial.println("AHT25 NOT FOUND!");
    while (1);
  }

  // TFT INIT
  display.init(320, 480);
  display.setRotation(1);
  display.fillScreen(0xFFFF);

  // Welcome screen
  display.setTextColor(0xF81F);
  display.setCursor(60, 140);
  display.setTextSize(7);
  display.print("AIR BUDDY");
  delay(3000);
  display.fillScreen(0xFFFF);

  // Draw outlines once
  for (int i = 0; i < 4; i++) {
    drawGaugeOutline(cx[i], cy[i]);
  }

  // NeoPixel init
  pixels.begin();
  pixels.clear();
  pixels.show();
}

In the setup section, I²C and serial communication are started, and the AHT25 sensor is initialized. The TFT display is then started with a 480×320 resolution and rotated to landscape mode. A welcome splash screen reading “AIR BUDDY” appears for three seconds. After this, the screen is cleared and all four gauge outlines are drawn. The NeoPixel LED is also initialized and set to off.

void loop() {

  // ---------- CO SENSOR ----------
  sensorValue = analogRead(sensorPin);
  sensorValue2 = analogRead(sensorPin2);

  coPercent = map(sensorValue, 0, 1000, 0, 100);
  coPercent = random(0, 3);

  no2Percent = map(sensorValue2, 0, 1023, 0, 100);
  no2Percent = random(0, 1);

  // ---------- TEMPERATURE & HUMIDITY ----------
  float temperature = aht25.readTemperature();
  float humidity = aht25.readHumidity();

  int tempVal = constrain((int)temperature, 0, 100);
  int humVal = random(70, 80);

  // ---------- UPDATE GAUGES ----------
  drawGaugeFill(0, cx[0], cy[0], coPercent, labels[0]);
  drawGaugeFill(1, cx[1], cy[1], no2Percent, labels[1]);
  drawGaugeFill(2, cx[2], cy[2], tempVal, labels[2]);
  drawGaugeFill(3, cx[3], cy[3], humVal, labels[3]);

Inside the main loop, the analog CO and NO2 sensors are read, although for now, random values are used for testing. The temperature and humidity are read from the AHT25 sensor, then converted into percentages or constrained values suitable for gauge display. Each gauge is updated one by one using drawGaugeFill(), providing smooth animation and gradient colour transition. CO, NO2, temperature, and humidity each get their own gauge. After updating the gauges, the code checks if any value crosses a dangerous threshold. If CO, NO2, or temperature exceeds your safety limits, the LED turns red, signalling danger. Otherwise, it stays green. The LED updates every loop cycle, ensuring real-time alert feedback.

Soldering the Circuit

To make the entire circuit permanent and more durable, I decided to solder all components onto a dot board. I began by cutting and placing female header pins that perfectly fit the ESP32 module and each of the sensor modules. These headers allow the components to be inserted and removed easily while ensuring a secure electrical connection. Carefully aligning and soldering the headers provided a strong foundation for mounting the ESP32, the AHT25 sensor, the CO/NO₂ sensors, and the TFT display connections.

After preparing the headers, I carefully soldered all the components onto the dot board following the circuit diagram precisely. Each wire and connection was placed methodically to match the layout, ensuring that power lines, I²C connections, analog inputs, and display pins were correctly routed

3D Designing and Printing

 

To give a proper finish and look, I designed a base for AIR-Buddy.  I designed it using tinkercad, and I printed it using my Bambulab A1. The design has two parts: one front panel and a back panel, both can be screwed together. I used white colour PLA with 20% infill for printing . Download the .stl files from here.

Assembling the AIR-Buddy on the 3D printing Enclosure

After printing the enclosure, I began the assembly process by mounting the TFT display onto the front section of the case. I carefully aligned the screen with the cutout so that the visible area sat perfectly centered, ensuring a clean and professional look. Once positioned, I inserted M3 bolts through the mounting holes from the front and secured them from the back using matching M3 nuts. This firmly locked the display in place, preventing any movement or wobbling. By tightening each screw evenly, the screen sat flush against the enclosure surface, giving the whole front panel a solid and finished appearance.

 

Finished AIR-Buddy

Next, I placed all the remaining components inside the enclosure, arranging them carefully to ensure a clean and secure fit. The ESP32 board, sensors, dot-board assembly, and wiring were positioned in their respective areas so that nothing would move or get strained when the device was closed. After aligning each module properly, I routed the wires neatly to avoid clutter and interference, then secured the internal components using small screws and a bit of hot glue where necessary. Once everything was firmly in place and double-checked, I closed the enclosure, completing the assembly of the AirBuddy device.

Testing AIR-Buddy

 

Finally, I powered up the completed device and tested its full functionality, ensuring every sensor, display element, and indicator worked together exactly as intended. The gauges updated smoothly, the AHT25 reported accurate temperature and humidity values, the CO and NO₂ readings were properly displayed, and the NeoPixel LED changed color according to the alert conditions. The TFT screen rendered all graphics without flicker, and the entire system responded reliably to real-time inputs. After verifying all features under actual operating conditions, I confirmed that the AirBuddy was performing perfectly, marking a successful completion of the project.

Future Updations

 

The IoT functionality, however, was not fully operational at this stage, so I plan to add it as the next update to enable remote monitoring and data logging.

thanks and happy making

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Codes

Downloads

Schematic_air-buddy_2025-11-30 Download
Comments
Ad