Quick answer: a DS18B20 that reads −127 °C isn't answering at all: check the data wire, the ground and the 4.7 kΩ pull-up resistor. 85 °C means the sensor hasn't finished a measurement since it powered up, and 127.94 °C usually means its power is unstable. Newer versions of the DallasTemperature library show those two as −251 and −250 instead. Below you'll find a test sketch that names each problem, the right wiring, and a simple ice-water calibration.
What you need
- From the 45-in-1 Sensor Kit: the DS18B20 temperature sensor module
- From the UNO R3 Starter Kit: the UNO R3 board and USB cable, jumper wires, and a 4.7 kΩ resistor if your sensor has no pull-up on board
- A glass, crushed ice and cold water for the calibration
- The free Arduino IDE with the OneWire (by Paul Stoffregen) and DallasTemperature (by Miles Burton) libraries

Steps
- Wire the sensor as in the table below: S (data) to pin 2, + to 5V, − to GND.
- Check the pull-up. The 1-Wire bus needs a resistor of about 4.7 kΩ between the data line and VDD. The module in our Sensor Kit has one on board. A bare 3-leg sensor (it looks like a small transistor) or a waterproof probe needs one added.
- Upload the test sketch and open the Serial Monitor at 9600 baud. It says how many sensors it found, prints each one's address, and explains any error reading in plain words.
-
Calibrate in ice water. Fill a glass with crushed ice, top it up with cold water, stir and wait two minutes. Hold the sensor in the middle, not touching the glass. Ice water is about 0 °C, so if the sketch reads 0.4 °C, set
OFFSETto −0.4 and upload again. - Keep it dry. The kit's module isn't waterproof. For the ice test, put it in a small sealed plastic bag first, or use a waterproof probe version of the sensor.

Full code: DS18B20 test and error finder
// DS18B20 test: finds the sensors, prints their addresses and explains error readings.
#include <OneWire.h>
#include <DallasTemperature.h>
const int ONE_WIRE_PIN = 2;
const float OFFSET = 0.0; // calibration: 0 minus what it reads in ice water
OneWire oneWire(ONE_WIRE_PIN);
DallasTemperature sensors(&oneWire);
void printAddress(DeviceAddress a) {
for (int i = 0; i < 8; i++) {
if (a[i] < 16) Serial.print("0");
Serial.print(a[i], HEX);
}
}
void setup() {
Serial.begin(9600);
sensors.begin();
sensors.setResolution(12); // 0.0625 °C steps, up to 750 ms per reading
int n = sensors.getDeviceCount();
Serial.print("Sensors found: ");
Serial.println(n);
if (n == 0) Serial.println("None: check the data wire, GND and the pull-up resistor");
for (int i = 0; i < n; i++) {
DeviceAddress a;
if (sensors.getAddress(a, i)) {
Serial.print("Sensor ");
Serial.print(i);
Serial.print(" address: ");
printAddress(a);
Serial.println();
}
}
}
void loop() {
sensors.requestTemperatures(); // waits until the reading is ready
float t = sensors.getTempCByIndex(0);
if (t == -127.0) {
Serial.println("-127: no answer. Check the data wire, GND and the pull-up.");
} else if (t == 85.0 || t == -251.0) {
Serial.println("85 / -251: power-on value. Check the + wire; don't read too early.");
} else if (t > 127.0 || t == -250.0) {
Serial.println("127.94 / -250: power problem. Check + and GND are firm.");
} else {
Serial.print("Temperature: ");
Serial.print(t + OFFSET, 2);
Serial.println(" C");
}
delay(1000);
}
A real 85 °C is possible in very hot water. The sketch can't tell the difference, so think about where the sensor is before you trust or doubt that reading.

Wiring

| From | To |
|---|---|
| DS18B20 module S (data, DQ) | UNO pin 2 |
| DS18B20 module + (VDD) | UNO 5V |
| DS18B20 module − (GND) | UNO GND |
| Bare sensor or probe only: 4.7 kΩ resistor | Between the data line and 5V |
Sensor modules from different makers can label and order their pins differently. Always follow the labels printed on your module. The DS18B20 runs from 3.0 to 5.5 V, so it also works with an ESP32's 3.3 V.
Build this circuit in EEMENTOR Lab
Wire it yourself in your browser before you touch a real wire. No sign-up, nothing to install.
Build it yourself
- Wire the parts using the wiring table above. Pins with no wire show red.
- Press Run, change the Temperature slider under Selected, and watch the reading.
Stuck? See the finished circuit →
EEMENTOR Lab is free and in beta. Results are a guide; a real build can differ slightly. About the Lab
Common problems
- −127 °C and "Sensors found: 0": the UNO can't talk to the sensor. A loose data wire, a missing ground, a missing pull-up or the wrong pin in the sketch are the usual causes.
- It reads −127 now and then: a wire that moves, a long cable or a breadboard hole that doesn't grip. Push the wires in firmly, and keep the cable short while you test: long cables make the 1-Wire bus less reliable.
-
85 °C (or −251) right after starting: the sensor hasn't done a measurement since power-up. Make sure
requestTemperatures()runs before you read, and that + is connected (not only data and GND). - 127.94 °C (or −250): a failed measurement, usually from unstable power. Check that + and GND are both firmly connected.
- The reading is a little off: the DS18B20 is accurate to ±0.5 °C between −10 and +85 °C. Use the ice-water calibration to remove most of the offset.
FAQ
Why does my DS18B20 show −127 °C?
−127 is not a temperature. The DallasTemperature library returns it when the sensor doesn't answer or the data is garbled, so it's always a wiring or pull-up problem.
Why does my DS18B20 show 85 °C?
85 °C is the value stored in the sensor when it powers up. If you read it before a measurement has finished, or the sensor resets because its power drops, you get 85. Newer library versions show −251 instead.
Do I need a 4.7 kΩ resistor with the DS18B20?
The 1-Wire bus needs a pull-up of about 4.7 kΩ between data and VDD. Many modules, including the one in our Sensor Kit, have it on board. A bare sensor or waterproof probe needs one added.
Can I connect several DS18B20 sensors to one pin?
Yes. Every DS18B20 has its own unique 64-bit address, so many can share one data wire and one pull-up. The test sketch prints each address, and getTempCByIndex(1) reads the second sensor.
How accurate is the ice-water calibration?
It's a single-point check at 0 °C, which removes a fixed offset. It's a quick confidence check rather than a lab calibration, but more than good enough for school projects.
Related lessons
- Measure temperature precisely with the DS18B20
- Read resistor colour codes (to find the 4.7 kΩ resistor)
- Weather station data logger