← All parts

DS18B20 1-Wire Temp

DS18B20

Analog Devicessensor environment

The DS18B20 is a digital thermometer that measures temperature from -55°C to +125°C with user-selectable resolution. It communicates via a single data line (1-Wire bus) and can be powered directly from this line, eliminating the need for an external power supply.

In stock

Specifications

10
Operating Voltage
3.0 V
Operating Voltage
5.5 V
Temperature Range
-55 °C
Temperature Range
+125 °C
Accuracy
±0.5 °C
Accuracy Range
-10 °C
Accuracy Range
+85 °C
Resolution
9 to 12 bits
Interface
1-Wire
Package
TO-92, SO, µSOP

Pinout

3
PinNameFunctionsNotes
3VDD
POWER
Optional VDD. Must be grounded for parasite power mode.
2DQ
GPIO
Data Input/Output. Open-drain 1-Wire interface pin. Also provides power in parasite power mode.
1GND
GND
Ground

Interactive pinout

Highlight:
DS18B20

Click a pin to copy its name · tap a tag above to spotlight a bus.

Logic level & voltage

Operates from 3.0-5.5 V (per the datasheet specs) over a single 1-Wire data line, so it works directly with both 3.3 V and 5 V microcontrollers.

Typical uses

  • Temperature logging and thermostats
  • Multi-point sensing on one bus (each sensor has a unique ROM ID)
  • Liquid/soil temperature with the waterproof probe variant

Wiring notes & gotchas

  • A ~4.7 kΩ pull-up from the data line to VDD is required.
  • Prefer normal (3-wire) power over parasite power for reliability.
  • Long buses benefit from a lower-value pull-up and star/daisy topology care.

Commonly used with

3

Starter code

Community starter examples — minimal, unofficial, and provided to get you wiring fast. Verify against the manufacturer datasheet before relying on them.

Arduino (C++)

Arduino library: DallasTemperature (+ OneWire)

arduino
// DS18B20 1-Wire temperature — community starter example
#include <OneWire.h>
#include <DallasTemperature.h>

#if defined(ESP32)
  #define ONE_WIRE_BUS 4    // ESP32: GPIO4
#else
  #define ONE_WIRE_BUS 2    // Uno: D2
#endif

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup() {
  Serial.begin(115200);
  sensors.begin();
}

void loop() {
  sensors.requestTemperatures();
  Serial.print("T="); Serial.print(sensors.getTempCByIndex(0)); Serial.println(" C");
  delay(1000);
}

MicroPython

python
# DS18B20 1-Wire (ESP32) — community starter example
# uses the built-in `onewire` + `ds18x20` modules
from machine import Pin
import onewire, ds18x20, time

ow = onewire.OneWire(Pin(4))        # DQ on GPIO4
ds = ds18x20.DS18X20(ow)
roms = ds.scan()

while True:
    ds.convert_temp()
    time.sleep_ms(750)
    for rom in roms:
        print(ds.read_temp(rom), "C")
    time.sleep(1)

Wiring

PinArduino Uno R3ESP32 DevKitC (WROOM-32)Notes
VDD+5V3V33.0-5.5 V
DQD2GPIO4Add a 4.7 kohm pull-up from DQ to VDD
GNDGNDGND

Related parts

6