Download PDF Parts List View on YouTube Download Code

Today, we are going to work with an extremely accurate temperature sensor, the TMP117 by Texas Instruments. This medical-grade digital sensor is capable of resolving temperatures to within ±0.1 °C. Adafruit has packaged this sensor in a low-cost breakout module that is easy to use with any microcontroller.

Introduction

Temperature measurement is one of the most common tasks in electronics projects. Whether you’re monitoring the environment, building a weather station, or controlling a heating system, you’ll need a reliable temperature sensor.

Today we’ll be looking at the TMP117, a high-accuracy digital temperature sensor from Texas Instruments. Adafruit produces a convenient module for this device, making it easy to connect to your favorite microcontroller.

Image

 

We’ll start by learning about the TMP117 and the Adafruit module, then hook it up to an ESP32-S3 board and write some Arduino code. After that, we’ll compare it against several other popular temperature sensors. Finally, we’ll build a WiFi thermometer project using the TMP117, an ESP32-C6, and a small OLED display – and we’ll construct it without using any wires!

TMP117

The TMP117 is a digital I²C temperature sensor designed by Texas Instruments. It offers exceptional accuracy and stability, making it ideal for applications where precise temperature readings are critical. In fact, it meets the ASTM E1112 and ISO 80601-2-56 standards for electronic patient thermometers.

Key specifications:

  • Accuracy: ±0.1 °C (from –20 °C to +50 °C)
  • Measurement range: –55 °C to +150 °C
  • Resolution: 0.0078 °C (16-bit output)
  • Low power consumption
  • I²C interface (up to 400 kHz)
  • 4 selectable I²C addresses
  • Programmable alert limits
  • Operating voltage: 1.8 V to 5.5 V

The TMP117 also has programmable Temperature Alerts. You can set high and low temperature thresholds and generate an interrupt on the module’s INT pin.

We’ll be using a module from Adafruit in our experiments. The module includes voltage regulation and level-shifting circuitry, so you can safely use it with both 3.3V and 5V microcontrollers. It also features STEMMA QT / Qwiic connectors, allowing for solderless, plug-and-play connections with compatible boards.

Sparkfun also makes a similar module, and you can use that one in these experiments as well.

Using the TMP117

The TMP117 module is very easy to use. As an I²C device, hookup is simple, either via the module pins or using the Qwiic connector. Both Adafruit and Sparkfun have provided libraries that can be used with their modules.

TMP117 Pinout

Here is the pinout of the Adafruit TMP117 module:

Image

The sensor is positioned on a thermal isolation island to reduce heat transfer from other board components. It has a default I²C address of 0x48, which can be changed using the ADDR pin.

TMP117 Hookup

We’ll be testing the sensor with a microcontroller; I’m using a Seeeduino XIAO ESP32-S3 board, but any microcontroller (3.3 or 5 volts) will work pretty well.

Thanks to the I²C interface, wiring is simple. You only need four wires: power, ground, clock (SCL), and data (SDA).

Here is the hookup for the Seeeduino XIAO:

Image

Of course, if your microcontroller has a Qwiic connector, you may use that instead. If you do, be aware that on many microcontrollers, the Qwiic connector is on a secondary I²C bus. Check your documentation if you are unsure of this, or just use the wires.

TMP117 Code

To read from the sensor, we’ll use the Adafruit TMP117 library. You can install it from the Arduino IDE Library Manager by searching for “Adafruit TMP117“. You’ll also need the “Adafruit BusIO” and “Adafruit Unified Sensor” libraries; the IDE should offer to install them for you when you select the TMP117 library.

Once we have installed the library, we can test out the sensor using the “basic_test” sketch packaged with the Adafruit library.

You’ll find this sketch under the Adafruit_TMP117 folder in the example sketches section of your Arduino IDE.

The sketch is pretty straightforward. It begins by including the required libraries, the Wire Library for I²C and two Adafruit libraries, the TMP117 and the Universal Sensor library.

In Setup(), we start the serial monitor and the TMP117.

In the Loop(), we create an event named “temp” and populate it with the current temperature measurement. This is then printed to the serial monitor. A one-second delay is applied, and then we restart the Loop().

Image

Load the sketch to your microcontroller and observe through the serial monitor. You should see the temperature in Celsius, with two decimal places of accuracy.

Comparing TMP117 to Other Sensors

The TMP117 is undoubtedly easy to use, and the Adafruit (and SparkFun) module is well supported. But it is also more expensive than other temperature sensors, some of which also sense humidity or other environmental parameters.

To determine if it is worth the extra expense, I have compared its performance to that of several other popular sensors. They are as follows:

Image

DHT11

  • A very basic, low-cost digital temperature and humidity sensor.
    • Temp Range: 0-50°C
    • Temp Accuracy:
    • Datasheet

DHT22

  • The more capable sibling of the DHT11, with better range and accuracy.
    • Temp Range: -40 to 80°C
    • Temp Accuracy:
    • Datasheet

MCP9808

  • A high-accuracy I2C temperature sensor, a direct competitor to the TMP117.
    • Temp Range: -40°C to +125°C
    • Temp Accuracy: (Typical)
    • Datasheet

AHT20

  • A popular and affordable I2C temperature and humidity sensor.
    • Temp Range: -40 to 85°C
    • Temp Accuracy: (Typical)
    • Datasheet

AM2320

  • An I2C-based digital temperature and humidity sensor.
    • Temp Range: -40 to +80°C
    • Temp Accuracy:
    • Datasheet

LM35

  • A classic precision analog temperature sensor. Output voltage is linearly proportional to the Celsius temperature (10mV per degree C).
    • Temp Range: -55 to 150°C
    • Temp Accuracy: (Typical at 25°C)
    • Datasheet

TMP36

  • Another popular analog temperature sensor, with a 10 mV/°C scale factor and a 500 mV offset.
    • Temp Range: -40°C to +125°C
    • Temp Accuracy: (Typical)
    • Datasheet

 

In the case of sensors that also sense humidity, we are only going to read temperature.

Sensor Type Accuracy Range (°C) Notes
TMP117 Digital (I²C) ±0.1 °C –55 to 150 Very high accuracy
DHT11 Digital (1-wire) ±2 °C 0 to 50 Low cost, limited range
DHT22 (AM2302) Digital (1-wire) ±0.5 °C –40 to 80 Better accuracy, humidity sensor
MCP9808 Digital (I²C) ±0.25 °C –40 to 125 Stable and accurate
AHT20 Digital (I²C) ±0.3 °C –40 to 85 Humidity + temperature
AM2320 Digital (I²C or 1-wire) ±0.5 °C –40 to 80 Humidity + temperature
LM35 Analog ±0.5 °C –55 to 150 Output 10 mV/°C
TMP36 Analog ±1 °C –40 to 125 Output 10 mV/°C, offset

The table above compares the temperature sensors.

Running the Test

The two analog sensors I’m using in the comparison require 5 volts. All of the other sensors are digital, either one-wire or I²C, and can operate on either 3.3 or 5 volts.

Because of the 5-volt requirement for the analog sensors, I decided to use an Arduino Uno R4 WiFi board.  I made this choice because:

  • The Uno R4 is a 5-volt logic device.
  • It features a 12-bit Analog-to-Digital Converter for increased accuracy compared to earlier models.
  • It has a 3.3-volt Qwiic connector on a secondary I²C channel.

I used the TMP117 and AHT20 with the Qwiic connectors; the other I²C sensors (MCP9808 and AM2320) used pins A4 and A5 for their I²C connection. The two “DHT” sensors utilized digital I/O pins (2 and 3), while the analog sensors employed analog inputs A0 and A1.

Image

It made for quite a packed breadboard!

The results were somewhat surprising.

All of the digital sensors performed well, tracking the TMP117 very closely. The AHT20 (which also measures humidity) was exceptionally impressive.

The two analog sensors were off by several degrees, which could be a result of the 5-volt power supply. Using the Arduino AREF pin with an externally calibrated voltage may have resolved this, although if you are going to such extremes, it might make sense to use one of the digital sensors instead.

Bottom line: the TMP117 was the most accurate, but several of the less-expensive digital I²C sensors performed almost as well.

Image

WiFi Thermometer

Let’s take our TMP117 and build a practical, standalone device – an ESP32-based WiFi thermometer that shows the reading on an OLED display and also broadcasts it on its own web server.

The design is pretty generic, and you could use almost any ESP32 module and OLED display along with the TMP117. However, I have selected a few components that pair exceptionally well with the TMP117, allowing us to create a compact, Wi-Fi 6-capable design that operates on a rechargeable battery.

For the ESP32, I have chosen the SparkFun ESP32-C6 Qwiic Board, a compact development platform built around Espressif’s ESP32-C6 microcontroller. It also includes a USB-C port for programming and power, a 2-pin JST connector with onboard LiPo battery charging circuitry (MCP73831), and Reset and Boot buttons.

Image

The display I have selected is also from SparkFun, the SparkFun Qwiic OLED Display. This is a compact 0.91-inch, 128×32 pixel monochrome screen based on the familiar SSD1306 driver IC. It’s one of many Qwiic OLEDs from Sparkfun. This version features two vertical Qwiic connectors on the back, allowing for easy daisy-chaining with other Qwiic devices while keeping wiring neat inside enclosures. It communicates over I²C at address 0x3C and includes onboard 4.7 kΩ pull-up resistors (which can be disabled via jumpers if needed).

WiFi Thermometer Hookup

If you build the thermometer using the same components I used, then all you need for “hookup” is two short Qwiic cables. Both the TMP117 and the SparkFun Qwiic OLED Display have two Qwiic connectors to allow “daisy-chaining”, so the only hookup instructions are to connect everything to either in the most suitable fashion using the two Qwiic cables!

Image

Otherwise, you can use any ESP32 board, along with an OLED display. The earlier demonstration with the Seeduino XIAO will show you the hookup for the TMP117. Just hook up the I2C OLED in the same fashion, paying attention not to reverse SDA and SCL.

WiFi Thermometer Code

This sketch reads the TMP117, displays it on the OLED, and also provides a web-based interface so you can view the temperature on your phone, tablet, or computer.

The sketch may be a bit long, but it is not that hard to understand.

We start by including several libraries to handle the TMP117 and the OLED display. You may need to install some of these libraries using your Library Manager in the Arduino IDE.

We then configure the OLED display and create the Wi-Fi Access Point credentials.  You can change these if it suits you better.

After that, we create objects for the sensor, display, and web server. We also make two variables for temperature, one in Celsius and one in Fahrenheit.

In Setup(), we initialize everything and create our Wi-Fi access point. We also define some web server routes.

In the Loop(), we handle the web server requests with the command server.handleClient(). The client requests will be handled by two functions, defined in Setup().

The rest of the Loop() involves reading the sensor, converting the reading to Fahrenheit, and printing to both the serial monitor and OLED display.

The handleRoot() function has all the HTML and CSS. You can personalize the display by editing it if you wish.

And the handleTemperature() function takes care of updating the display on the web page.

Using the WiFi Thermometer

Load the code to the ESP32-C6 and restart the microcontroller. You should see some Wi-Fi connection information displayed on the OLED, followed by the temperature in both scales.

To use the Wi-Fi feature, you will need to connect your device (phone, tablet, or computer) to the Access Point created by the ESP32-C6.  The details are shown here:

Image

Once you connect to the web page, you should see the following display:

Image

You’ll note that the temperature on the OLED and the web page match each other, with a slight bit of latency on the web page.

You can use ytis as is, or modify it to become an IoT device. The ESP32-C6 is Wi-Fi-6 compatible, so it is ideal for IoT.

Conclusion

The TMP117 is one of the most precise and reliable temperature sensors available for hobby projects. With ±0.1 °C accuracy, it outperforms most common alternatives like the DHT11 or LM35. Thanks to boards like Adafruit’s Qwiic breakout, it’s also extremely easy to use with both 3.3 V and 5 V microcontrollers.

We’ve seen how to use it with an ESP32-S3, compared it against other sensors, and built a full WiFi thermometer with an ESP32-C6 and an OLED display. Whether you’re experimenting, teaching, or creating a practical project that requires precision temperature measurements, the TMP117 is an excellent sensor to add to your toolkit.

 

Parts List

Here are some components you might need to complete the experiments in this article. Please note that some of these links may be affiliate links, and the DroneBot Workshop may receive a commission on your purchases. This does not increase the cost to you and is a method of supporting this ad-free website.


TMP117  Adafruit

ESP32-C6 Sparkfun

 

 

Resources

 

Code Samples – All the code used in this article in one easy-to-use ZIP file!

Article PDF – A PDF version of this article in a ZIP file.

 

 

TMP117 Precision Temperature Sensor
Summary
TMP117 Precision Temperature Sensor
Article Name
TMP117 Precision Temperature Sensor
Description
Learn to use the TMP111 precision temperature sensor. We'll use this Texas Instruments sensor on an Adafruit module to build a precision thermometer with an OLED display and Wi-Fi.
Author
Publisher Name
DroneBot Workshop
Publisher Logo

1 Comment
Oldest
Newest
Inline Feedbacks
View all comments
Peter Liwyj
2 months ago

I’m having trouble with the libraries for the WiFi thermometer sketch. Which ones did you use for WiFi.h and WebServer.h ?