3952 views|3 replies

1237

Posts

66

Resources
The OP
 

【Infineon XENSIV PAS CO2 sensor】Arduino routine test [Copy link]

Last time I built a test circuit on a breadboard https://en.eeworld.com/bbs/thread-1223050-1-1.html and found that I couldn't read the sensor data. After being pointed out by netizens, it might be the unreliable Dupont line. I took the time to draw a simple Arduino Uno R3 interface compatible expansion board:

The 5V to 12V power module uses a high-end DCDC module (100+ dollars) that MPS offers for free. The effect of the module being plugged into the expansion board is as follows:

Tested using esp32s3 development board:

Test code, using IO17 and IO18 as I2C interface:

#include <Arduino.h>
#include <pas-co2-ino.hpp>

#define I2C_FREQ_HZ  100000                     
#define PERIODIC_MEAS_INTERVAL_IN_SECONDS  10 
#define PRESSURE_REFERENCE  900
#define I2C_SDA 17
#define I2C_SCL 18

PASCO2Ino cotwo;

int16_t co2ppm;
Error_t err;

void setup()
{
    Serial.begin(9600);
    delay(800);
    Serial.println("serial initialized");

    /* Initialize the i2c interface used by the sensor */
    Wire.begin(I2C_SDA, I2C_SCL,I2C_FREQ_HZ);
    //Wire.setClock(I2C_FREQ_HZ);

    /* Initialize the sensor */
    err = cotwo.begin();
    if(XENSIV_PASCO2_OK != err)
    {
      Serial.print("initialization error: ");
      Serial.println(err);
    }

    /* We can set the reference pressure before starting 
     * the measure 
     */
    err = cotwo.setPressRef(PRESSURE_REFERENCE);
    if(XENSIV_PASCO2_OK != err)
    {
      Serial.print("pressure reference error: ");
      Serial.println(err);
    }

    /*
     * Configure the sensor to measureme periodically 
     * every 10 seconds
     */
    err = cotwo.startMeasure(PERIODIC_MEAS_INTERVAL_IN_SECONDS);
    if(XENSIV_PASCO2_OK != err)
    {
      Serial.print("start measure error: ");
      Serial.println(err);
    }

    delay(1000);
}

void loop()
{
    /* Wait for the value to be ready. */
    delay(PERIODIC_MEAS_INTERVAL_IN_SECONDS*1000);

    err = cotwo.getCO2(co2ppm);
    if(XENSIV_PASCO2_OK != err)
    {
      /* Retry in case of timing synch mismatch */
      if(XENSIV_PASCO2_ERR_COMM == err)
      {
        delay(600);
        err = cotwo.getCO2(co2ppm);
        if(XENSIV_PASCO2_OK != err)          
        {
          Serial.print("get co2 error: ");
          Serial.println(err);
        }
      }
    }

    Serial.print("co2 ppm value : ");
    Serial.println(co2ppm);

    /*
     * Assuming we have some mechanism to obtain a
     * pressure reference (i.e. a pressure sensor),
     * we could compensate again by setting the new reference. 
     * Here we just keep the initial value.
     */
    err = cotwo.setPressRef(PRESSURE_REFERENCE);
    if(XENSIV_PASCO2_OK != err)
    {
      Serial.print("pressure reference error: ");
      Serial.println(err);
    }
}

This time we got the correct result, and the sensor outputted the carbon dioxide content data:

appendix

test.rar (1.01 KB, downloads: 0)

I will try to port the Arduino version driver to the STM32 or CH32 platform when I have time.

This post is from Sensor

Latest reply

Does the OP still have the CO2 sensor? Can you give it to me to play with?   Details Published on 2024-9-26 11:36
 
 

6027

Posts

6

Resources
2
 

It's really luxurious. Just put a boost module on it.

This post is from Sensor

Comments

Expensive ones are more fragrant  Details Published on 2022-12-1 21:53
Personal signature

在爱好的道路上不断前进,在生活的迷雾中播撒光引

 
 
 

1237

Posts

66

Resources
3
 
Qintianqintian0303 posted on 2022-12-1 16:47 It's really luxurious. Just put a boost module at will

Expensive ones are more fragrant

This post is from Sensor
 
 
 

1228

Posts

0

Resources
4
 

Does the OP still have the CO2 sensor? Can you give it to me to play with?

This post is from Sensor
Personal signature

喝最烈的酒,..DIY最实用的东西

 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list