Driver for the TI TMP102 I2C temperature sensor. For use with TI TM4C123X MCUs.

Related tags


TI TMP102 Driver

Simple driver for the TI TMP102 I2C temperature sensor. For use with TI TM4C123X MCUs and TI's TivaWare™ Peripheral Driver Library.


This is a very basic driver for the TI TMP102 I2C temperature sensor for use with TI TM4C123X microcontrollers. I wrote this driver solely for the learning experience, and it is the first MCU driver I made. Because of this, you should use caution when implementing it into your project. The current version contains no error handling or detection, and was only tested using the limited tools that I had available at the time.

This driver relies heavily on TI's TivaWare™ Peripheral Driver Library. Because of this, it should be portable to all TM3C123X MCUs, but was only tested using a TM4C123GH6PM.

This driver implements nearly every feature of the TMP102 sensor including temperature readings, alerts, alert polarity adjustment, conversion rate adjustment, shutdown mode, comparator mode, interrupt mode, fault queue adjustment, one-shot mode, and high/low limits.

The only feature I didn't implement was the ability to turn off enhanced mode. Enhanced mode allows for 13-bit temperature readings, and I hardcoded it into this driver. I saw no reason to allow the use of 12-bit readings.

Getting Started

For function details, please see the function descriptions in tmp102.h


  • You must be using TI's TivaWare™ Peripheral Driver Library in order for this driver to work. It can be downloaded here:
  • You must be using an MCU compatible with TI's TivaWare™ Peripheral Driver Library. In my case, I used a TM4C123GH6PM.


  • Download tmp.c and tmp.h to your project directory, or another directory and add it to your project's include path.
  • Make sure to add #include "tmp102.h" to your project.


In order to use this driver, you must have an I2C port on your MCU configured. Once that is complete, you simply have to initialize your tmp102 sensor by using the tmp102Begin() function.

tmp102Begin() takes two arguments, the sensor address (default 0x48) and the I2C port number that you are using. This driver is able to use ports 0-3.

For example, if I wanted to initialize device 0x48 on I2C port 0, I would use the following:

tmp102Begin(0x48, 0);

This statement does three things:

  • Saves the device address locally
  • Saves the device's port number locally
  • Retrieves the current configuration from the sensor and ensures that EM mode (13-bit temperatures) is active

Everytime tmp102Begin() is called, the local address and port variables are overwritten with the new values. This means that you can use multiple TMP102 sensors on different addresses by calling the tmp102Begin() function to switch between sensors. Configuration settings are stored in the sensors themselves as long as they maintain power.

After tmp102Begin() is called, you are able to use any of the other functions. If you you want the most basic of functionality, you can immediately start calling tmp102GetTemp() after tmp102Begin():

float temp;
tmp102Begin(0x48, 0);

   temp = tmp102GetTemp();
   //do something with temp


Dan Maher

Version History

  • 0.1
    • Initial Release


This project is licensed under the MIT License - see LICENSE.MD for details


Inspiration and Reference Material

Dan Maher
Dan Maher
Trial port of the rtf_433 Library for use with OpenMQTTGateway on a ESP32 and a CC1101 Transceiver

This is an attempt at creating an Arduino library for use on ESP32 boards with a CC1101 transceiver with the device decoders from the rtl_433 package.

Northern Man 24 Jul 24, 2021
A programming environment for Lua for the Raspberry Pi Pico microcontroller

picolua A programming environment for Lua for the Raspberry Pi Pico microcontroller. Version 0.3, April 2021 What is this? picolua is a proof-of-conce

Kevin Boone 23 Jul 26, 2021
MPU-9250 sensor driver.

mpu9250 This library communicates with InvenSense MPU-9250 and MPU-9255 Inertial Measurement Units (IMUs). License Changelog Contributing guide Descri

Bolder Flight Systems 27 Jul 8, 2021
ds18b20 full function driver

LibDriver DS18B20 English | 简体中文 The DS18B20 digital thermometer provides 9-bit to 12-bit Celsius temperature measurements and has an alarm function w

Shifeng Li 82 Jul 19, 2021
I2C hardware test terminal/master mode emulator.

I2C Master Mode Emulator The I2C master mode emulator allows communication with I2C devices by sending or receiving data to/from the I2C bus. To issue

Dilshan R Jayakody 16 Apr 12, 2021
Custom firmware for Quicko and KSGER T12 soldering stations

STM32 Soldering Station Firmware Project details Compatibility Operations guide Frequently asked questions Building Creating a .ioc file from scratch

null 18 Jul 28, 2021
GFX Demo for the ESP-IDF

Display Drivers and Demo for GFX This is a Demo of GFX With Several Display Drivers This is not GFX itself, but it includes it. GFX Documentation is b

honey the codewitch 24 Jul 16, 2021
A guide and set of tools for working with TinyML powered Audio Sensors

Audio Sensor Toolkit This is a guide on how to build an Audio Sensor using Machine Learning, and helpful tools. Audio Sensor Guide Audio Tools Acceler

IQT Labs 18 May 27, 2021
bmp180 full function driver

LibDriver BMP180 English | 简体中文 The BMP180 is the function compatible successor of the BMP085, a new generation of high precision digital pressure sen

Shifeng Li 50 Jul 19, 2021
Arduino sample code to help you get started using the Soracom IoT Starter Kit!

Soracom IoT Starter Kit The Soracom IoT Starter Kit includes everything you need to build your first connected device. It includes an Arduino MKR GSM

Soracom Labs 10 Mar 11, 2021
Espressif ESP32 implementation of ANSI-ESTA E1.11 DMX-512A

This library allows for transmitting and receiving ANSI-ESTA E1.11 DMX-512A using an Espressif ESP32. It provides control and analysis of the packet configuration and allows the user to read synchronously or asynchronously from the DMX bus. This library also includes tools for data error-checking to safely process DMX commands.

null 15 Jul 17, 2021
🪴💧 A Bluetooth Low Energy (BLE) soil moisture sensor.

b-parasite b-parasite is an open source Bluetooth Low Energy (BLE) soil moisture and ambient temperature/humidity sensor. Features Soil moisture senso

null 249 Jul 23, 2021
Firmware, mechanical and electrical design files for the Inline Filament Diameter Estimator, Lowcost (InFiDEL).

Inline Filament Diameter Estimator, Lowcost (InFiDEL) Originally created by Thomas Sanladerer A cheap, yet precise filament diameter sensor, intended

Daniel Smullen 46 Jul 10, 2021
Common Sensor API for the BMA2 family of sensors

BMA2 Sensor API Sensor overview The BMA2 is a triaxial, low-g acceleration sensor with digital output. An ASIC in the sensor converts the output of a

Bosch Sensortec 6 Jul 12, 2021