Air Quality Monitor W/alarm

by ScottieDigital in Circuits > Arduino

422 Views, 0 Favorites, 0 Comments

Air Quality Monitor W/alarm

large_display_9d0780bf-a157-41ba-823c-d787c16f9dfa.jpg
PXL_20231021_075412243.jpg
October 21, 2023
October 21, 2023

Monitor your house levels. Gives you temperature, humidity, CO2 levels. Accurately over I2C sensor. With the LED's you can tell from a distance how good the air is. The display can show you values. When levels get dangerous the buzzer will sound.

Supplies

PXL_20231006_223029755.jpg

Arduino Nano

I2C Mutiplexer

.96" OLED display

3V logic converter

USB Micro female power port

Piezo buzzer

5mm LED R,Y,G

SCD - 41 sensor

resistors.

wire

3D printer

hot glue

hardware screws for OLED I only used 2

3D Print

You can find files here >>>>

HERE

Or

HERE

Soldering

PXL_20231021_062619694.jpg

Originally I had a switch but since there is no battery I decided not too. Power Arduino to 5V pin. I use 3V logic board to power sensor. It gets better data. I also tried removing all pullup resistors. But it's up to you. Your data pins are found in code and can be adjust as you like.

Code

 /*   
10/20/2023 Working ScottieDigital
 */
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define LED_PIN1 9
#define LED_PIN2 10
#define LED_PIN3 11
#define BUZZ_PIN1 12
Adafruit_SSD1306 display(128,64,&Wire,4);
const int16_t SCD_ADDRESS = 0x62,I2C_ADDRESS = 0x70,DISPLAY_ADDRESS = 0x3C;
float co2_1, temperature_1, humidity_1,TempF_1;
uint8_t data_1[12], counter_1;


void buzz(){
   tone(BUZZ_PIN1,1000);
   delay(1000);
   noTone(BUZZ_PIN1);
   delay(1000);  
}


void TCA9548(uint8_t bus){
  Wire.beginTransmission(I2C_ADDRESS);
  Wire.write(1 << bus);
  Wire.endTransmission();
}
void setup(){
  Wire.begin();
  pinMode(LED_PIN1, OUTPUT);pinMode(LED_PIN2, OUTPUT);pinMode(LED_PIN3, OUTPUT);pinMode(BUZZ_PIN1, OUTPUT);


  TCA9548(2);
  Wire.beginTransmission(SCD_ADDRESS);
  Wire.write(0x21);
  Wire.write(0xb1);
  Wire.endTransmission();
  
  TCA9548(1);
  display.begin(SSD1306_SWITCHCAPVCC,DISPLAY_ADDRESS);
  delay(500);
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.setTextSize(2);
  display.print("SCD - 41");
  display.setCursor(0,16);
  display.setTextSize(1);
  display.print("Initializing");
  display.setCursor(0,32);
  display.print("...................");
  display.setCursor(0,48);
  display.print("By: ScottieDigital");
  display.display();
  delay(6666);


}
void loop(){
  TCA9548(2);
  Wire.beginTransmission(SCD_ADDRESS);
  Wire.write(0xec);
  Wire.write(0x05);
  Wire.endTransmission();
  Wire.requestFrom(SCD_ADDRESS, 12);
  counter_1 = 0;
  while (Wire.available()) {
    data_1[counter_1++] = Wire.read();
  }
  co2_1 = (float)((uint16_t)data_1[0] << 8 | data_1[1]);
  temperature_1 = -45 + 175 * (float)((uint16_t)data_1[3] << 8 | data_1[4]) / 65536;
  humidity_1 = 100 * (float)((uint16_t)data_1[6] << 8 | data_1[7]) / 65536;
  TempF_1 = (temperature_1*1.8)+32; // convert C to F else use temperature_1
  
  TCA9548(1);
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.setTextSize(2);
  display.print("AirQuality");
  display.setCursor(0,16);
  display.setTextSize(2);
  display.print("T:");
  display.print(TempF_1); // temperature_1 goes here if C
  display.setTextSize(1);
display.print((char)247);
  display.print("F"); // change to C if
  display.setCursor(0,32);
  display.setTextSize(2);
  display.print("H:");
  display.print(humidity_1);
  display.setTextSize(1);
  display.print("%");
  display.setCursor(0,48);
  display.setTextSize(2);
  display.print("C:");
  display.print(co2_1);
  display.setTextSize(1);
  display.print("ppm");
  display.display();
  delay(2000);


  if(co2_1 < 1200){
     digitalWrite(LED_PIN1,HIGH);digitalWrite(LED_PIN2,LOW);digitalWrite(LED_PIN3,LOW);
  }else if(co2_1 > 1200 && co2_1 < 1700){
     digitalWrite(LED_PIN1,LOW);digitalWrite(LED_PIN2,HIGH);digitalWrite(LED_PIN3,LOW);   
  }else if(co2_1 > 1700){
     digitalWrite(LED_PIN1,LOW);digitalWrite(LED_PIN2,LOW);digitalWrite(LED_PIN3,HIGH);
     buzz();    
  }
}

Final

Super glued sensor on top in place. Mounting display in place and close up. The first time closing in place I have to use a adjustable pliers to snap in place. Deburr files ends can interfere. Lastly powering up sensors vary. You might have to adjust in code your output? If things seem to high ask for a replacement and send a picture of you crazy results. I have tested mine and purposely for science made the sensor go crazy to show on video. I was at DANGEROUS levels ONLY to show on video alarm going off. PLEASE DON'T EXPOSE YOURSELF TO DANGEROUS LEVELS IF ALARM IS GOING OFF GET AIR FLOW IMMEDIATELY!!!!

Note: If taken outside. CO2 level should be around 400ppm. Base sensor and change data accordingly. If outside parameters to crazy, ask for replacement.

Also Note: CO2 is a heavy gas. So the lower the sensor to the ground the faster it will go off. Even though it isn't listed in datasheet, it still detect dangerous gas so if a stove left on that wasn't lit. WILL DETECT!

I made this for my mother so that way anybody in the house can know how good the air is. Even if you can't read the display you can see what color the LED is on. Within just a few weeks it has already went off a few times and did it's job! MAKES ME WORRIED THAT WITHOUT THIS PROJECT PEOPLE CAN HAVE SEVERE HEALTH RISKS!

  • HAS BEEN TESTED TO RUN NON-STOP

Project Time: 4 hours

Cost: ~$70 USD