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: v4.10: i2ctmp driver example program reading TMP006 NRND?

Part Number: SIMPLELINK-CC2640R2-SDK
Other Parts Discussed in Thread: TMP116, TMP007, TMP006, BOOSTXL-BASSENSORS, TMP117

Hi,

The i2ctmp driver example program, reads TMP116 and TMP006. I suggest the TMP006 be replaced by TMP007. The TMP007 is present at BOOSTXL-SENSORS. Also this multiplier is specific for TMP116.

temperature *= 0.0078125;

-kel

  • Hi Markel,

    Thanks for the suggestion and the scale factor heads up! i will bring this feedback up with the responsible team.

  • Hi Markel, 

    Looked a bit closer at this and I think there will likely be no change in this regard. The TMP006 and TMP007 is both NRND and the example is not really meant to cater this boosterpack (and as they ahve NRND both 006 and 007, I doubt any effort will be added to port the example to another boosterpack).

    The reason the TMP006 is in there is the first place is because it is mounted on some of the CC32XX lauchpads. Basically, it is there because of legacy reasons, not to show of the temp sensor as such. 

    As for the constant, it seems to actually be correct if you assume that 1 LSB of the TMP006 sensor is 1/32 C* and that you should right shift the value by 2 :)

  • No problem.

    I am just suggesting the TMP007 because I assume most people would have the BOOSTXL-SENSORS. If the user don't have the BOOSTXL-BASSENSORS which has the tmp116, then this i2ctmp example program is useless for them.

    I have no time to verify the multiplier for tmp006, but for tmp007 should be like this.

    temperaturef = ((float)(temperature >> 2)) * 0.03125;

    Anyway, I modified the i2ctmp to work for my BOOSTXL-SENSORS just for your reference here is the code.

    #include <stdint.h>
    #include <stddef.h>
    #include <unistd.h>
    
    /* Driver Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/I2C.h>
    #include <ti/display/Display.h>
    
    /* Example/Board Header files */
    #include "Board.h"
    
    #define TASKSTACKSIZE       640
    
    /*
     *  ======== TMP Registers ========
     */
    #define TMP007_OBJ_TEMP     0x0003  /* OBJ Temp Result Register for TMP007 */
    #define TMP007_ADDR         0x40;
    
    
    static Display_Handle display;
    
    /*
     *  ======== mainThread ========
     */
    void *mainThread(void *arg0)
    {
        uint16_t        sample;
        uint16_t        temperature;
        float           temperaturef;
        uint8_t         txBuffer[1];
        uint8_t         rxBuffer[2];
        I2C_Handle      i2c;
        I2C_Params      i2cParams;
        I2C_Transaction i2cTransaction;
    
        /* Call driver init functions */
        Display_init();
        GPIO_init();
        I2C_init();
    
        /* Configure the LED and if applicable, the TMP116_EN pin */
        GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    #ifdef Board_GPIO_TMP116_EN
        GPIO_setConfig(Board_GPIO_TMP116_EN, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_HIGH);
        /* 1.5 ms reset time for the TMP116 */
        sleep(1);
    #endif
    
        /* Open the HOST display for output */
        display = Display_open(Display_Type_UART, NULL);
        if (display == NULL) {
            while (1);
        }
    
        /* Turn on user LED */
        GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
        Display_printf(display, 0, 0, "Starting the i2ctmp example.");
    
        /* Create I2C for usage */
        I2C_Params_init(&i2cParams);
        i2cParams.bitRate = I2C_400kHz;
        i2c = I2C_open(Board_I2C_TMP, &i2cParams);
        if (i2c == NULL) {
            Display_printf(display, 0, 0, "Error Initializing I2C\n");
            while (1);
        }
        else {
            Display_printf(display, 0, 0, "I2C Initialized!\n");
        }
    
        /* Common I2C transaction setup */
        i2cTransaction.writeBuf   = txBuffer;
        i2cTransaction.writeCount = 1;
        i2cTransaction.readBuf    = rxBuffer;
        i2cTransaction.readCount  = 2;
    
        /* try TMP007*/
        txBuffer[0] = TMP007_OBJ_TEMP;
        i2cTransaction.slaveAddress = TMP007_ADDR;
        if (!I2C_transfer(i2c, &i2cTransaction)) {
            /* Could not resolve a sensor, error */
            Display_printf(display, 0, 0, "Error. No TMP sensor found!");
            while(1);
        }
    
        Display_printf(display, 0, 0, "Detected TMP007 sensor.");
    
    
        /* Take 20 samples and print them out onto the console */
        for (sample = 0; sample < 20; sample++) {
            if (I2C_transfer(i2c, &i2cTransaction)) {
                /*
                 * Extract degrees C from the received data;
                 * see TMP007 datasheet
                 */
                temperature = (rxBuffer[0] << 8) | (rxBuffer[1]);
                temperaturef = ((float)(temperature >> 2)) * 0.03125;
    
                Display_printf(display, 0, 0, "Sample %u: %f (C)",
                    sample, temperaturef);
    
            }
            else {
                Display_printf(display, 0, 0, "I2C Bus fault.");
            }
    
            /* Sleep for 1 second */
            sleep(1);
        }
    
        I2C_close(i2c);
        Display_printf(display, 0, 0, "I2C closed!");
    
        return (NULL);
    }

  • The recommended booster-pack is actually http://www.ti.com/tool/BP-BASSENSORSMKII right now (which has the TMP117 sensor featured). No matter what, you are quite right on the example being rather useless unless you have the actual sensors. I would consider it more of a CC32XX example and that it is there for other devices to showcase how the I2C driver works.

    As for the conversion, (temp >> 2) * 0.03125 could also be written as temp / 4 * 0.03125 or temp * 0.0078125 :)