MHZ-16 CO2 Sensor, provided example in library broken?

Hello,

I recently received delivery of this CO2 sensor: https://sandboxelectronics.com/?product=mh-z16-ndir-co2-sensor-with-i2cuart-5v3-3v-interface-for-arduinoraspeberry-pi

After doing so I grabbed the arduino ide library folder linked there on their product page. Git hub link: NDIR/ReadConcentration.ino at master · SandboxElectronics/NDIR · GitHub

When I run the example below I get some weird behavior:

#include <Wire.h>
#include <NDIR_I2C.h>

NDIR_I2C mySensor(0x4D); //Adaptor's I2C address (7-bit, default: 0x4D)

void setup()
{
    Serial.begin(9600);

    if (mySensor.begin()) {
        Serial.println("Wait 10 seconds for sensor initialization...");
        delay(10000);
    } else {
        Serial.println("ERROR: Failed to connect to the sensor.");
        while(1);
    }
}

void loop() {
    if (mySensor.measure()) {
        Serial.print("CO2 Concentration is ");
        Serial.print(mySensor.ppm);
        Serial.println("ppm");
    } else {
        Serial.println("Sensor communication error.");
    }

    delay(1000);
}

First I discovered that what it's wired to the 5V power on the Uno directly I get the error message in void setup immediately. Same with the 3.3V option. When I connect the VCC & GND for the sensor to an external power supply I no longer get the error. Instead it simply hangs on a blank serial monitor. Doesn't even display the "Wait 10 seconds for sensor initialization..." statement.

This tells me that I was first supplying insufficient power due to the I/O pins on the Uno maxing out at 40mA while the MHZ-16 spec sheets states an average current of < 60mA. So it was an improvement from getting the "ERROR: Failed to connect to the sensor." message.

So does this mean there is an issue with the mySensor.begin() function?

From the library files:

uint8_t NDIR_I2C::begin()
{
    if (i2c_addr) {
        WIRE.begin();
        write_register(IOCONTROL, 0x08);

        if (write_register(FCR, 0x07)) {
            if (write_register(LCR, 0x83)) {
                if (write_register(DLL, 0x60)) {
                    if (write_register(DLH, 0x00)) {
                        if (write_register(LCR, 0x03)) {
                            if (measure()) {
                                return true;
                            }
                        }
                    }
                }
            }
        }
    }

    return false;
}

I've never had to dig through the libraries before to troubleshoot. Would any of you have any insight into why this setup function simply hangs with proceeding? Could the sensor simply be DOA?

Hmmm, okay, I think it might be a DOA item.

Ran the I2C scanner sketch found here: Arduino Playground - I2cScanner

Picked up my SHT20 Temp/Hum sensor no problem but just hangs at "Scanning..." when the MHZ-16 is connected. Doesn't even go to the "No I2C Devices Found" message.

So there's something wrong with the module that does the switching to I2C is what I'm concluding from this.

Would any of you have any other things I could try to disqualify DOA as the culprit?

Did you set the I2C/UART switch to the I2C position?