Skip to content

ds18b20 device

Erik Baauw edited this page Aug 5, 2026 · 2 revisions

ds18b20 Device

A ds18b20 device exposes a DS18B20 sensor connected through 1-wire, which uses GPIO pin 4. Homebridge RPi polls a file provided by 1-wire, to retrieve the sensor value. I does not interact directly with GPIO 4.

The device is exposed as a separate HomeKit accessory, with Temperature Sensor service. Through this service, you can monitor the sensor temperature in HomeKit. The accessory mimics an Eve Weather, exposing a History service, so Eve shows the history of the temperature.

The dht device uses the following config.json keys:

key type Description
name string The name for the device in HomeKit.
id string The sensor ID (12-hex digits, without the leading 28-).

Multiple sensors are supported as separate devices, each with their own ID.

Installation

The DS18B20 has three pins: ground, data, and power. Power connects to +3.3V, ground to ground, and data to GPIO 4. You need to add a 4.7 kΩ resistor between power and data. Multiple sensors can be connected in parallel, sharing GPIO 4 and the resistor.

You need to enable 1-wire on the Raspberry by, by adding dtoverlay=w1-gpio to /boot/firmware/config.txt. After rebooting the Pi, run sudo modprobe w1-gpio and sudo modprobe w1-therm to find the sensors. For each sensor found, a directory 28-nnnnnnnnnnnn is created in /sys/bus/w1/devices. This ID, nnnnnnnnnnnn, is used in config.json.

Homebridge RPi does not interact directly with GPIO 4. Instead, it reads the sensor value from /sys/bus/w1/devices/28-nnnnnnnnnnnn/temperature. These files need to be whitelisted for reading by rgpiod or pigpiod.

Check with rpi -H hostds18b20nnnnnnnnnnnn that the sensor can be read remotely.

Clone this wiki locally