DS18B20 Library changes now only getting nan


#1

I’ve been using my code and the DS18B20 Library (V 0.1.3) for a couple of years with just one sensor. I just updated some code and created a new app with the latest DB18B20 Library(V 0.1.8) and all I get is nan for readings. I double checked my code, but can’t find anything wrong. As a last attempt I pasted the new code into the older app with the older version of the Library and everything works fine.

Anyplace I can find what changes were made or if anyone can clue me into what changed so I can correct my new app?

Any help would be appreciated.

Here is my code - which was working very well with no error readings:

if(!ds18b20.search()){
      ds18b20.resetsearch();
      celsiusTemp = ds18b20.getTemperature();
//      Serial.println(celsius);
      while (!ds18b20.crcCheck() && dsAttempts < 3){
//        Serial.println("Caught bad value.");
        dsAttempts++;
//        Serial.print("Attempts to Read: ");
//        Serial.println(dsAttempts);
        if (dsAttempts < 3){
//        Spark.publish("PNotification", "Temp Reset", PRIVATE);
        LED_Red_Flash(2,5,2,96);
          delay(1000);
//          celsius = celsiusTemp;
        }
        continue;
      }
        dsAttempts = 0;
        ds18b20.resetsearch();
        celsiusTemp = ds18b20.getTemperature();
  }
  if(ds18b20.crcCheck()){
      celsius = celsiusTemp;
      fahrenheit = ds18b20.convertToFahrenheit(celsius);}

#2

The main changes were to make a distinction between single drop setup (one sensor per pin) and multi drop.
For single drop, all the searching and resetting of the bus is futile and hence is bypassed when you create the bus as single drop.

If you want to see how to correctly use either scenario you may want to have a look in the updated library examples.


#3

Oooooo! I had looked - but after another look I see they added a switch…

DS18B20  ds18b20(D2, true); 

Where I had

DS18B20 ds18b20 = DS18B20(D7);

Working great now!
Thankyou!! :smile: :smile: