Good day everyone!
Has anyone tried interfacing an NDIR CO2 module to arduino?
I'm trying to use a Telaire T6004 CO2 module that I ordered from the net. I want to get analog values so that I could make a monitoring system. WHAT PINS SHOULD I USE? Is the method of getting values from this sensor similar with a simple voltage divider using potentiometer? Im new with arduino but I need to learn it quickly. I would be grateful if someone would help me in understanding the requirements in order to communicate this NDIR CO2 module with arduino. Attached is a product description of the module.
Also, i have seen a youtube video that was using the same sensor module, and it made me realize that it could really be possible, unfortunately, there was no clear description on how he was able to interface and code it with his 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.
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?
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.
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.
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.