Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temperature range goes down to -127; should stop at -55 #15

Open
TimMathias opened this issue Mar 3, 2023 · 5 comments
Open

Temperature range goes down to -127; should stop at -55 #15

TimMathias opened this issue Mar 3, 2023 · 5 comments

Comments

@TimMathias
Copy link

In simulation mode with the temperature slider at the far left (-55):

image

the Serial output displays:
Temperature is: -127.00

It should display:
Temperature is: -55.00

@bonnyr
Copy link
Owner

bonnyr commented Mar 4, 2023

Can you share some info about your project?
We've had some spurious behaviour when used with ESP32.

Temperature of -127 usually means that the 1-wire communication is not successful - this is the default value that the host library initialises the temperature setting to.

@TimMathias
Copy link
Author

It's the DS18B20 demo project using an Arduino Uno.

image

image

The temperature range from -54.875 to +125 is printed correctly, but -55 is printed as -127.

@bonnyr
Copy link
Owner

bonnyr commented Mar 6, 2023

@TimMathias

I spent some time looking around at the DallasTemperature library and I noticed several commits related to handling negative numbers.

I think the issue lies 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 DISCONNECTED sensor when in reality it is not.

I have opened an issue here: milesburton/Arduino-Temperature-Control-Library#236

Hopefully, this can be resolved either by fixing this bug (according to me :) ) or telling me what is wrong in my assertion...
I will leave this issue open until I hear from the maintainer of DallasTemperature

@TimMathias
Copy link
Author

As a workaround, could you constrain the scaled range to -7039 to +16000?

That would be -54.9921875 to +125°C which would be rounded off by many programmes.

@bonnyr
Copy link
Owner

bonnyr commented Mar 6, 2023

the minimum is -54.875 simply because how the sensor reports the temperature, there's no way to specify this with the same precision as the library.

I would rather not do this in the sensor if I can avoid this.

Since this is a simulation, the controls specify the temperature, wouldn't that be sufficient to set the temp to the value you desire? Or is there something else in your project that controls the temp?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants