MQ135 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