From ArduinoInfo
Jump to navigation Jump to search

Air Quality and Gas Sensors:

MQ135 Air Quality Sensor

Reads values from an air quality sensor connected to the analog input pin 0. The value read from the sensor is proportional to the air quality measured by the sensor. The value read is printed to the serial monitor.MQ135-200.jpg


Here we show the pin-out and a possible wiring approach for this sensor. Connect the "B" terminal to Analog input 0.
Here is a quick software sketch to test it:
/* Example Software Sketch MQ135 Air Quality Sensor */ /*-----( Import needed libraries )-----*/ /*-----( Declare Constants )-----*/ /*-----( Declare objects )-----*/ /*-----( Declare Variables )-----*/ int sensorValue; void setup() /*----( SETUP: RUNS ONCE )----*/ { Serial.begin(9600); }/*--(end setup )---*/ void loop() /*----( LOOP: RUNS CONSTANTLY )----*/ { sensorValue = analogRead(0); // read analog input pin 0 Serial.println(sensorValue, DEC); // prints the value read delay(100); }/* --(end main loop )-- */ /*-----( Declare User-written Functions )-----*/ /* ( THE END ) */