How to make (CM1106) CO2 Sensor work?

Hello all ! I am a complete beginner with regards to sensors. I would like to get help on the wiring for the CM1106 CO2 sensor, so that it outputs a value between 0 and 2000 ppm.

I’ve included the most comprehensive datasheet I could find and down below example code provided by the CM1106 library. Thanks!

#include <cm1106_i2c.h>

CM1106_I2C cm1106_i2c;

void setup() {
  cm1106_i2c.begin();
  Serial.begin(9600);
  delay(1000);
  cm1106_i2c.read_serial_number();
  delay(1000);
  cm1106_i2c.check_sw_version();
  delay(1000);
}

void loop() {
  uint8_t ret = cm1106_i2c.measure_result();

  if (ret == 0) {
    Serial.print("Co2 : ");
    Serial.println(cm1106_i2c.co2);
    Serial.print("Status : ");
    switch (cm1106_i2c.status) {
      case CM1106_I2C_STATUS_PREHEATING: {
          Serial.println("Preheating");
          break;
        }
      case CM1106_I2C_STATUS_NORMAL_OPERATION: {
          Serial.println("Normal operation");
          break;
        }
      case CM1106_I2C_STATUS_OPERATING_TROUBLE: {
          Serial.println("Operating trouble");
          break;
        }
      case CM1106_I2C_STATUS_OUT_OF_FS: {
          Serial.println("Out of FS");
          break;
        }
      case CM1106_I2C_STATUS_NON_CALIBRATED: {
          Serial.println("Non calibrated");
          break;
        }
    }
  }
  delay(1000);
}

W-Cubic_CM1106_DS.pdf (458 KB)

It is not clear that the library matches the sensor that you have produced a data sheet for.
The library name (there is a library named CM1106 integrated with the Arduino library manager) differs from that of the sensor which appears to be CU1106.

Anyway, assuming these are similar enough, the library appears to use the I2C alternative interface of the the sensor (which also supports a standard serial interface)

I'd suggest the following assuming you are using a 5 volt arduino Uno or similar:

connect arduino 5volts to CU1106 connector 4, pin 1
connect arduino ground to CU1106 connector 4, pin 2
connect CU1106 connector 5, pin 4 to ground to switch the device into I2C mode
connect CU1106 connector 5, pin 2 to arduino uno pin A4 (SDA) *
connect CU1106 connector 5, pin 3 to arduino uno pin A5 (SCL) *

  • you may need to try a pullup resistor (between 2k and 10k) between 5 volts and these pins.

From the attachment in the OP:

Thanks for your response! They (school) gave us this datasheet to work with, so that is what I'm using as a reference. The CM1106 datasheets online are similar.

I tried your solution, but it didn't work. I think the problem is the given library, as PWM gives me some weak results :confused:

You also tried with two pull-up resistors between 5v and the I2C lines ?
What Arduino are you using ?

I've used a resistor for each SDA and SCL line, ranging from 2k all the way up to 10k. I've used the Arduino Uno board.

OK. The next thing I would try is to download an I2C scanner, say from here Arduino Playground - I2cScanner to see if your Uno can talk, at a basic level, to your sensor. If it can, it will report the I2C address of your device. You'll still need the pullup resistors.

I’ve tried 10k, 2k, 470, 120 and no resistors. The only result I got was from using no resistors, which is odd to me. However, the result I got was probably inaccurate, as it found multiple devices at multiple addresses.

I see this in the CM1106 library (installed through the Arduino IDE) :

#define CM1106_I2C_ADDRESS 0x31

so I would have expected it to find this address(if the library matches the device).

Are you using a standard bare arduino Uno (ATMEGA328P based) without any other peripherals (real time clock, LCD display etc.) or is it a Uno WiFi or similar which may explain the other devices found.

If you completely remove the sensor and run the I2C scanner, do you still see the same addresses ?

It is a bare Arduino Uno with an ATMEGA328P microchip (without any other peripherals). I’ve recently connected two Arduino’s before using I2C, so I bet the Arduino itself is not the problem. I can also see light fading between bright and dim when the CM1106 sensor receives power. I’ve had a closer look and the sensor has a tiny print on it saying ‘CM1106’.

OK. If it is a normal Uno board and you get consistent results back from the I2C scanner that it finds something at address 0x49 and 0x5F when the sensor is connected and nothing when the sensor is disconnected, then it is clear that the device has 2 separate I2C addresses. That is not impossible. A Real time clock module can also respond with two I2C addresses, one for the clock chip itself and one for the eeprom.

The problem is that without complete documentation, you are tapping around in the dark, so to say.

I get what you’re trying to say. As I said the results are inaccurate and I forgot to mention that the results vary every time. Could there be a possibility that something on the inside is broken? I handle it carefully, so that would surprise me. I’ll add the correct datasheet to this post and I’ll try to change the datasheet from my original post.

W-Cubic_CM1106_DS.pdf (458 KB)

It looks like the connections are the same in both data sheets.

I found this for a similar device which also has an I2C specification: http://en.gassensor.com.cn/uploadfiles/2020/03/20200314132108942.pdf
There it is clear (or at least for that model) that the I2C address is 0x31.

I guess you are supplying the 5 volts to the device from the Arduino and, if not, you have connected the grounds together so these share a common ground. The pullups then go to the Arduino + 5v. Don't try anything lower than 2k when you are experimenting with the pullups.

Maybe supply a diagram of how you have wired it up.

There is always a possibility that the device is broken in some way, but you have said the PWM part functions ?

I will upload my wiring schematic. I’ve tried 2k, 4.5k and 10k ohm worth of resistance.
PWM gave me a certain value followed by a 0. For example, 0, 13, 0, 11, 0.

The wiring looks correct to me. I guess you've checked whether the pin numbering is from the top view or underside of the device. I normally use A4 for SDA and A5 for SCL but the additional Uno pins you have used should have the same effect. Also, some breadboards have split power rails, where the coloured line indicating the polarity is broken at the point where a joint would be required. Those illustrated in your Fritzing diagram look OK.
If the I2C scanner does not give consistent results, then I don't really know what else to suggest.

Yes, I've used CON4 and CON5 to indicate the sides. It's difficult to make a wiring schematic for it, as Fritzing doesn't contain an CM1106 part. Indeed, the SDA and SCL pins should work fine, as I've used it in other I2C projects as well. I will contact my teacher to inform him about this problem. Thanks for your help!