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, ...
-
@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
-
@ericvdb Resolution and accuracy are not the same! But if you're only interested in resolution, your solution will work just fine.
-
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.