Cheap CO2 meter using the MQ135 sensor with AVR ATmega

Summary of Cheap CO2 meter using the MQ135 sensor with AVR ATmega


This article details the calibration of an MQ135 air quality sensor to measure CO2 levels. It explains deriving a power function from the datasheet to convert resistance ratios into ppm values. The author calibrates the sensor using atmospheric CO2 as a reference and validates results by correlating raw ADC data with an MHZ14 NDIR infrared sensor, logging the information via Xively.

Parts used in Cheap CO2 meter using the MQ135 sensor:

  • MQ135 Air Quality Sensor
  • AVR ATmega microcontroller
  • MHZ14 NDIR infrared sensor
  • Xively datastream for data logging

MQ135 is an Air Quality Sensor suitable for detecting of NH3, Alcohol, Benzene and other gases.

Cheap CO2 meter using the MQ135 sensor with AVR ATmega
The description below, is what i derive from the poor datasheet of this sensor, it may be uncorrect, so if you have suggestions please leave me a feedback.
The “sensitivity characteristics of the MQ-135” figure of the datasheet, you can see it below, it is used to convert the output of the sensor to the related ppm physical physical charateristic for the gas under test.
The graphic above seems a power function
y = a*x^b
so
ppm = a*(Rs/Ro)^b
using power regression, we can obtain scaling factor (a), and exponent (b), for the gas we would like to measure
Then
Ro = Rs * sqrt(a/ppm, b) = Rs * exp( ln(a/ppm) / b )

So, if we want to calibrate a sensor, we “just” need a know amount of a certain gas, then we can read the resistance output value from the sensor (Rs), and we can compute the calibrated Ro value.
We know the current amount of CO2 gas in atmosphere http://co2now.org/, we can use this as a reference for calibration.
Datasheet tell us even detecting concentration scope for a certain gas, so we can compute the limit for Rs/Ro.
Rs/Ro_limit = (ppm/a) ^ (1/b)
Now, because i want to build a CO2 meter, let’s try to calibrate this sensor for measure CO2.
For CO2, if we measure points graph and do power regression we can obtain the function

ppm = 116.6020682 (Rs/Ro)^-2.769034857
we also know that the current amount of CO2 gas in atmosphere is (unfortunately) 392ppm, so, heating the sensor for 24 hours, and leaving it in open air, if we measure 26954ohm as the resistance output we can Ro should be 41763.
Datasheet does not tell us much for detecting concentration scope for this gas, the figure is from 10 to 200ppm, but we can suppose a limit from 10 to 2000ppm.
The above derivation seems to works quite well, but for estimating the scaling factor, and exponent in a more precise way, i’ve logged raw adc data from MQ135 and correlated to a MHZ14 NDIR infrared sensor.
Data was logged on a xively datastream.Schematic Cheap CO2 meter using the MQ135 sensor with AVR ATmega
For more detail: Cheap CO2 meter using the MQ135 sensor with AVR ATmega

Quick Solutions to Questions related to Cheap CO2 meter using the MQ135 sensor:

  • How can you convert the sensor output to ppm?
    You can use a power function derived from the datasheet where ppm equals a times Rs divided by Ro raised to the power of b.
  • What gas is used as a reference for calibration?
    The current amount of CO2 gas in the atmosphere is used as a reference for calibration.
  • How do you compute the calibrated Ro value?
    You read the resistance output value Rs and compute Ro using the formula involving the scaling factor and exponent.
  • Can you estimate the detection limit for the sensor?
    Yes, you can compute the limit for the Rs divided by Ro ratio based on the concentration scope provided in the datasheet.
  • Why did the author log raw ADC data?
    To estimate the scaling factor and exponent in a more precise way by correlating it with another sensor.
  • Which sensor was used to validate the MQ135 measurements?
    An MHZ14 NDIR infrared sensor was used to correlate and validate the raw data.
  • Where was the logged data stored?
    The data was logged on a Xively datastream.
  • What is the assumed detection range for CO2 in this project?
    The author supposes a limit from 10 to 2000ppm since the datasheet figure only shows 10 to 200ppm.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top