Serial Port Temperature Sensors - Using Multiple Sensors
This page describes how to configure and use multiple temperature sensors
using a single serial port interface circuit.
If you are using a USB-serial adapter instead of a serial port interface circuit,
refer to the USB hardware interface page for information on
connecting multiple temperature sensors to a single USB-serial adapter.
Multiple Sensors
Each DS18S20 temperature sensor has a unique 64-bit address, so multiple sensors
can be connected in parallel to the same interface circuit.

connecting multiple sensors in parallel (in parasitic mode)
Multiple sensors can be connected in parallel in this way, using either a parasitic circuit (as shown above)
or a non-parasitic circuit.
Different network topologies can be created with multiple sensors - linear, stubbed and star topology, and
each has advantages and disadvantages. Refer to Maxxim's
Guidelines for Reliable Long Line 1-Wire Networks for more information.
Update digitemp Configuration
If multiple sensors are connected, it's necessary to update the digitemp configuration file:
digitemp -i -q -c /etc/digitemp.conf
and digitemp should detect all the connected sensors and update the configuration file.
Reading Multiple Temperatures
To read the temperature of all the connected sensors, the "-a": parameter
is specified:
digitemp -a -q -c /etc/digitemp.conf
with the following output:
Apr 17 23:16:16 Sensor 0 C: 26.56 F: 79.81
Apr 17 23:16:18 Sensor 1 C: 23.44 F: 74.19
Apr 17 23:16:20 Sensor 2 C: 23.38 F: 74.08
Read Single Temperature
To read the temperature of just one sensor, the sensor number can be specified:
digitemp -t 1 -q -c /etc/digitemp.conf
with the resulting output:
Apr 17 23:18:12 Sensor 1 C: 23.44 F: 74.19
Sensor Order
Note that digitemp sorts the temperature sensors in ascending order of their
64-bit addresses.
This can mean that adding an additional sensor may cause other existing sensors
to be re-numbered by digitemp.
If this is the case, and you want to preserve any existing history in your
RRDTool database files, you may need to rename your RRDTool database files,
as well as modifying the description in the perl script that handles
data collection and graphing.
Graphing Multiple Sensors
The page on graphing temperatures provides a sample script for storing
and graphing the temperature of a single temperature sensor.
If using multiple sensors, you could run multiple instances of this script - one for each sensor.
However, that will result in separate graphs for each sensor.
The script can easily be modified to graph multiple temperatures on a single graph,
and you can download a copy of my rrd_tempsensors.pl
script, which demonstrates how to query three sensors and graph the results on a single graph.
The script can easily be modified for a different number of sensors.
last updated 18 Dec 2015
|