ROS2 Jazzy driver for the Texas Instruments TMP102 low-power digital temperature sensor over I2C.
- Publishes
sensor_msgs/Temperatureontmp102/temperature fake_modefor 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_ratechange viaros2 param set - Calibration and reset services
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.
- ROS 2 Jazzy
- Python 3
- Real hardware only:
smbus2(pip install smbus2)
cd ~/ros2_ws
colcon build --packages-select tmp102_temp --symlink-install
source install/setup.bashros2 launch tmp102_temp tmp102_launch.pyros2 run tmp102_temp tmp102_node.pyros2 launch tmp102_temp tmp102_launch.py \
params_file:=path/to/your_params.yamlSet fake_mode: false and device_address in your YAML file.
ros2 topic echo /tmp102/temperature| 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) |
| 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 |
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
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 |
MIT