Sheekar Banerjee
Published © CC0

MQ-135 Sensor (CO2, Benzyne) with Arduino | Sheekar Banerjee

The MQ-135 sensor is usually used to measure the level of CO2, Benzene, Sulfide or Ammonia in the air.

IntermediateShowcase (no instructions)13,587
MQ-135 Sensor (CO2, Benzyne) with Arduino | Sheekar Banerjee

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Arduino MQ-135 Gas Sensor
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Circuit Diagram of MQ135 Sensor with Arduino UNO R3

Code

Program of MQ-135 Sensor (CO2) with Arduino UNO R3

Arduino
This code is for measuring Carbon Dioxide (CO2)
//Coded and tested by: 
//Sheekar Banerjee, AI-ML-IOT Solution Engineer and Researcher

void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  Serial.println("The amount of CO2 (in PPM): ");
  Serial.println(sensorValue);
  delay(2000);
}

Program of MQ-135 Sensor (Acetone) with Arduino UNO R3

Arduino
This Code for measuring Acetone(C3H6O) with MQ-135 Sensor
//Coded and tested by:
//Sheekar Banerjee, AI-ML-IOT Solution Engineer and Researcher

int R0 = 176;
int R2 = 1000;
float RS;
float PPM_acetone;
 
void setup() {
   Serial.begin(9600);
}
 
void loop() {
   // read the input on analog pin 0:
   int sensorValue = analogRead(A0);
   // convert to voltage:
   float volts = sensorValue * 5;
   volts = volts / 1023;
   // calculate RS
   RS = R2 * (1-volts);
   RS = RS/volts;
   // calculate acetone PPM
   PPM_acetone = 159.6 - 133.33*(RS/R0);
   // print out the acetone concentration:
   Serial.println("Acetone (C3H6O) Value: ");
   Serial.println(PPM_acetone);
   delay(3000); // delay in between reads for stability
}

Credits

Sheekar Banerjee

Sheekar Banerjee

0 projects • 6 followers
A motivated Computer Scientist & Engineer with years of experience over IoT, Robotic Systems, Machine Learning Algorithms and Software.

Comments