This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SIMPLELINK-CC2640R2-SDK: Integration of I2C protocol based sensor with CC2640R2F

Part Number: SIMPLELINK-CC2640R2-SDK
Other Parts Discussed in Thread: CC2640R2F

void scd30_read(float* scd30_co2, float* scd30_T, float* scd30_RH)
{
    uint8_t txBuffer[2];
    uint8_t rxBuffer[18];

    unsigned int tempU32;

    // send command for getting firmware version
    txBuffer[0] = SCD30_CMD_READ_MEASUREMENT >> 8;             // scd30 firmware version register address = D100
    txBuffer[1] = SCD30_CMD_READ_MEASUREMENT & 0xFF;

    i2cTransaction.slaveAddress = SCD30_ADDRESS;            // Default address of SCD30 is 0x61
    i2cTransaction.writeCount = 2;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.readCount = 18;
    i2cTransaction.readBuf = rxBuffer;
    I2C_transfer(i2cHandle, &i2cTransaction);



    // method I
    tempU32 =   (unsigned int)((((unsigned int)rxBuffer[0]) << 24) |
                (((unsigned int)rxBuffer[1]) << 16) |
                (((unsigned int)rxBuffer[3]) << 8) |
                ((unsigned int)rxBuffer[4]));

    *scd30_co2 = *(double*)&tempU32;
    
    // method II

    *scd30_co2 = ((rxBuffer[0] << 8) + rxBuffer[1] + rxBuffer[3] + rxBuffer[4]);
    *scd30_T = ((rxBuffer[6] << 8) + rxBuffer[7] + rxBuffer[9] + rxBuffer[10]);
    *scd30_RH = ((rxBuffer[12] << 8)+ rxBuffer[13] + rxBuffer[15] + rxBuffer[16]);


}

Hi Team, 

I'm trying to integrate "SCD30" a sensirion sensor with CC2640R2F BLE MCU and read CO2, Temperature, Relative Humidity data from it. I could read some junk data from it, so I could say it's integrated. But I couldn't read meaningful data from the SCD30. I did many trail and errors, and followed closely with other sensor integration code given in TI Resource explorer and over internet. Yet, couldn't read a proper data and have little to no idea on where it's going wrong. 

I am trying to send/write 2 bytes to the sensor and reading 18 bytes of data from it. The data frame here has MMSB, MLSB, LMSB and LLSB with CRC at end of every 2 bytes. I tried doing the byte to float conversion, and still couldn't get it.

I have attached the sample code, result of one of the tries and the SCD30 data format along with this thread. Any leads or help on how to make this work would be highly appreciated. 

Thanks in advance!