Troubleshooting

Robot CO sensor does not work

userHead Dirk Jan.de Haan 2023-03-09 23:42:13 258 Views2 Replies

Hi, I bought the CO sensor, and connected it to a ESP32 Wrover board, I2C pins. Although the sensor is found on its address, there is no reading from it. It came on I2C-address 0x74, I also tried 0x77 (switch A0 and A1 switches to 1). Sel switch i s0. What I made is this (Arduino code in PlatformIO), see below. Below that the logging. What goes wrong?? Note: there is several other sensors on the I2C bus, with different addresses.

 

 

#include "DFRobot_MultiGasSensor.h"

#define I2C_COMMUNICATION

#define I2C_ROBOT 0x77

DFRobot_GAS_I2C Robot(&Wire, I2C_ROBOT);

 

 

setupRobot is called in setup()

readRobot is called in loop() every 30 seconds

 

void setupRobot()

{

  Robot.setI2cAddr(I2C_ROBOT);

  if (!Robot.begin()) ESP_LOGV("ROB", "DFROBOT not begin");

  Robot.changeAcquireMode(Robot.PASSIVITY);

  delay(1000);

  Robot.setTempCompensation(Robot.OFF);

}


 

void readRobot()

{

 

  if(true==Robot.dataIsAvailable())

  {

    Serial.println("========================");

    Serial.print("gastype:");

    Serial.println(AllDataAnalysis.gastype);

    Serial.println("------------------------");

    Serial.print("gasconcentration:");

    Serial.print(AllDataAnalysis.gasconcentration);

    if (AllDataAnalysis.gastype.equals("O2"))

      Serial.println(" %VOL");

    else

      Serial.println(" PPM");

    Serial.println("------------------------");

    Serial.print("temp:");

    Serial.print(AllDataAnalysis.temp);

    Serial.println(" ℃");

    Serial.println("========================");

  }

  ESP_LOGV("ROB", "DFROBOT CO %f ppm", Robot.readGasConcentrationPPM());

}


Output:

========================
gastype:
------------------------
gasconcentration:0.00 PPM
------------------------
temp:-273.15 ℃
========================
[120886][V][main.cpp:573] readRobot(): [ROB] DFROBOT CO 0.000000 ppm

 

 

Result of I2C port scan is:

{"Scanning" : "
I2C device found at address 0x38
I2C device found at address 0x48
I2C device found at address 0x62
I2C device found at address 0x76
I2C device found at address 0x77
done
"}

 

 

2023-03-10 00:57:21

Ok did a test with above code that proves the sensor works indeed. 

Issue solved and topic can be closed!

userHeadPic Dirk Jan.de Haan
2023-03-09 23:59:51

Well, I found one mistake allready: I copied the wrong demo code. When I use in my loop():

  Serial.print("Ambient ");

  Serial.print(Robot.queryGasType());

  Serial.print(" concentration is: ");

  Serial.print(Robot.readGasConcentrationPPM());

  Serial.println(" %vol");

  //The measurement unit will only be %vol when the sensor is SEN0465

  //Otherwise the unit will be PPM

  Serial.print("The board temperature is: ");

  Serial.print(Robot.readTempC());

  Serial.println(" ℃");

  Serial.println();

 

I get:

Ambient CO concentration is: 0.00 %volThe board temperature is: 22.25 ℃

[122065][V][main.cpp:566] readRobot(): [ROB] DFROBOT CO 0.000000 ppm

 

Which makes sense, the CO concentration could be 0 indeed (could it?). The temp seems a real reading…

userHeadPic Dirk Jan.de Haan