OC
OceanRemote
Low-code IoT platform
Back to Troubleshooting Hub

DS18B20 Reading -127C

Your DS18B20 temperature sensor reports -127C instead of actual temperature. This is the sensor's power-on reset value and indicates communication failure. This guide covers missing pull-up resistor, wiring issues, 1-Wire protocol problems, and sensor addressing failures on ESP32, ESP8266, and Pico W.

Last updated: April 22, 2026 | 10 min read

Symptoms

  • Dashboard shows -127C or -127.0C
  • Serial Monitor shows "[SENSOR] DS18B20 read failed - sending error code -999"
  • Temperature reading stuck at -127C regardless of actual temperature
  • Sensor works after power cycle but fails again
  • OneWire scan finds sensor but temperature conversion fails
  • Reading alternates between -127C and actual temperature
  • Multiple DS18B20 sensors show -127C for some but not all

Common Causes

  1. Missing 4.7k Pull-up Resistor DS18B20 requires pull-up between DATA and VCC. Without it, communication fails and sensor returns -127C
  2. Insufficient Pull-up Strength Using 10k instead of 4.7k causes weak signal, intermittent -127C errors
  3. Loose or Intermittent DATA Connection Poor contact causes CRC errors, sensor returns -127C as default
  4. Power Supply Instability Voltage drops during temperature conversion cause sensor reset to -127C
  5. Long Wire Length Signal degradation on 1-Wire bus causes communication errors
  6. Parasite Power Mode Issues Using parasite power without proper strong pull-up causes conversion failure
  7. Faulty Sensor Damaged DS18B20 returns -127C as error state

What Does -127C Mean?

DS18B20 Power-On Reset Value:

After power-up, before first conversion:     SCRATCHPAD = 0x00  -127C
After failed CRC check:                     SCRATCHPAD = 0x00  -127C
After communication timeout:                SCRATCHPAD = 0x00  -127C

-127C is NOT a real temperature reading!
It indicates the sensor's internal register was never updated.

Valid temperature range: -55C to +125C
-127C is outside this range  definitely an error state.

OceanRemote converts -127C to -999C in the dashboard to indicate error.

Correct Wiring Diagrams

ESP32 with DS18B20

ESP32                    DS18B20
                    
3.3V  VDD 
                         
                        4.7k  MUST USE 4.7k, NOT 10k!
                         
GPIO15  DQ 
GND   GND 

// Without the 4.7k resistor, you WILL get -127C

Waterproof DS18B20 Wiring

Waterproof DS18B20 :

Red wire       3.3V
Yellow wire   GPIO + 4.7k pull-up to 3.3V
Black wire     GND

 Common mistake: Swapping yellow and red wires causes -127C!
Verify with multimeter: Red = VCC, Black = GND, Yellow = DATA

Step-by-Step Fixes

1. Add/Verify 4.7k Pull-up Resistor

The #1 cause of -127C is missing or wrong pull-up resistor:

  • Connect 4.7k resistor between DATA pin and VCC
  • Do NOT use 10k it may cause intermittent -127C errors
  • Color code: Yellow-Violet-Red-Gold
  • Place resistor as close to the DS18B20 as possible
  • For multiple sensors, one 4.7k resistor is sufficient
  • Measure resistance with multimeter to verify value
// Test with this sketch after adding pull-up resistor
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 15
OneWire oneWire;
DallasTemperature sensors;

void setup() {
  Serial.begin;
  sensors.begin();
  sensors.setWaitForConversion;  // Wait for conversion
}

void loop() {
  sensors.requestTemperatures();
  float temp = sensors.getTempCByIndex;
  
  if  {
    Serial.println;
  } else {
    Serial.print;
    Serial.print;
    Serial.println;
  }
  delay;
}

2. Check DATA Wire Connection

Intermittent connection causes -127C:

  • Use continuity mode on multimeter to verify DATA connection
  • Jiggle wires while measuring should stay connected
  • For breadboard connections, ensure jumper wires are fully seated
  • For soldered connections, check for cold solder joints
  • Replace damaged jumper wires

3. Add Delay After power-up

Sensor needs time to initialize:

// OceanRemote firmware includes this delay, but verify
void setup() {
  delay;  // Wait 1 second for DS18B20 to stabilize
  sensors.begin();
  delay;   // Additional delay after initialization
}

// If sensor still returns -127C, increase delay to 2000ms

4. Use Normal Power Mode

Parasite power mode is less reliable:

  • Connect VDD pin to 3.3V
  • Do NOT connect VDD to GND unless necessary
  • Normal power mode is much more reliable and recommended
  • If you must use parasite mode, add strong pull-up

5. Check Power Supply Stability

Voltage drops during conversion cause -127C:

  • Measure voltage at DS18B20 VDD pin during temperature conversion
  • Should stay stable within 3.0V-3.3V
  • Add 100F capacitor between VDD and GND near DS18B20
  • Use separate 3.3V regulator if sharing power with relays/motors
  • Ensure power supply can handle ESP32 peaks

6. Reduce Wire Length or Add Repeater

Long wires cause signal degradation:

  • Keep wire length under 10 meters
  • For longer runs, use active 1-Wire repeater
  • Use twisted pair cable
  • Reduce pull-up resistor to 2.2k for long cables
  • Add 100 resistor in series with DATA at the microcontroller end for impedance matching

7. Test with New DS18B20 Sensor

Isolate sensor vs wiring issue:

  • Replace with known working DS18B20
  • If new sensor works, original sensor is faulty
  • If new sensor also returns -127C, issue is wiring or pull-up resistor
  • Test sensor on different board

Troubleshooting Flowchart

DS18B20 reads -127C
         
         
Check 4.7k pull-up resistor
         
          Missing  Add 4.7k between DATA and VCC
         
         
Verify wiring 
         
          Wrong order  Correct wiring
         
         
Run OneWire scanner
         
          0 devices  Check connections, pull-up
         
         
Check power supply stability
         
          Unstable  Add 100F capacitor
         
         
Test with short wires 
         
          Works  Wire length issue
         
         
Replace DS18B20 sensor
         
          Works  Original sensor faulty
         
          Still -127C  Issue with microcontroller pin

Prevention Tips

  • Always use 4.7k pull-up resistor critical for reliable operation
  • Use normal power mode avoid parasite mode
  • Keep wire length under 10 meters
  • Add 100F capacitor near DS18B20 for power stability
  • Use quality jumper wires and verify continuity with multimeter
  • Test with OneWire scanner before integrating into OceanRemote
  • Add 1-second delay after power-up before first temperature read

Related Issues

Frequently Asked Questions

Q: Why -127C specifically? Why not another number?

A: -127C is the DS18B20's power-on reset value for the scratchpad register. When communication fails or CRC check fails, the sensor never updates this register, so it remains at -127C. Valid temperature range is -55C to +125C, so -127C is clearly an error.

Q: Can I use 10k pull-up instead of 4.7k?

A: 10k may work but is not recommended. The 1-Wire bus requires stronger pull-up for reliable communication, especially with longer wires or multiple sensors. 10k can cause intermittent -127C errors.

Q: My DS18B20 reads -127C only sometimes. Why?

A: Intermittent -127C indicates weak pull-up, loose connection, or power supply noise. Check pull-up resistor . Add 100F capacitor near sensor. Verify all connections are secure.

Still seeing -127C? Contact Support or return to the Troubleshooting Hub.