The MQ-135 sensor detects harmful gases in the air, such aas NH3, NOx, alcohol, and benzene.
The sensing element reacts to concentrations of certain gases by changing its resistance.
To wire the gas sensor up to an Arduino, connect the VCC and GND appropriately, and the signal wire to an analog pin, in this example pin 0.
Making the firmware
In this example, we're using a threshold value of '200'. When the sensed value is greater than that, the on-board LED is turned on.
Instead of turning on a LED, you can sound a buzzer or start a fan motor.
This screenprint shows all there is to it: a sensor defined, and a basic logic rule to switch the LED on or off depending on the sensor value.
MQ gas sensors have a heating element and need approx. 180 mA to power the heating element, so you can't power a lot of them from one microcontroller.