Component guide · Beginner · 3 min read
DS18B20 Waterproof Temperature Sensor

Wiring and Code
By Geekobot Learning Team · Updated 24 Oct 2026
On this page
The DS18B20 is a digital temperature sensor that talks over a single data wire called 1-Wire. It measures −55 to +125 °C, accurate to ±0.5 °C between −10 and +85 °C, and runs from 3.0 to 5.5 V. It needs a 4.7 kΩ pull-up resistor from data to VCC. Each sensor has a unique 64-bit address, so many probes can share one pin. The waterproof steel probe suits water, soil and freezers.
Key specs at a glance
- Range
- −55 to +125 °C
- Accuracy
- ±0.5 °C from −10 to +85 °C
- Resolution
- 9 to 12 bits (0.5 to 0.0625 °C)
- Conversion time
- Up to 750 ms at 12-bit
- Supply
- 3.0 to 5.5 V
- Interface
- 1-Wire with a 4.7 kΩ pull-up; unique 64-bit ROM address
Wiring
TO-92 package (flat face towards you, legs down): left GND, middle DQ (data), right VDD.
Waterproof probe: red is VDD, black is GND, and yellow (sometimes white) is data. Colours vary between sellers, so check the listing.
Connect VDD to 3.3 V or 5 V, GND to GND, data to any digital pin, and a 4.7 kΩ resistor between data and VDD. With long cables (over about 10 m) or many sensors, a lower pull-up such as 2.2 kΩ and a 3-wire connection help. Parasite power, where VDD is tied to GND, saves a wire but is less reliable; use normal power when you can.
Code with OneWire and DallasTemperature
Install the OneWire and DallasTemperature libraries.
`` #include <OneWire.h> #include <DallasTemperature.h> OneWire bus(4); DallasTemperature sensors(&bus); void setup(){ Serial.begin(115200); sensors.begin(); } void loop(){ sensors.requestTemperatures(); Serial.println(sensors.getTempCByIndex(0)); delay(1000); } ``
For several probes on one pin, print each sensor's address once with getAddress(), then read them by address so the order never changes. Reducing resolution to 10 bits cuts conversion time to about 190 ms.
Reading 85 °C or −127 °C?
(DEVICE_DISCONNECTED_C) means the library cannot see the sensor: check the pull-up resistor, wiring order and the pin number.
is the power-on reset value: the reading was taken before a conversion finished, often because the sensor is on parasite power or the supply dips.
on long cables: lower the pull-up value, use twisted-pair or shielded cable, and add a 100 nF capacitor near the sensor.
Many low-cost probes use clone chips that are less accurate; check against a known thermometer and apply an offset if needed.
Try it: Voltage drop calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Leaving out the 4.7 kΩ pull-up resistor.
- Swapping VDD and GND, which makes the sensor hot.
- Reading by index with several sensors, so the order changes.
- Relying on parasite power with long cables.
- Expecting fast readings at 12-bit resolution.
Frequently asked questions
Why does my DS18B20 read -127?
The sensor is not detected. Check the 4.7 kΩ pull-up, wiring order and that the code uses the right pin.
Why does my DS18B20 always read 85 °C?
85 °C is the power-on value. The conversion did not complete, usually due to parasite power or a weak supply.
How many DS18B20 sensors can I put on one pin?
Dozens in theory, each with its own 64-bit address. In practice 10 to 20 on a few metres of cable works well; lower the pull-up for more.
Can the DS18B20 work at 3.3 V?
Yes, from 3.0 to 5.5 V, so it suits ESP32 and Raspberry Pi Pico.
Is the waterproof DS18B20 safe to submerge?
The steel probe tip and cable are sealed for water. Keep the cable end with the wires dry, and avoid long immersion in hot liquids above the cable's rating.
Parts for this guide
- ₹33View
Calculators
Terms in this guide
Projects that use it
Put this into practice: 154 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

