INTERFACING NDIR CO2 MODULE WITH ARDUINO

From the datasheet it looks to me that the AVOUT pin provides 0 to 4V depending on the level of CO2. So you could connect that pin directly to an analog input. The only other pins I think you need to connect are +5V and ground.

Okay thank u sir.

The datasheet can be found at: ....?

How can I calculate PPM. If my analog output voltage is 0-4V? and the sensitivity of the CO2 sensor is 0-2000PPM? Pls help!

vmandin:
How can I calculate PPM. If my analog output voltage is 0-4V? and the sensitivity of the CO2 sensor is 0-2000PPM? Pls help!

If 0V is 0ppm and 4V is 2000ppm and the device is linear and you are using the standard 5V analog reference, then:

ppm = (analog_reading * 2000 * 5)/(1024 * 4)

You'll need to use unsigned long arithmetic to avoid overflow, e.g. this code:

  unsigned int ppm = ((unsigned long)analogRead(pin) * 2500)/1024;

Thank u so much sir. How about if 0ppm is 1V and 2000ppm is 4V? how is that calculated?

robtillaart:
The datasheet can be found at: ....?

vmandin:
Thank u so much sir. How about if 0ppm is 1V and 2000ppm is 4V? how is that calculated?

ppm = (analog_reading * 3000 * 5)/(1024 * 4) - 1000

However, if your 5V supply (the default analog reference) is not very accurate then you will have a significant zero error. If the sensor has a digital output, it would be better to use that.

vmandin:
However, if your 5V supply (the default analog reference) is not very accurate then you will have a significant zero error. If the sensor has a digital output, it would be better to use that.

Yes sir, the sensor has a digital output. What exactly is the difference in measurements if I use the digital or analog? And how is it done?

vmandin:
Yes sir, the sensor has a digital output. What exactly is the difference in measurements if I use the digital or analog? And how is it done?

The device seems to have analogue, serial and SPI interfaces. The data sheet says...

SPI/Microwire or UART @9600 baud
(Please call for detailed protocol specification)

Riva:

vmandin:
Yes sir, the sensor has a digital output. What exactly is the difference in measurements if I use the digital or analog? And how is it done?

The device seems to have analogue, serial and SPI interfaces. The data sheet says...

SPI/Microwire or UART @9600 baud
(Please call for detailed protocol specification)

Yes, its on the data sheet. I just don't know how to use it yet. I would like to know how accurate is the digital output than the analog.

Reading serial would be relatively easy so just setup a test bench where your reading the analogue pin and serial data as close to the same time as possible and compare the results over the range your looking for. You will then know how good your analogue calculations are.

Hi Riva. I can see the spi pins marked in the documentation. Can you tell me which pin is the analog. Is it pin 4? Thanks.

koaiwi:
Hi Riva. I can see the spi pins marked in the documentation. Can you tell me which pin is the analog. Is it pin 4? Thanks.

Assuming your device is the same as this TELAIRE | CO2, HUMIDITY & DUST SENSORS then the datasheet shows pin 4 is the analogue out. FYI pin 10 is TX and pin 11 is RX and the data sheet says 9600 boud if you want to compare to serial. To read SPI your probably going to have to ask the manufactures as you will need register information to do this.

NDIR Pinout.jpg

Thanks for your feedback.

Thank U Riva & DC42

what if I would just map the values? Pls inspect my assumption.

like this one,

int sensorValue = analogRead(A0);
int partspermillion = map(sensorValue, 205, 818, 0, 2000);

a support from telaire told me that 1V=205bits and 4V=818bits
since the sensors sensitivity is from 0-2000ppm

can this method be accurate?

I have a NDIR with voltage output of 0.8 - 4 VDC and the CO2 measurement is from 0 - 2000 ppm. From previous posting, the voltage output range is quite good, that is from 0 - 4 DC,1-5 DC and not fraction as above etc. Then there is a function map(). Which is better to use function map() or to calculate. Thank you in advance for any advice.

Then there is a function map(). Which is better to use function map() or to calculate. Thank you in advance for any advice.

0.8V = 163,68 (1..1023@5V)
4.0V = 818,4
map() is integer math, so the formula will look like: ppm = map(analogRead(A0), 164, 818, 0, 2000);
you see at least 2 (small) roundings. Furthermore you have only about 654 steps (steps of 3)
Even if youaverage multiple readings this will stand.

If you calculate you can get more accurate number when you calculate the PPM as float.

in the snippet below you can compare the two methods:

void loop()
{
  float value = (analogRead(A0) * 3.0  + previous) / 4.0;    // apply low pass filter - weighted average of new reading and prev reading
  float ppmF= (value -163.68) * 2000 / (818.4 -163.68);    // can be optimized to PPM = (value -163.68) * 3.05474096;

  int ppmI = map(value, 164, 818, 0, 2000);

  Serial.print("PPM int: ");
  Serial.println(ppmI, DEC);

  Serial.print("PPM float: ");
  Serial.println(ppmF, 1);  // 1 decimal place

  delay(1000);
}

you might need to check the math, and you must be sure that the Arduino gets 5.00V
as when it gets e.g. 4.95 or 5.05 the readings will be affected of course.

give it a try.

I'm using https://co2meters.com/Documentation/AppNotes/AN157-T6613-Arduino-uart.pdf