How to Use MQ-135 to Detect Gases

In this tutorial, you will learn how to detect gas with an MQ-135 sensor and an Arduino.

Parts Required

  • Arduino
  • MQ-135 Gas Sensor
  • Jumper wires
  • Breadboard

Circuit

MQ-135 Air Quality Sensor Tutorial | Microcontroller Tutorials

To use the LED connect it to digital pin 13.

Code

int sensorValue;
int digitalValue;
void setup()
{

Serial.begin(9600); // sets the serial port to 9600
pinMode(13, OUTPUT);
pinMode( 3, INPUT);

}


void loop()

{

sensorValue = analogRead(0); // read analog input pin 0

digitalValue = digitalRead(2); 
if(sensorValue>400)
{
digitalWrite(13, HIGH);
}
else
digitalWrite(13, LOW);
Serial.println(sensorValue, DEC); // prints the value read
Serial.println(digitalValue, DEC);

delay(1000); // wait 100ms for next reading

}

References

[1] https://microcontrollerslab.com/interfacing-mq-135-gas-sensor-arduino/

Leave a Reply

Your email address will not be published. Required fields are marked *

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock