# Implementation of multiple DS18B20

**URL:** <https://community.influxdata.com/t/implementation-of-multiple-ds18b20/8012>\
**Category:** Store\
**Tags:** influxdb, telegraf, chronograf\
**Created:** [January 3, 2019, 1:32pm UTC](https://community.influxdata.com/t/implementation-of-multiple-ds18b20/8012 "2019-01-03T13:32:43Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![KliG](https://avatars.discourse-cdn.com/v4/letter/k/22d042/32.png) [@KliG](https://community.influxdata.com/u/KliG)\
**Post date:** [January 3, 2019, 1:32pm UTC](https://community.influxdata.com/t/implementation-of-multiple-ds18b20/8012/1 "2019-01-03T13:32:43Z")

</div>

Hello,

I would like to know about an issue which is appearing with multiple (10 sensors with 1-Wire) Temp (DS18B20) measurements with inputs.temp (Telegraf) and Chronograf on a RaspberryPI.  
Apparently the temperature is correct gathered (10 measurements) by Telegraf but just one temperature is shown in InfluxDB. Has there to be an indexing eg temp(1), temp(i)?

How many sensors can handle Telegraf and influxdb?

Raspian Stretch  
Raspi 3B+  
Telegraf 1.9.1  
InfluxDB 1.7.2  
Chronograf 1.7.5

Nice greetings and thanks in advance

---

<div class="post-metadata">

**Author:** ![PaulRowntree](https://avatars.discourse-cdn.com/v4/letter/p/bb73d2/32.png) [@PaulRowntree](https://community.influxdata.com/u/PaulRowntree)\
**Post date:** [January 5, 2019, 4:08am UTC](https://community.influxdata.com/t/implementation-of-multiple-ds18b20/8012/2 "2019-01-05T04:08:43Z")

</div>

How are the 10 results distinguished at the source, and at the output of telegraf? Do you only see one entry in InfluxDB when you query directly, without Chronograf?

---

<div class="post-metadata">

**Author:** ![KliG](https://avatars.discourse-cdn.com/v4/letter/k/22d042/32.png) [@KliG](https://community.influxdata.com/u/KliG)\
**Post date:** [January 5, 2019, 9:47am UTC](https://community.influxdata.com/t/implementation-of-multiple-ds18b20/8012/3 "2019-01-05T09:47:15Z")

</div>

At Telegraf the 10 results are shown, so I assume the inputs.temp works corectly … see below.  
And yes in the Influxdb is only the last entry of the Telegraf output listed.  
The readout takes about 10-15 seconds.

 ![PastedGraphic-1](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/5/542b570c2db499f57666e3af8e22561190a1de17.png)

At the source → As I understood every DS18B20 has its own serial number. [[https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf](https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf) (Description on Page 8)]

---

<div class="post-metadata">

**Author:** ![KliG](https://avatars.discourse-cdn.com/v4/letter/k/22d042/32.png) [@KliG](https://community.influxdata.com/u/KliG)\
**Post date:** [January 5, 2019, 9:53am UTC](https://community.influxdata.com/t/implementation-of-multiple-ds18b20/8012/4 "2019-01-05T09:53:45Z")

</div>

![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/9/9b9b0918551875f76f6e5e45bad1e20020f1b6ba.png)

all 28-\* are DS18B20 devices.

---

<div class="post-metadata">

**Author:** ![PaulRowntree](https://avatars.discourse-cdn.com/v4/letter/p/bb73d2/32.png) [@PaulRowntree](https://community.influxdata.com/u/PaulRowntree)\
**Post date:** [January 5, 2019, 1:00pm UTC](https://community.influxdata.com/t/implementation-of-multiple-ds18b20/8012/5 "2019-01-05T13:00:58Z")

</div>

All 10 readings have identical timestamps… are they replacing previous readings instead of adding to the database store? What happens If you space them out by even 1 nsec between readings? Or include an extra tag that makes them unique, such as the DS18B20’s unique identifier.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/daniel/32/142_2.png) [@daniel](https://community.influxdata.com/u/daniel)\
**Post date:** [January 7, 2019, 8:09pm UTC](https://community.influxdata.com/t/implementation-of-multiple-ds18b20/8012/6 "2019-01-07T20:09:09Z")

</div>

Yeah, it looks like we need another tag here to uniquely identify the sensors. What is the output of `ls -l /sys/class/hwmon/hwmon*/device/temp*`?

---

<div class="post-metadata">

**Author:** ![KliG](https://avatars.discourse-cdn.com/v4/letter/k/22d042/32.png) [@KliG](https://community.influxdata.com/u/KliG)\
**Post date:** [January 7, 2019, 8:59pm UTC](https://community.influxdata.com/t/implementation-of-multiple-ds18b20/8012/7 "2019-01-07T20:59:07Z")

</div>

Thank you for your suggestions! I would like to add the serial number as an extra tag, because if I add some more sensors on another GPIO it would not be problematic again. I am quite new to this field and I wonder how I can do that.

“are they replacing previous readings instead of adding to the database store?” actually, I know that the loggings are only from one sensor, the last read from the inputs.temp, because the temperature is significantly lower than the others. And this sensor shows over time the right data and is proper visualized in chronograf

 ![20](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/b/b9727a4fee9396b9c5d755c6ec82a7a9a1de660d.png)

---

<div class="post-metadata">

**Author:** ![KliG](https://avatars.discourse-cdn.com/v4/letter/k/22d042/32.png) [@KliG](https://community.influxdata.com/u/KliG)\
**Post date:** [January 7, 2019, 9:10pm UTC](https://community.influxdata.com/t/implementation-of-multiple-ds18b20/8012/8 "2019-01-07T21:10:16Z")

</div>

> [@daniel](#):
>
> ls -l /sys/class/hwmon/hwmon\*/device/temp\*

 ![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/2/2c1be119ee8de8db4f81679caf93bdbdfb0ab2c4.png)

and i can’t enter the folder via [cd]

---

<div class="post-metadata">

**Author:** ![daniel](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/daniel/32/142_2.png) [@daniel](https://community.influxdata.com/u/daniel)\
**Post date:** [January 7, 2019, 9:22pm UTC](https://community.influxdata.com/t/implementation-of-multiple-ds18b20/8012/9 "2019-01-07T21:22:49Z")

</div>

Can you run the command without expanding the wildcards, and don’t complete with tab, I expect it should pick up a file for each sensor. I also notice that on some platforms it uses an alternate directory, so run both of these:

```auto
ls -l '/sys/class/hwmon/hwmon*/temp*'
ls -l '/sys/class/hwmon/hwmon*/device/temp*'

```

---

<div class="post-metadata">

**Author:** ![KliG](https://avatars.discourse-cdn.com/v4/letter/k/22d042/32.png) [@KliG](https://community.influxdata.com/u/KliG)\
**Post date:** [January 8, 2019, 9:17am UTC](https://community.influxdata.com/t/implementation-of-multiple-ds18b20/8012/10 "2019-01-08T09:17:25Z")

</div>

> [@daniel](#):
>
> ls -l ‘/sys/class/hwmon/hwmon\*/device/temp\*’

Thank you yes the other command worked!  
and as you assumed there is a file for each sensor.

 ![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/1/127b3ff2c3068e95a03c48cb09b41276ca38bad1.png)

can I just rename the Sensor names?

---

<div class="post-metadata">

**Author:** ![daniel](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/daniel/32/142_2.png) [@daniel](https://community.influxdata.com/u/daniel)\
**Post date:** [January 8, 2019, 7:05pm UTC](https://community.influxdata.com/t/implementation-of-multiple-ds18b20/8012/11 "2019-01-08T19:05:00Z")

</div>

The files in `/sys` are not normal files so you won’t be able to rename them. Could you also run these commands?

```auto
cat /sys/class/hwmon/hwmon0/temp1_label
cat /sys/class/hwmon/hwmon0/name

```

---

<div class="post-metadata">

**Author:** ![noahcrowley](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/noahcrowley/32/818_2.png) [@noahcrowley](https://community.influxdata.com/u/noahcrowley)\
**Post date:** [January 8, 2019, 7:25pm UTC](https://community.influxdata.com/t/implementation-of-multiple-ds18b20/8012/12 "2019-01-08T19:25:14Z")

</div>

DS18B20s don’t have a `_label` file, which means that the [SensorKey created by gopsutil](https://github.com/shirou/gopsutil/blob/db425313bfa86d78ce81b07d8898e0f9723e0ecd/host/host_linux.go#L677) is the same for all DS18B20s attached to a device

From [the kernel documentation](https://github.com/torvalds/linux/blob/3bd6e94bec122a951d462c239b47954cf5f36e33/Documentation/hwmon/sysfs-interface#L400-L406):

```plaintext
temp[1-*]_label	Suggested temperature channel label.
		Text string
		Should only be created if the driver has hints about what
		this temperature channel is being used for, and user-space
		doesn't. In all other cases, the label is provided by
		user-space.
		RO

```

Because the application of a DS18B20 and other similar sensors can vary, the driver is generic and does not have any information about what the temperature channel is being used for, so this file is not created.

The device name, however, is unique among DS18B20s and could be used to add tags to the measurement (`/sys/class/hwmon/hwmon*/device/name`).

---

<div class="post-metadata">

**Author:** ![KliG](https://avatars.discourse-cdn.com/v4/letter/k/22d042/32.png) [@KliG](https://community.influxdata.com/u/KliG)\
**Post date:** [January 11, 2019, 12:30pm UTC](https://community.influxdata.com/t/implementation-of-multiple-ds18b20/8012/13 "2019-01-11T12:30:47Z")

</div>

> [@daniel](#):
>
> cat /sys/class/hwmon/hwmon0/temp1\_label cat /sys/class/hwmon/hwmon0/name

 ![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/8/82a19e1e2419dc2536130d074fbd4967814b40e9.png)

---

<div class="post-metadata">

**Author:** ![KliG](https://avatars.discourse-cdn.com/v4/letter/k/22d042/32.png) [@KliG](https://community.influxdata.com/u/KliG)\
**Post date:** [January 12, 2019, 3:09pm UTC](https://community.influxdata.com/t/implementation-of-multiple-ds18b20/8012/14 "2019-01-12T15:09:46Z")

</div>

I see, thank you! so can I just make a \_label file and name (like the ID) each?

and with the

temp[1-\*]\_offset

i could perform a calibration?!

---

<div class="post-metadata">

**Author:** ![KliG](https://avatars.discourse-cdn.com/v4/letter/k/22d042/32.png) [@KliG](https://community.influxdata.com/u/KliG)\
**Post date:** [January 28, 2019, 4:47am UTC](https://community.influxdata.com/t/implementation-of-multiple-ds18b20/8012/15 "2019-01-28T04:47:20Z")

</div>

hey the name (/sys/class/hwmon/hwmon\*/device/name) is not unique, as shown, I am not able to create (su) the temp1\_label file.

![image](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex023/uploads/influxdata/original/2X/8/8312e8149cba4399a11151978840592e54c472a4.png)

---

<div class="post-metadata">

**Author:** ![misho](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/misho/32/4059_2.png) [@misho](https://community.influxdata.com/u/misho)\
**Post date:** [January 21, 2020, 10:27am UTC](https://community.influxdata.com/t/implementation-of-multiple-ds18b20/8012/16 "2020-01-21T10:27:56Z")

</div>

I write solution for multiple.

> **[GitHub - mishop/sensors: lm-sensors alternative for w1-therm](https://github.com/mishop/sensors/)**
>
> lm-sensors alternative for w1-therm. Contribute to mishop/sensors development by creating an account on GitHub.

 ![multiple](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/4/423057cc0492084ff49319708cb9e35a2c898a32.png)

---

<div class="post-metadata">

**Author:** ![tbhhi](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/tbhhi/32/5537_2.png) [@tbhhi](https://community.influxdata.com/u/tbhhi)\
**Post date:** [August 25, 2020, 10:39pm UTC](https://community.influxdata.com/t/implementation-of-multiple-ds18b20/8012/17 "2020-08-25T22:39:06Z")

</div>

I am new to Telegraf and I have the same situation with 2 1-wire temperature probes (DS18B20) on the same Raspberry Pi.

Is the [sensors](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/sensors) plugin being used here? If so, it looks like the underlying `sensors` executable has a limitation that could be related; it’s described in this GitHub issue: [Multiple 1-wire sensors (e.g. DS18B20) indistinguishable · Issue #204 · lm-sensors/lm-sensors · GitHub](https://github.com/lm-sensors/lm-sensors/issues/204). When running `sensors`, both probes are labeled as `w1_slave_temp-virtual-0`.
