Example #1
0
/**********************************************************
 * getExtTemp - Gets the current external temperature from the sensor.
 *
 * @return float - The external temperature in degrees C
 **********************************************************/
float TMP421::getExtTemp(void)
{
  uint8_t highByte = 0x00, lowByte = 0x00;

//  I2c.beginTransmission(_address);
//  I2c.write(0x01);
//  I2c.endTransmission();
//  I2c.requestFrom((int)_address, 2); // request 2 byte from address 1001000
//  while(I2c.available())
//  {
//    highByte = I2c.read(); // Read the first octet
//    lowByte = I2c.read(); // Read the second octet
//  }

  I2c.write(_address, (byte) 0x01);
  I2c.read(_address, (uint8_t) 2);
  if(I2c.available()) {
    highByte = I2c.receive();
    lowByte = I2c.receive();
  }

  return getFraction(highByte, lowByte);
}