Arduino Nano-Based Air Quality Monitor with OLED Display and Alert Buzzer
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
The circuit in question is designed around an Arduino Nano microcontroller and includes a variety of sensors and output devices. The primary components include a buzzer for audible alerts, an Adafruit SGP30 for air quality measurements, an Adafruit SHTC3 STEMMA QT for temperature and humidity readings, and a 0.96" OLED display for visual data output. The circuit utilizes I2C communication for sensor data and controls the buzzer through one of the digital pins of the Arduino Nano.
Component List
Buzzer
- Description: A simple piezoelectric buzzer used for generating audible alerts.
- Pins: PIN (signal), GND (ground)
Arduino Nano
- Description: A compact microcontroller board based on the ATmega328P, which is the brain of the circuit.
- Pins: D1/TX, D0/RX, RESET, GND, D2 to D13, VIN, 5V, A0 to A7, AREF, 3V3
Adafruit SGP30
- Description: An air quality sensor capable of measuring volatile organic compounds (VOCs) and equivalent CO2 (eCO2) levels.
- Pins: VCC, 3.3V, GND, SCL, SDA
Adafruit SHTC3 STEMMA QT
- Description: A high-accuracy temperature and humidity sensor.
- Pins: VCC, 3.3V, GND, SCL, SDA
0.96" OLED
- Description: A small OLED display for showing sensor readings and other information.
- Pins: GND, VDD, SCK, SDA
Wiring Details
Buzzer
- PIN: Connected to Arduino Nano D3
- GND: Connected to Arduino Nano GND
Arduino Nano
- D3: Connected to Buzzer PIN
- GND: Common ground with Buzzer, 0.96" OLED, Adafruit SHTC3, and Adafruit SGP30
- 5V: Powers the 0.96" OLED and Adafruit SGP30
- A5: Connected to SCK of 0.96" OLED, SCL of Adafruit SHTC3, and SCL of Adafruit SGP30 for I2C communication
- A4: Connected to SDA of 0.96" OLED, SDA of Adafruit SHTC3, and SDA of Adafruit SGP30 for I2C communication
- 3V3: Powers the Adafruit SHTC3
Adafruit SGP30
- VCC: Powered by Arduino Nano 5V
- GND: Common ground with Arduino Nano
- SCL: Connected to Arduino Nano A5
- SDA: Connected to Arduino Nano A4
Adafruit SHTC3 STEMMA QT
- 3.3V: Powered by Arduino Nano 3V3
- GND: Common ground with Arduino Nano
- SCL: Connected to Arduino Nano A5
- SDA: Connected to Arduino Nano A4
0.96" OLED
- GND: Common ground with Arduino Nano
- VDD: Powered by Arduino Nano 5V
- SCK: Connected to Arduino Nano A5
- SDA: Connected to Arduino Nano A4
Documented Code
#include <Wire.h>
#include <Adafruit_SGP30.h>
#include <Adafruit_SHTC3.h>
#include <Adafruit_SSD1306.h>
Adafruit_SGP30 sgp;
Adafruit_SHTC3 shtc3 = Adafruit_SHTC3();
Adafruit_SSD1306 display(128, 64, &Wire);
void setup() {
Serial.begin(9600);
Wire.begin();
// Initialize SGP30
if (!sgp.begin()) {
Serial.println("SGP30 not found");
while (1);
}
// Initialize SHTC3
if (!shtc3.begin()) {
Serial.println("SHTC3 not found");
while (1);
}
// Initialize OLED
if (!display.begin(SSD1306_I2C_ADDRESS, OLED_RESET)) {
Serial.println("SSD1306 allocation failed");
while (1);
}
display.display();
delay(2000);
display.clearDisplay();
}
void loop() {
// Read SGP30
if (!sgp.IAQmeasure()) {
Serial.println("SGP30 measurement failed");
return;
}
// Read SHTC3
sensors_event_t humidity, temp;
if (!shtc3.getEvent(&humidity, &temp)) {
Serial.println("SHTC3 measurement failed");
return;
}
// Display on OLED
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.print("CO2: ");
display.print(sgp.eCO2);
display.println(" ppm");
display.print("TVOC: ");
display.print(sgp.TVOC);
display.println(" ppb");
display.print("Temp: ");
display.print(temp.temperature);
display.println(" C");
display.print("Humidity: ");
display.print(humidity.relative_humidity);
display.println(" %");
display.display();
// Buzzer logic (example)
if (sgp.eCO2 > 1000) {
digitalWrite(3, HIGH); // Turn on buzzer
} else {
digitalWrite(3, LOW); // Turn off buzzer
}
delay(1000);
}
This code initializes and reads data from the SGP30 and SHTC3 sensors, displays the readings on the OLED, and activates the buzzer if the eCO2 level exceeds 1000 ppm. The Wire library is used for I2C communication, and the Adafruit_SGP30, Adafruit_SHTC3, and Adafruit_SSD1306 libraries are used to interface with the respective components.