← 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| Pin | Name | Functions | Notes |
|---|---|---|---|
| 3 | VDD | POWER | Optional VDD. Must be grounded for parasite power mode. |
| 2 | DQ | GPIO | Data Input/Output. Open-drain 1-Wire interface pin. Also provides power in parasite power mode. |
| 1 | GND | 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
3Starter 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
| Pin | Arduino Uno R3 | ESP32 DevKitC (WROOM-32) | Notes |
|---|---|---|---|
| VDD | +5V | 3V3 | 3.0-5.5 V |
| DQ | D2 | GPIO4 | Add a 4.7 kohm pull-up from DQ to VDD |
| GND | GND | GND |