Site Overlay

MQ135 Sensor – calibrate and configure

MQ135 Sensors are usable as an air quality sensor for detecting a wide range of gases, including NH3, NOx, alcohol, benzene, smoke and CO2

For me, these sensors should be affordable by the price but also deliver acceptable measurements. That’s the reason I decided to test this MQ135 Sensor. Five of them are available in our region even with amazon for 11€ which make these little guys inexpensive and easily available.



  • High Sensitivity
  • High sensitivity to Ammonia, Sulfide and Benze
  • Stable and Long Life
  • Detection Range: 10 – 300 ppm NH3, 10 – 1000 ppm Benzene, 10 – 300 Alcohol
  • Heater Voltage: 5.0V
  • Dimensions: 22mm x 34mm
  • Long life and low cost


  • Domestic air pollution detector
  • Industrial air pollution detector
  • Portable air pollution detector

Before you start using this MQ135 Sensor, they need to burn-in. This means you have to connect them to 5V and let them run for at least 12-24h. Afterwards, we have to calibrate the measurement

I you received a sensor like mine, you will notice that this little resistor whoch is connected against ground is arround 1K Ohm, this as a bit of a problem as the basic arduino libary calculates with 22K Ohm.

You can use this libarys which has been corrected

A common mistake is that RLOAD is define as 22 (22K Ohm) or 1 (1K Ohm). You should use ohm here for your calculation which result in RLOAD of 1000 instead of 1

/// The load resistance on the board
#define RLOAD 1000
/// Calibration resistance at atmospheric CO2 level
#define RZERO 22500

After your MQ135 Sensor was running for the burning period you can use the following example to capture your RZERO for calibration

//check the used library and your sensor for this settings (1k vs 22k resistor)
//#define RLOAD 1000
// This value needs to be captured first
#define RZERO 1

#include "MQ135.h" 
MQ135 gasSensor = MQ135(A0); 
int val; 
int sensorPin = A0; 
int sensorValue = 0; 
void setup() { 
  pinMode(sensorPin, INPUT); 
void loop() { 
  val = analogRead(A0); 
  Serial.print ("raw = "); 
  Serial.println (val); 
  float zero = gasSensor.getRZero(); 
  Serial.print ("rzero: "); 
  Serial.println (zero); 
  float ppm = gasSensor.getPPM(); 
  Serial.print ("ppm: "); 
  Serial.println (ppm); 

You should run the sketch from above for at least 30min outside in the fresh air to capture your RZERO. My correction value was around 22500. If you adjust the used library to the collected correction value you should end up with around ~400ppm outside.

More detailed information about this MQ135 Sensor can be found here, unforcedly different documentations exits so make sure if you want to dig deeper that you are searching for the correct one.

1 thought on “MQ135 Sensor – calibrate and configure

  1. Appreciate it for helping out, wonderful info. „The four stages of man are infancy, childhood, adolescence, and obsolescence.“ by Bruce Barton.

Comments are closed.