As it is very important to know the saturation rate of the environment, for example at the workplace, I have looked on the Internet for a sensor that can be used with Arduino to measure the CO2 content. Luckily, I found a sensor that measures air quality. This is the MQ-135, which, as can be seen in the data sheet, can measure certain substances, such as NH3, alcohol, benzene, smoke, CO2, etc. That's how I came across this sensor.
Because I knew there was a chance that he and our ATmega328 Microcontrols I first looked for the safety limit values for CO2 in parts per million (ppm) for apartments, rooms and buildings, which according to various studies can lie between 400 and 800 ppm. Now that I knew the right sensor and the safety limits, it was time to design a useful project that shows us this information and also informs us about temperature and humidity.
The aim of this project is therefore to measure the CO2 concentration in parts per million, to display it on a screen and to give us an acoustic warning when it reaches a dangerous concentration, as well as to inform us about the temperature and humidity. In order to extend the duration of the screen, I thought it would be a good option to install three different color LEDs that give us quick visual information about the level of CO2 concentration without having to see the data. After all this is installed, we can get to work.
Description of the operation of the circuitThe operation of this circuit is very simpleThere, there. MQ-135 sensor measures CO2 concentration in parts per million, DHT-11 sensor measures temperature and humidity. These three data are fed to a two-colour OLED screen with 0, 96 Customs sent to show each value for three seconds in intervals of one minuteI. Dthe screen stays off during this time. These time values can be configured. While the screen remains off, the three LEDs visually inform us about the existing CO2 valuesI. Dit lights green LED if the concentration is equal to or less than 550I. DIf the concentration is between 551 and 799 parts per million CO2, the red LED is lit together with a summerton if the concentration exceeds 799 parts per million. These three values can also be configured.
Preparation and termination of the RZERO resistance reference for atmospheric CO2 contentFirst, the MQ-135 sensor must be prepared to measure the correct values that we will use in the next step. For this purpose, the sensor in its new state must be operated with five volts for approximately two hours in order to eliminate the impurities generated during production. After that it is best to perform the reference balancing of the RZERO resistance in the final circuit, as this is done with the normal supply and operating voltages used and the measurement is optimal.
The purpose of this calibration is to adjust the resistance of the atmospheric CO2 level so that the MQ-135 sensor measures a concentration between 300 and 450 ppm corresponding to the normal concentration of this gas in the environment. It is very important to supply the sensor independently with 5 VDC, as it consumes 850 mW.
When everything is connected, we start the Arduino IDE, load and start the Sketch. "MQ135 calibration.ino". The MQ135 library must be installed firstYeah. We open the serial monitor and see the ppm measurement value; we need to change and store the RZERO value in the MQ135.h file in the Arduino IDE library folder until the ppm measurement value is the one we want to leave as the working reference of the circuit. The value to be changed is the green coloured value.
/// Calibration resistance at atmospheric CO2 level
/// Change this value until the ppm value is 450.
'35; defines RZERO 22500
To do this, we need to change the value of RZERO, save changes to the MQ135.h file of the library in its Arduino IDE folder and reload the calibration sketch, review the new value of the CO2 concentration in the serial monitor and repeat the process to set RZERO to the value, which we want to leave as a reference for the CO2 concentration in the air for the alert limits in the sketch of our project.
Sketch MQ135(download):
'35; includes "MQ135.h"
'35; define RZERO 1
MQ135 gas = MQ135(A0);
int choice;
int sensorPine = A0;
int sensorValue = 0;
void setup() {
Serial.start(115200);
pinMode(sensorPine, INPUT);
}
void run() {
choice = analog(A0);
Serial.print ("raw =");
Serial.Print (choice);
float zero = gas.getRZero();
Serial.print ("crero:);
Serial.Print (zero);
float ppm = gas.getPPM();
Serial.print ("ppm:);
Serial.Print (ppm);
delay(2000);
}
If we have read the CO2 concentration in parts per million correctly, it is time to load the CO2 monitor.ino sketch, which provides us with the information about this concentration, humidity and temperature on site, where we want to measure the values.
Sketch. CO2 monitor(download):
Necessary libraries for the project
%35; include
'35; include
'35; include
'35; include
'35; includes "pitches.h"
Screen parameters ************************************************************
';define SCREEN'u WIDTH 128
''35; define SCREEN'u HEIGHT 64
Adafruit SSD1306 display(SCREEN WIDTH, SCREEN AUTHORITY, &Wire, -1);
/****** Humidity and temperature sensor DHT-11 paramters and variables *****
35; defines DHTPIN 2
35; defines DHTTYPE DHT11
DHT t(DHTPINE, SUBJECT);
float t, h;
/**************** MQ-135 sensor parameter and variables **********************
'35; define RZERO 1
'35; includes "MQ135.h"
MQ135 gas = MQ135(A0);
int choice;
int sensorPine = A0;
int sensorValue = 0;
float ppm, zero;
**************************************************************************
';define green ice 3
''35; defines amarillo ice
''35; defines the ice
unsuitable long anterior tibia; Time counter
*********************SETUP BLOCK ***********************************************
void setup( )
{
Serial.start(115200);
t.start(); // DHT-11 initialization
if(!display.start(SWITCHCAPVCC SSD1306, 0x3C)) { // Checking display present
Serial.Print(F("SSD1306 allocation failed"));
for(;;);
}
delay(2000);
display.Clear(); // Initialization screen and
display.setTextColor(WHITE); // config text color
pinMode(sensorPine, INPUT); // MQ-135 pin data
pinMode(Ice green, OUTPUT);
pinMode(Ice amarillo, OUTPUT);
pinMode(Ice cream, OUTPUT);
digitalWrite(Ice green, LOW);
digitalWrite(Ice amarillo, LOW);
digitalWrite(Ice cream, LOW);
}
*********************LOOP BLOCK *********************************************
void run( ) {
t = t.readTemperature(); Read temperature
h = t.readHumidity(); Read Humidity
if (Issan(h) || Issan(t)) { If there aren't temperature and
Serial.Print("DHT sensor reading Fallo!!!"); // humidity read, show message to inform
}
choice = analog(A0); // CO2 read
zero = gas.getRZero(); // Calibration value for the MQ-135 sensor
ppm = gas.getPPM(); // Formula in the library for obtaining the ppm of CO2
Czech ice (); Go and run to LEDs check method
Serial.print( "T =" ); Show values by the Serial Port
Serial.print(t);
Serial.print("C, H =");
Serial.print(h);
Serial.print( "%, " );
Serial.print ("raw =");
Serial.print (choice);
Serial.print ("Rope:"Rope);
Serial.print (zero);
Serial.print ("ppm, ppm);
Serial.Print (ppm);
delay (1000);
if ( millis()-anterior tibia >= 60000) { If the time past is most or equal than 60 sg
Pandalum encendido(); Execute the turn on screen method.
anterior tibia = millis(); Save the current time.
}
}
void Czech ice() {
if (ppm >= 800) { If the CO2 concentration is equal o most than 800
digitalWrite(Ice cream, HIGH); Turn on the red LED
tonnes(8, Note C5, 5000); // Buzzer sound
display.Clear(); // Set the screen parameters to show the PPM value
display.setTextSize(2);
display.setCursor(7,0);
display.print("CO2 (PPM):");
display.setTextSize(3);
display.setCursor(40,35);
display.print(ppm,0);
display.display();
delay(10000);
} ed {
digitalWrite(Ice cream, LOW);
display.Clear();
display.display(); }
if (ppm >= 551 && ppm <= 799) {
digitalWrite(Ice amarillo, HIGH); The yellow LED turno on if the CO2 concentration
} ed {
digitalWrite(Ice amarillo, LOW); } // is between 551 and 799
if (ppm <= 550) {
digitalWrite(Ice green, HIGH); The green LED turn on only when the CO2
} ed {
digitalWrite(Ice green, LOW); } /concentration is most low than 551
}
void Pandalum encendido() { Turn on screen method
display.Clear(); // Set the screen parameters and show the PPM value
display.setTextSize(2);
display.setCursor(7,0);
display.print("CO2 (PPM):");
display.setTextSize(3);
display.setCursor(40,35);
display.print(ppm,0);
display.display();
delay(3000);
display.Clear(); // Set the display parameters and show the Humidity value
display.setTextSize(2);
display.setCursor(20,0);
display.print("Homemade:");
display.setTextSize(3);
display.setCursor(20,35);
display.print(h,1);
display.setCursor(90,35);
display.print("%");
display.display();
delay(3000);
display.Clear(); // Set the display parameters and show the Temperature value
display.setTextSize(2);
display.setCursor(40,0);
display.print(TEMP:);
display.setTextSize(3);
display.setCursor(5,35);
display.print(t,1);
display.setCursor(85,35);
display.cp437(true);
display.write(167);
display.setCursor(107,35);
display.print(C);
display.display();
delay(3000);
display.Clear();
display.display();
}
Comments