Another DS18B20 Question

I have a waterproofed DS18B20 sensor which I cannot get a temp reading from. What’s strange is the device address from the sensor is returned just not the temperature. I would think if communication is established enough to read the address, temperature should be returned as well correct?

Using single drop with 4.7k pull up resistor and powering directly with 3V from the Boron and Argon devices I have. Sensor is returning the 85 error code.

Below is the single drop example code from the DS18B20 library which I’m using. Substituting in a spare waterproofed sensor works fine and returns address and temp. Is my original DS18B20 sensor bad or is there something I can do to further troubleshoot?

#include <DS18B20.h>
#include <math.h>


const int      MAXRETRY          = 4;
const uint32_t msSAMPLE_INTERVAL = 2500;

const int16_t dsData = A0;

// Sets Pin A0 as data pin and the only sensor on bus
DS18B20  ds18b20(dsData, true); 

char     szInfo[64];
double   celsius;
double   fahrenheit;
uint32_t msLastMetric;
uint32_t msLastSample;

uint8_t dsAddress[8];

void setup() {


void loop() {
  if (millis() - msLastSample >= msSAMPLE_INTERVAL){
    msLastSample = millis();

void getTemp(){
  float _temp;
  int   i = 0;

  do {
    _temp = ds18b20.getTemperature();
  }while (!ds18b20.crcCheck() && MAXRETRY > i++);

  if (i < MAXRETRY) {
    celsius = _temp;
    // fahrenheit = ds18b20.convertToFahrenheit(_temp);
  else {
    celsius = fahrenheit = NAN;
    Serial.println("Invalid reading");

void printAddress(uint8_t deviceAddress[8])
  for (uint8_t i = 0; i < 8; i++)
    if (deviceAddress[i] < 0x10) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
    if (i < 7) Serial.print(", ");

what would happen if you increase this parameter to something like 30?
I know I know, sounds silly…

Unfortunately, it changed absolutely nothing.

Could you try to put in between this two lines this:


From DS18B20.cpp:

So maybe this 750ms _sampleDelay is really not enough in your case.

You could try using a lower value resistor pull-up of 3.33k to limit the current flow to the pin to approximately 1 mA. The 4.7k resistor which comes with some DS18B20 sensors was intended for 5V boards.

Another thing to try would be to increase the clocking speed in setup():

Wire.setSpeed(CLOCK_SPEED_400KHZ);//set the I2C clock speed to 400Khz

Using a 2.2k pull up resistor and updating the clock speed did not help. Also @dreamER I did try resetting the OneWire bus and that did not work either. I do appreciate all the help.

At this point I’ll spend $10 and get another sensor. I’ll chalk it up to this one being bad but it was curious oddity the sensor would return it’s address but not the requested temperature.

it’s not just about reset() it’s more about conversion time (750ms) which in many cases is not enough. Here is better explanation:

also I’ll try to change resolution as max 12bits (0.0625 ° C) is not really required in typical applications
but… If you already decided to get a new one , I’m not sure if this matter :slight_smile:

by the way, the returned value of 85 is not an error code is correct :+1:


1 Like