Improve DS18B20 resolution



  • Hello everybody.

    I would like to know if it was possible to improve the resolution for the DS18B20 sensors.

    The goal is to have a reading of XX.XX degrees instead of XX.X.

    In the DallasTemperature.CPP, i have seen "DallasTemperature::setResolution", but i don't know how to use it in the sketch, certainly in the setup(), i think.

    Thanks for answers



  • You can do as follows:

    //Declare a DeviceAddress
    DeviceAddress deviceAddress;
    
    //In your setup routine do
    sensors.getAddress(deviceAddress, index);
    //Set the resolution to 9/10/11/12 bits
    sensors.setResolution(deviceAddress, 9);
    
    //In your loop change
    gw.send(msg.setSensor(i).set(temperature,1));
    // to
    gw.send(msg.setSensor(i).set(temperature,2));
    

    Just for information, remember that the stepsize in 12bit = 0.0625 °C, so don't expect to see temperature readings like 12.50, 12.51, 12.52, ...


  • Mod

    @Totche said:

    DS18B20

    From the datasheet:
    "It has an operating temperature range of -55°C to +125°C and is accurate to ±0.5°C over the range of -10°C to +85°C."

    There's not much sense in reporting more then 1 decimal, when the sensor is only accurate up to ±0.5°C .



  • @Yveaux ,

    not entirely true, read a bit further in the datasheet:

    The resolution of the temperature sensor is user-configurable to 9, 10, 11, or 12 bits, corresponding to increments of 0.5°C, 0.25°C, 0.125°C, and 0.0625°C, respectively.
    The default resolution at power-up is 12-bit


  • Mod

    @ericvdb Resolution and accuracy are not the same! But if you're only interested in resolution, your solution will work just fine.


  • Hardware Contributor

    Agree with @Yveaux. The only situations I can see the full resolution to be useful is when one examine the accuracy or calibrate its output (e.g. offset).

    Accuracy like 0.01 C would require some high class Pt100.


Log in to reply
 

Suggested Topics

  • 87
  • 6
  • 7
  • 3
  • 8
  • 9

1
Online

11.2k
Users

11.1k
Topics

112.5k
Posts