Dallas DS18B20¶
One-wire weather-proof temperature sensor.

Image Credit: Seeed Studio
Experimental support
The DS18B20 is not enabled in any of the default firmware builds. To use it, you need to compile the firmware with one of the flags described below. Check the guide on enabling additional features.
Working principle¶
The DS18B20 is a digital temperature sensor, originally by Dallas Semiconductor (now part of Analog Devices). It measures temperature with an integrated sensor and converts it into a digital value with a configurable resolution from 9 to 12 bits 1.
It communicates using the 1-Wire protocol: data and commands go through a single data line, and several sensors can share the same line, since each one has a unique 64-bit address. This makes it very simple to wire, even with long cables.
The sensor is very popular in a waterproof probe format: the chip is sealed inside a stainless steel tube at the end of a cable, which makes it suitable for measuring the temperature of water, soil, or air in harsh environments.
Usage and considerations¶
There are two ways to connect a DS18B20 to the SCK, each with its own firmware flag:
| Flag | Connection | Shell name | Units | API |
|---|---|---|---|---|
SCK_WITH_DALLAS_TEMP |
Directly to the Auxiliary connector | Direct Dallas Temperature |
ºC | 96 |
SCK_WITH_DS18B20 |
Through a DS2482-100 I2C to 1-Wire bridge (I2C address 0x18) |
DS18B20 Water temperature |
ºC | 42 |
Direct connection¶
With SCK_WITH_DALLAS_TEMP, the sensor is connected directly to the Auxiliary connector, and the firmware uses the SCL pin of the connector as the 1-Wire data line. You can use a grove to screw connector to connect a waterproof probe:
| DS18B20 wire | Auxiliary connector pin |
|---|---|
| Data (normally yellow) | SCL |
| VDD (normally red) | VCC (3.3V) |
| GND (normally black) | GND |
Pull-up resistor
The 1-Wire data line needs a pull-up resistor (typically 4.7kΩ) between the data and VCC lines. Many breakout modules for waterproof probes already include it. If you are using a bare probe, add it to your connection.
Other auxiliary sensors
In this mode, the SCL line of the Auxiliary connector is shared with the I2C sensors. If you see problems with other auxiliary sensors, use the DS2482-100 bridge instead.
The firmware reads the first sensor found on the line, with a resolution of 12 bits.
Through an I2C bridge¶
With SCK_WITH_DS18B20, the sensor is connected to a DS2482-100 I2C to 1-Wire bridge, which is connected to the Auxiliary connector as any other I2C sensor. This keeps the 1-Wire line separate from the I2C bus.
You can check the readings with the read and monitor commands, for instance:
read direct dallas temperature
Performance¶
| Property | Value |
|---|---|
| Sensor type | Digital temperature sensor with 1-Wire interface |
| Measurement range | -55 ºC – 125 ºC |
| Accuracy | ±0.5 ºC (from -10 ºC to 85 ºC) |
| Resolution | 0.0625 ºC (12 bits) |
Limitations¶
- In the waterproof probe format, the steel tube and the cable add some thermal inertia, so the sensor responds slowly to fast temperature changes
- When measuring air temperature, the probe needs to be protected from direct sunlight, otherwise it will measure a higher temperature than the air
- There are many counterfeit DS18B20 sensors in the market, which might not meet the specifications of the datasheet
Resources¶
References¶
-
Analog Devices. “DS18B20 Programmable Resolution 1-Wire Digital Thermometer - Datasheet.” https://www.analog.com/en/products/ds18b20.html. ↩