Skip to content

ROS2 Jazzy driver for Texas Instruments TMP102 digital temperature sensor (I2C)

License

Notifications You must be signed in to change notification settings

mingyo186/tmp102_temp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TMP102 Temperature Sensor — ROS2 Jazzy Driver (I2C)

ROS2 Jazzy driver for the Texas Instruments TMP102 low-power digital temperature sensor over I2C.

Features

  • Publishes sensor_msgs/Temperature on tmp102/temperature
  • fake_mode for testing without hardware (random Gaussian data)
  • I2C address configurable (0x48-0x4B via ADD0 pin)
  • 12-bit normal mode and 13-bit extended mode
  • Ultra-low power: 10 µA active, 1 µA shutdown
  • Runtime publish_rate change via ros2 param set
  • Calibration and reset services

Why this package?

There is also a ds18b20_temp driver for DS18B20. The TMP102 offers different trade-offs:

Feature DS18B20 (ds18b20_temp) TMP102 (this package)
Interface 1-Wire (kernel sysfs) I2C (smbus2)
Temperature range -55 ~ 125 °C -40 ~ 125 °C (150 °C extended)
Temperature accuracy ±0.5 °C ±0.5 °C typical
Resolution 9-12 bit configurable 12-bit (0.0625 °C)
Conversion time 93.75-750 ms 26 ms
Max sampling rate ~1.3 Hz (12-bit) 8 Hz
Power consumption 1 mA active 10 µA active
Multi-sensor Many on 1 GPIO pin Up to 4 per I2C bus
Waterproof probe Yes No
Driver dependency None (kernel sysfs) smbus2

Choose ds18b20_temp for waterproof probes and unlimited sensors on one wire. Choose this package for ultra-low power, fast conversion, and standard I2C bus.

Prerequisites

  • ROS 2 Jazzy
  • Python 3
  • Real hardware only:
    • smbus2 (pip install smbus2)

Installation

cd ~/ros2_ws
colcon build --packages-select tmp102_temp --symlink-install
source install/setup.bash

Usage

Launch (fake mode — default)

ros2 launch tmp102_temp tmp102_launch.py

Run node directly

ros2 run tmp102_temp tmp102_node.py

Real hardware (Raspberry Pi)

ros2 launch tmp102_temp tmp102_launch.py \
  params_file:=path/to/your_params.yaml

Set fake_mode: false and device_address in your YAML file.

Verify output

ros2 topic echo /tmp102/temperature

Parameters

Parameter Type Default Description
fake_mode bool true Generate random data without hardware
i2c_bus int 1 I2C bus number (/dev/i2c-N)
device_address int 0x48 I2C address (0x48-0x4B)
publish_rate float 4.0 Publishing rate in Hz (up to 8 Hz)
frame_id string tmp102_link TF frame ID
extended_mode bool false 13-bit extended mode (-40~150 °C)
temperature_variance float 0.0 Temperature variance (0 = unknown)

Services

Service Type Description
tmp102/calibrate std_srvs/srv/Trigger Collect samples for 2 s, report averages
tmp102/reset std_srvs/srv/Trigger Clear bias, reinitialize sensor

Package Structure

tmp102_temp/
├── CMakeLists.txt
├── package.xml
├── config/
│   └── tmp102_params.yaml
├── launch/
│   └── tmp102_launch.py
├── tmp102_temp/
│   ├── __init__.py
│   └── tmp102_driver.py
├── nodes/
│   └── tmp102_node.py
├── test/
│   └── test_tmp102_node.py
├── .gitignore
├── LICENSE
├── CONTRIBUTING.md
└── README.md

Test Results

Tested on Ubuntu 24.04 (WSL2) with fake_mode: true.

Test Category Test Result
Topics tmp102/temperature publishes sensor_msgs/Temperature PASS
Services tmp102/calibrate returns success=True PASS
Services tmp102/reset returns success=True PASS
Parameters publish_rate runtime change PASS
Shutdown Clean exit PASS
Linting pep257, flake8, copyright, xmllint PASS

License

MIT

About

ROS2 Jazzy driver for Texas Instruments TMP102 digital temperature sensor (I2C)

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published