DigiTemp is a lightweight solution for monitoring 1-Wire temperature sensors on Linux. It is one of many apps that let you read USB Thermometer sensor. By following these steps, you can set up DigiTemp on Debian, Ubuntu, or Raspberry Pi OS and automate data collection for long-term monitoring.
Installation
Ubuntu / Raspberry Pi OS / Debian
sudo apt install digitemp
Execution of this command will install three programs:
digitemp_DS2490
digitemp_DS9097
digitemp_DS9097U
into the /usr/bin/
directory. For usage with the USB Thermometer we will need only digitemp_DS9097
.
DigiTemp configuration
Step 1: Identify Your USB Thermometer
You can identify your USB Thermometer serial port using:
ls /dev/ttyUSB*
This will list available USB-to-serial devices (e.g., /dev/ttyUSB0
) one of them is your connected USB Thermometer.
Step 2: Initialize DigiTemp
Once you’ve identified the correct device, initialize DigiTemp:
digitemp_DS9097 -i -s /dev/ttyUSB0
Remember to replace /dev/ttyUSB0
with your actual device.
After running this command, you should see output similar to:
DigiTemp v3.7.2 Copyright 1996-2018 by Brian C. Lane
GNU General Public License v2.0 - http://www.digitemp.com
Turning off all DS2409 Couplers
.
Searching the 1-Wire LAN
286C530570230702 : DS18B20 Temperature Sensor
ROM #0 : 286C530570230702
Wrote .digitemprc
More about configuration file
When you first initialize DigiTemp it creates a hidden configuration file named .digitemprc
by default inside the current directory. This file stores essential settings for future readings like serial device, sensor ROM IDs, and logging format.
You can also specify a custom location for this file when running DigiTemp:
digitemp_DS9097 -c /path/to/custom_config -a -s /dev/ttyUSB0
The .digitemprc
file contains the following:
TTY /dev/ttyUSB0
READ_TIME 1000
LOG_TYPE 1
LOG_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F"
SENSORS 1
ROM 0 0x28 0x6C 0x53 0x05 0x70 0x23 0x07 0x02
- TTY /dev/ttyUSB0 → The serial/USB device’s port.
- READ_TIME 1000 → Delay in milliseconds between sensor reads.
- LOG_TYPE 1 → Defines the output format (0 = plain text).
- LOG_FORMAT → Specifies how the temperature data is displayed (date, time, sensor ID, temperature in °C and °F).
- SENSORS 1 → The number of detected sensors.
- ROM 0 0x28 0x6C 0x53 0x05 0x70 0x23 0x07 0x02 → The unique ROM address of Sensor 0.
Each 1-Wire sensor has a globally unique ROM ID, which helps DigiTemp identify individual sensors even if they are rearranged.
Now that DigiTemp is initialized and .digitemprc
is created, you can read sensor data without specifying the serial device each time
sudo digitemp_DS9097 -a
This will automatically use the settings stored in .digitemprc
.
Step 3: Read Temperature Data
Once initialized, you can read temperature values with:
cd /path/to/directory/with/config
digitemp_DS9097 -a
if you are using default .digitemprc
or use:
digitemp_DS9097 -c /path/to/custom_config -a
if you would like to use custom config file.
Example output:
Mar 10 14:42:39 Sensor 0 C: 25.75 F: 78.35
Step 5: Automate Data Logging (Optional)
DigiTemp can log data automatically using a log file and predefined format stored in the .digitemprc
file.
To continuously monitor temperature readings, you can either use cron for scheduled logging or run DigiTemp as a background process without cron.
Option 1: Using DigiTemp’s Built-in Logging Feature (Recommended)
DigiTemp provides built-in logging capabilities that allow temperature readings to be stored in a structured format, making it easier to automate and analyze data.
For example, to log readings every 60 seconds indefinitely:
digitemp_DS9097 -a -r 0 -d 60 -l /var/log/digitemp.log
Explanation:
-a
→ Reads all sensors.-n 0
→ Repeats indefinitely (0 means infinite loop).-d 60
→ Waits 60 seconds between readings.-l /var/log/digitemp.log
→ Stores logs in the specified file.
Run it in the background:
nohup digitemp_DS9097 -a -n 0 -d 60 -l /var/log/digitemp.log &
This allows DigiTemp to log temperature readings every minute in the background, even if you log out.
To stop logging:
pkill -f digitemp_DS9097
Option 2: Using Cron for Scheduled Logging
If you prefer cron, DigiTemp can still be scheduled to run periodically.
Open the Crontab editor:
crontab -e
To log every minute (* * * * *), add the logging command:
* * * * * /usr/bin/digitemp_DS9097 -a -l /var/log/digitemp.log
This runs DigiTemp every minute and appends the data to /var/log/digitemp.log
.
After a few minutes, check the log file:
tail -f /var/log/digitemp.log
0 Comments