Home > Arduino > Air Quality Sensor With Arduino

08/12/2023

Air Quality Sensor With Arduino

Writing about Air Quality Sensor With Arduino for educational and informational purposes only. however, do not hesitate to use this information on your own risk as we make no warranty of any kind.

Monitoring Air Quality with Arduino


#include 
#include 
#include 
#define OLED_RESET 4
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32
#define OLED_RESET    -1  // Reset pin not used with this OLED

Adafruit_SSD1306 display(OLED_RESET);

// Air Quality Sensor Pin
const int airQualityPin = A3;

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

  // Initialize with the I2C address of your display
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }

  display.display();
  delay(2000);
  display.clearDisplay();
}

void loop() {
  int sensorValue = analogRead(airQualityPin);

  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0,0);
  display.println("Air Quality:");
  display.setTextSize(2);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0,20);
  display.println(sensorValue);
  display.display();

  delay(1000); // Delay for stability
}


Air Quality Sensor With Arduino
All content and information on this web site is intended for educational and entertainment purposes only.