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.

TMP118EVM: USB Command Driver

Part Number: TMP118EVM
Other Parts Discussed in Thread: TMP118

Tool/software:

Hi expert,

May I know if we have the USB command/driver of USB to I2C for TMP118EVM can share with customer for system integration development? 

Thanks,

Allan 

  • Hello Allan,

    Are you asking for separate code the customer can use for the TMP118 device? Or the source code for the TMP118EVM software?

    I have attached some C-based sample code for Arduino below. If the customer needs help with developing a C-based driver, I highly encourage checking out our SysConfig page.

    //TMP118 Example Code to allow users to read from the TMP118 temperature sensor using a C-based program.
    //Author: Harry Gill
    //v0.2
    
     #include <Wire.h>
    
    //|| Device Definitions ||\\
    
    // Register Configurations
    #define DEVICE_CONFIG_REG_ADDR 0x0 //
    #define DEVICE_ADDR 0x48 //
    #define DEVICE_TEMP_REG_ADDR 0x0 //
    
    // Device Mode Options \\
    
    // One-Shot
    #define CONFIG_OS 0x1 //
    // Continuous
    #define CONFIG_CONTINUOUS 0x0 //
    
    
    void setup() {
      
      // put your setup code here, to run once:
      Wire.begin();
      Serial.println("TMP118 Arduino Example");
      Serial.begin(9600);
    
      //initialize device
      device_init();
      
      //wait 8ms
      delay(8);
    
    }
    
    void loop() {
    
      // put your main code here, to run repeatedly:
    
      // Pass device address and temp reg addr
      int16_t tempData = getData(DEVICE_ADDR, DEVICE_TEMP_REG_ADDR);
    
      float celcius = tempData * 0.0078125;
    
      Serial.print("Temp (C): ");
      Serial.println(celcius);
    
      //wait one second until next temp read
      delay(1000); 
    
    }
    
        // initialize device and load configuration into sensor
        void device_init(){
    
          //initiate contact with sensor
          Wire.beginTransmission(DEVICE_ADDR);
    
          //write to config register
          Wire.write(DEVICE_CONFIG_REG_ADDR);
          
          //write OS mode to config register
          Wire.write(CONFIG_OS);
          
          Wire.endTransmission();
    
        }
    
        int16_t getData(int8_t sensorAddr, int8_t tempReg) {
          
          Wire.beginTransmission(sensorAddr);
          Wire.write(tempReg);
          Wire.endTransmission();
          Wire.requestFrom(sensorAddr, 2);
    
          int16_t bytes = Wire.read() << 8;
          bytes |= Wire.read();
    
          return bytes;
          
        }
     
    

    Regards,

    Harry