If you are searching for a sensor ds1820 for an Arduino, ESP32, or Raspberry Pi project, you need to know a critical piece of industry history: the original Dallas Semiconductor DS1820 chip was retired in the early 2000s. When you buy a 'DS1820' module today, you are almost certainly receiving a DS18B20 (12-bit resolution) or a DS18S20 (9-bit resolution). While they share the same TO-92 footprint and 1-Wire protocol, their internal scratchpad structures and raw-to-unit math are entirely different. Copy-pasting legacy DS1820 code onto a modern DS18B20 will result in wildly inaccurate temperature readings.

This guide provides the exact wiring matrices, raw-to-Celsius conversion math, and 1-Wire debugging frameworks you need to interface these sensors reliably, whether you are using standard external power or parasitic power mode.

Sensing Principle and Digital Output Architecture

The DS1820 family does not output an analog voltage or a varying current. It utilizes a solid-state bandgap temperature sensing principle. Inside the silicon, the sensor measures the difference in base-emitter voltage ($\Delta V_{BE}$) between two bipolar transistors operating at different current densities. Because this voltage difference is strictly proportional to absolute temperature (PTAT), the onboard analog-to-digital converter (ADC) digitizes this physical property directly into a binary number stored in the chip's scratchpad memory.

Because the output is strictly digital, the sensor communicates via the Maxim/Analog Devices 1-Wire protocol. This means the microcontroller sends command bytes over a single data line, and the sensor responds with its digital temperature payload. No analog reference pins, no op-amp signal conditioning, and no ADC pin mapping on your microcontroller are required. You only need a single GPIO pin configured for bit-banged 1-Wire communication, alongside power and ground.

Hardware Specifications and Wiring Matrix

Before writing any code, you must establish a stable physical layer. The 1-Wire protocol is unforgiving of poor wiring and incorrect pull-up resistor values. Below is the definitive specification and wiring matrix for the modern DS18B20 (and compatible DS18S20) in standard VDD power mode.

DS18B20 / DS18S20 Hardware & Wiring Specifications
Parameter Value / Specification Engineering Notes
Supply Voltage (VDD) 3.0V to 5.5V DC Do not exceed 5.5V. For 3.3V MCUs (ESP32/Pi), power the sensor from the 3.3V rail to avoid 5V logic backfeeding into the GPIO.
Pin 1 (GND) Ground Reference Must share a common ground plane with the microcontroller. The black wire on waterproof probes.
Pin 2 (DQ) Data I/O (1-Wire) Requires a 4.7kΩ pull-up resistor to VDD. The yellow (or white) wire on waterproof probes.
Pin 3 (VDD) Power Supply The red wire on waterproof probes. If using Parasitic Power mode, tie this pin to GND.
Standby Current 1.0 µA (max) Extremely low quiescent draw, making it ideal for battery-powered ESP32 deep-sleep nodes.
Active Conversion Current 1.0 mA to 1.5 mA Drawn only during the 750ms (max) temperature conversion phase.
Accuracy ±0.5°C (-10°C to +85°C) Degrades to ±2.0°C at the extreme limits (-55°C or +125°C).
Bench Tip: Waterproof Probe Wire Colors
Commercially potted waterproof DS18B20 probes almost universally follow this color code: Red = VDD, Black = GND, Yellow (or sometimes White) = DQ. Always verify with a multimeter continuity test against the TO-92 pinout if you are salvaging bare chips, as aftermarket manufacturers occasionally swap the yellow and white data lines.

Raw-to-Unit Math and Signal Scaling

Because the sensor outputs a digital scratchpad rather than an analog voltage, 'calibration' in the traditional sense (adjusting a trimpot or reference voltage) does not apply. The sensor is factory-calibrated. Your microcontroller's only job is to read the 16-bit raw hex value from the scratchpad and apply the correct scaling math based on the exact silicon variant you have.

The Analog Devices DS18B20 datasheet defines the output as a 16-bit, two's complement signed integer. Here is the exact math to convert the raw register bytes into physical Celsius units.

DS18B20 Math (12-Bit Resolution)

The DS18B20 defaults to 12-bit resolution, yielding a step size of 0.0625°C. The raw 16-bit value is formed by combining the MSB (Most Significant Byte) and LSB (Least Significant Byte).

  • Formula: Temperature (°C) = Raw_16bit_Integer / 16.0
  • Example 1 (+25.0625°C): Raw Hex 0x0191 -> Decimal 401. 401 / 16.0 = 25.0625°C
  • Example 2 (-10.125°C): Raw Hex 0xFF5E -> Decimal -162 (two's complement). -162 / 16.0 = -10.125°C

Original DS1820 / DS18S20 Math (9-Bit Resolution)

If you are maintaining legacy equipment with genuine original DS1820 or DS18S20 chips, the resolution is 9-bit (0.5°C steps). The math is completely different, and the scratchpad includes 'Count Remain' and 'Count Per °C' registers for extended precision.

  • Basic Formula: Temperature (°C) = Raw_9bit_Integer * 0.5
  • Example (+25.0°C): Raw Hex 0x0032 -> Decimal 50. 50 * 0.5 = 25.0°C
The 85°C Power-On Reset Trap
If your serial monitor consistently prints exactly 85.0°C, your sensor is not measuring the ambient temperature. 85°C is the hardcoded power-on reset (POR) value of the DS18B20 scratchpad. This means your microcontroller is reading the register before the sensor has completed its 750ms conversion cycle, or the sensor browned out during conversion. Add a strict delay(750) after sending the 0x44 Convert T command, or use the PJRC OneWire library's blocking read functions.

Interference Sources, Parasitic Power, and Counterfeits

While the 1-Wire protocol is robust in theory, real-world jobsite and bench environments introduce specific interference modes that will corrupt your data. Understanding these failure states is the difference between a sensor that works on a breadboard and one that fails in a finished enclosure.

1. Capacitive Loading on Long Wire Runs

The 1-Wire protocol relies on precise microsecond timing. The microcontroller pulls the DQ line low to send a '0', and releases it to let the 4.7kΩ pull-up resistor bring it high for a '1'. If you run a waterproof probe cable longer than 10 meters, the parasitic capacitance of the cable acts as a low-pass filter. The 4.7kΩ resistor cannot charge the cable capacitance fast enough, rounding off the square waves into slopes. The microcontroller misreads the timing, resulting in CRC (Cyclic Redundancy Check) failures.
The Fix: For runs between 10m and 30m, drop the pull-up resistor to 2.2kΩ or 1.0kΩ to increase the charge current. For runs over 30m, abandon bit-banging and use an active 1-Wire master IC like the DS2480B.

2. Parasitic Power Brownouts

The DS18B20 supports 'Parasitic Power' mode, where VDD is tied to GND, and the chip harvests power from the DQ line via an internal diode, storing it in an internal capacitor. This is useful when you only have two wires available.
The Failure Mode: During the temperature conversion phase, the sensor draws up to 1.5mA. If the microcontroller's GPIO pin cannot source this current while holding the line high, the internal capacitor voltage droops, the sensor resets, and the conversion aborts (yielding the 85°C error).
The Fix: Never rely on the microcontroller's internal pull-up or a standard GPIO pin to supply parasitic power. Use a dedicated MOSFET (like a 2N7000) controlled by a second GPIO pin to hard-drive the DQ line high during the 750ms conversion window, as recommended in the ESPHome Dallas sensor documentation.

3. The Counterfeit Chip Epidemic

The market is flooded with clone DS18B20 sensors. These counterfeit chips often pass basic room-temperature tests but exhibit catastrophic failures in production.
Symptoms of Clones:

  • ROM ID Collisions: Genuine chips have a unique 64-bit laser-trimmed ROM. Clones often share the exact same ROM ID, making it impossible to address multiple sensors on the same 1-Wire bus.
  • High-Temperature Lockup: Clones frequently return garbage data or lock up completely when exposed to temperatures above 85°C, whereas genuine chips are rated to 125°C.
  • Missing Scratchpad Bytes: Clones may ignore the 'Write Scratchpad' command, meaning you cannot change the resolution from the default 12-bit.

The Fix: Source sensors from authorized distributors (Mouser, Digi-Key, Arrow) rather than open-marketplaces. If you must use cheap probes, implement a strict CRC-8 check in your firmware on every single read. If the CRC fails, discard the reading and retry; never trust a payload that fails the Dallas CRC-8 polynomial.