TMP117 temperature sensor

The TI TMP117 high-accuracy thermometer on its I2C breakout: 7.8125 m°C a count, averaging, one-shot mode and an ALERT pin.

Aliases: TMP117, TMP 117, Adafruit 4821, SparkFun Qwiic TMP117, precision temperature sensor.

Drag the slider above the board to set the temperature, -55 to 150 °C. Adafruit_TMP117.h reads it, and so does SparkFun_TMP117.h:

#include <Adafruit_TMP117.h>

Adafruit_TMP117 tmp117;

void setup() {
  Serial.begin(115200);
  if (!tmp117.begin()) { Serial.println("Failed to find TMP117 chip"); while (1) delay(10); }
}

void loop() {
  sensors_event_t temp;
  tmp117.getEvent(&temp);   // waits for the next conversion
  Serial.println(temp.temperature);
}

Pins

Pin What it does
VIN Supply, 3 to 5 V on the boards.
GND Ground.
SCL, SDA I2C, with 10k pull-ups on the board.
ALERT Open drain, pulled up on the board: the alert flags, or Data_Ready. Active low unless POL is set.
ADD0 The address strap, pulled down on the board.

ADD0 left alone or to GND is 0x48, to VIN 0x49, to SDA 0x4A, to SCL 0x4B.

Properties

Property Default What it is
temperature 22.5 The temperature, -55 to 150 °C. The slider sets it while it runs.

What the model gets right

The registers. Sixteen bits, high byte first, through a pointer: the result (0x00, two's complement, 7.8125 m°C a count), the configuration (0x01), the high and low limits (0x02, 0x03), the EEPROM unlock (0x04), EEPROM1 to EEPROM3 (0x05, 0x06, 0x08), the offset (0x07, added to every result) and the device ID, 0x0117 (0x0F).

Power-on. The result reads 0x8000, -256 °C, until the first conversion ends.

The conversion cycle. Each conversion averages 1, 8, 32 or 64 samples of 15.5 ms. In continuous mode a result lands at the end of the averaging and the cycle lasts the longer of the CONV setting (15.5 ms to 16 s) and the averaging's minimum, as the datasheet's table lists: one a second at power-on. One-shot converts once and shuts down. Data_Ready is set with each result and cleared by reading the result or the configuration.

The alerts. In alert mode a result above the high limit or below the low one latches its flag until the configuration is read. In therm mode the high flag sets above the high limit and clears below the low one. ALERT follows the flags, or Data_Ready with DR/Alert set.

Reset and the EEPROM. Soft_Reset reloads the power-on settings after 2 ms. With the EEPROM unlocked, writes to the configuration, the limits, the offset and EEPROM1 to EEPROM3 are programmed into it (busy for 7 ms) and come back after a reset.

What it does not model

The accuracy: the result is the slider exactly, rounded to 7.8125 m°C, with no noise to average away, where the real part is within 0.1 °C. The general-call reset, the SMBus alert-response address and the supply current are not modeled either.

Common mistakes

Reading the result straight after power-on and getting -256 °C: wait for Data_Ready, as getEvent() does.

Polling dataReady() and the alert flags from two places: reading the configuration clears both, so one read can hide the other's news.