Overview

The DS18B20 is a 1-Wire digital temperature sensor manufactured by Maxim Integrated (now Analog Devices). It communicates over a single data line plus ground (1-Wire bus protocol), requiring only one microcontroller pin to interface with multiple sensors distributed over a large area.

Each DS18B20 has a unique 64-bit factory-lasered ROM ID code, allowing multiple DS18B20 sensors to coexist on the same 1-Wire bus. The sensor offers user-configurable measurement resolution from 9 to 12 bits (corresponding to 0.5 C0.5\text{ }^\circ\text{C} down to 0.0625 C0.0625\text{ }^\circ\text{C} increments).

Quick reference

Operating voltage (VDD)3.0 V – 5.5 V (Supports Parasite Power mode on DQ)
Measurement range-55 °C to +125 °C (-67 °F to +257 °F)
Accuracy±0.5 C\pm 0.5\text{ }^\circ\text{C} (from -10 °C to +85 °C)
ResolutionConfigurable 9, 10, 11, or 12 bits (0.5 C0.5\text{ }^\circ\text{C} to 0.0625 C0.0625\text{ }^\circ\text{C})
Interface1-Wire (Dallas/Maxim single-wire serial interface)
Conversion time93.75 ms (9-bit) to 750 ms (12-bit max)

Pinout

TO-92 Package & Waterproof Probe Cable

Pin / Wire ColorNameTypeDescription
1 (Left / Black)GNDPowerGround (0 V)
2 (Center / Yellow or White)DQDigital I/O1-Wire Data Input/Output (requires 4.7 kΩ pull-up to VDD)
3 (Right / Red)VDDPowerOptional external power supply (GND for parasite power mode)

Specifications

ParameterSymbolMinTypMaxUnitConditions
Supply VoltageVDD3.05.05.5VLocal power mode
Standby CurrentDDS7501000nAVDD=5.0 VV_{DD} = 5.0\text{ V}
Active CurrentDD1.01.5mADuring temperature conversion
Temperature AccuracyTaccT_{acc}±0.5\pm 0.5±2.0\pm 2.0°C10 C-10\text{ }^\circ\text{C} to +85 C+85\text{ }^\circ\text{C}
12-Bit Conversion TimetCONVt_{CONV}400750ms12-bit resolution mode
DQ Pull-Up ResistorRPUPR_{PUP}1.54.710.0Bus pull-up resistor

1-Wire protocol & scratchpad commands

Communication with the DS18B20 follows a strict sequence:

  1. Reset pulse & Presence detect (Master pulls DQ LOW for 480 μs\ge 480\text{ }\mu\text{s}, slave responds with presence pulse).
  2. ROM Command (0xCC Skip ROM for single sensor, 0x55 Match ROM for multiple sensors).
  3. Function Command (e.g. 0x44 Convert T, 0xBE Read Scratchpad).

Scratchpad memory map

The DS18B20 scratchpad consists of 9 bytes of SRAM:

ByteRegisterDescription
0Temperature LSBLow byte of temperature value (24=0.0625 C/LSB2^{-4} = 0.0625\text{ }^\circ\text{C}/\text{LSB})
1Temperature MSBHigh byte of temperature value (sign bits)
2TH RegisterHigh temperature alarm trigger byte (EEPROM backed)
3TL RegisterLow temperature alarm trigger byte (EEPROM backed)
4ConfigurationResolution setting (Bits 6:5 — 00: 9-bit, 01: 10-bit, 10: 11-bit, 11: 12-bit)
5–7ReservedFactory reserved bytes
8CRCCRC byte calculated over bytes 0 through 7 (X8+X5+X4+1X^8 + X^5 + X^4 + 1)

Temperature formula

The 16-bit temperature register stores two's-complement temperature in increments of 0.0625 C0.0625\text{ }^\circ\text{C}:

Temperature (C)=Raw 16-bit Value16\text{Temperature }(^\circ\text{C}) = \frac{\text{Raw 16-bit Value}}{16}

Wiring

Standard Local Power Setup

DS18B20Microcontroller (Arduino / ESP32)Notes
GND (Black)GNDGround
DQ (Yellow)Digital GPIO PinConnected to GPIO; 4.7 kΩ pull-up resistor to VDDV_{DD}
VDD (Red)3.3V or 5VExternal Power Supply
Warning

A pull-up resistor (typically 4.7 kΩ) between the DQ data line and VDD is mandatory. Without this pull-up resistor, the 1-Wire bus remains floating and communication will fail completely.

Common mistakes

  • Missing 4.7 kΩ pull-up resistor: The 1-Wire bus is open-drain and cannot function without an external pull-up resistor connected between DQ and VDD.
  • Not waiting for conversion to complete: At 12-bit resolution, a temperature conversion takes up to 750 ms. Attempting to read the scratchpad before this delay completes returns stale or invalid data (85 C85\text{ }^\circ\text{C} default power-on value).
  • Parasite power mode current starvation: When using parasite power mode (where VDD is tied to GND), the data line must be held strongly HIGH during conversion to supply sufficient current.

Notes

  • Power-On Reset Value: The DS18B20 scratchpad initializes to +85 C+85\text{ }^\circ\text{C} (0x0550) upon power-up. If your software reads exactly 85.0 C85.0\text{ }^\circ\text{C}, it usually indicates a power cycle occurred without issuing a new 0x44 Convert T command.

Assets & downloads