MQ135 CO2 PPM Calculation

Hello all…
I am working on MQ135 Gas sensor for CO2 PPM.
I refer Internet blogs, datasheet, internet codes and i apply in my coding.
I also got result in PPM in range of 420 to 450. is it true or not? What is CO2 PPM in Air?
Also it gives me reading in loop, it can not go beyond 450 PPM.
I used this equation
Rs=( ( 5.0 * RL ) - ( RL * Vout ) ) / Vout, where Vout is ADC value & RL=10
ratio=Rs/R0, where R0 = 76.63
CO2_PPM= (146.15

I also attached image of my hardware

Your 450 PPM reading sounds OK
see e.g

But I’m not too sure about the formula, if this will give you valid readings in all cases.

There are other threads about this sensor too

Is there any other equation for CO2 PPM calculation?

I’d say you need to adapt the calculation for Rs, since you are dealing with a different ADC which gives you a value of 4095 for 3.3V where I only see a 5 in your equation which would correspond to an impossible analog reading of 6204.5 (5.0V/3.3V * 4095 ).
With this in mind, you’d need to correct the equation by use of the Ohm’s Law

But this would definetly not work

since the ADC value is not immediately in Volt but only (3.3V/4095).

With that in mind we could either calculate Vout = analogRead() * 3.3 / 4095.0 or we just “correct” the 5V to that same factor like this

Vout = analogRead();
Rs = RL * (6204.5 - Vout) / Vout;
// instead of 
//Vout = analogRead() * 3.3 / 4095.0;
//Rs = RL * (5.0 - Vout) / Vout;

either way works and with this Rs you can carry on.

For more exact readings you’d need to measure the actual 5V supply and the 3.3V ADC reference voltage and plug these into above formulae.

I’m not sure where this comes from

but that

should be derived from the datasheet/chart.

It always makes me cringe when I see some obscure factors without any reference where they come from or how they can be calculated :stuck_out_tongue_closed_eyes:

1 Like