Arduino-Temperature-Control-Library
Arduino-Temperature-Control-Library copied to clipboard
bug: sensor (DS18S20) is considered disconnected when reporting the lowest temperature (-55 deg C)
When a sensor is reporting -55°C, the library treats the sensor as disconnected and reports temperature readings as -127°C.
The issue appears to lie with the library since it defines the following (in DallasTemperature.h
):
#define DEVICE_DISCONNECTED_RAW -7040
And has the following to say about that value in the implementation (DallasTemperature.cpp
):
// returns temperature in 1/128 degrees C or DEVICE_DISCONNECTED_RAW if the
// device's scratch pad cannot be read successfully.
// the numeric value of DEVICE_DISCONNECTED_RAW is defined in
// DallasTemperature.h. It is a large negative number outside the
// operating range of the device
int32_t DallasTemperature::getTemp(const uint8_t* deviceAddress) {
ScratchPad scratchPad;
if (isConnected(deviceAddress, scratchPad))
return calculateTemperature(deviceAddress, scratchPad);
return DEVICE_DISCONNECTED_RAW;
However, -55 deg C is exactly -7040 (if you multiply it by 128 which the code does all over)
Thus, when you request a reading the next time, the value matches a DEVICE_DISCONNECTED_RAW sensor when in reality it is not.
This was tested with the latest version in master
.