Fix DS18B20 not working properly (#1121)

* Fix Switch Celcius and Fahrenheit

* Fix overflow issue
This commit is contained in:
Benoit Courty authored and GitHub committed 2022-01-02 18:15:43 -06:00
1 parent 5c3eccbb18
commit 892cbc35f5
2 files changed
+6 -6

No files matched your search

+4 -4
View File
@@ -128,11 +128,11 @@ void MeasureDS1820Temp() {
// trigger temperature conversion some time before actually
// calling getTempC() to make reading temperatures non-blocking
if (!triggeredConversion && (millis() > (timeDS1820 + (DS1820_INTERVAL_SEC * 1000) - DS1820_CONV_TIME))) {
if (!triggeredConversion && ((millis() - timeDS1820) > (DS1820_INTERVAL_SEC * 1000UL - DS1820_CONV_TIME))) {
Log.trace(F("DS1820: Trigger temperature conversion..." CR));
ds1820.requestTemperatures();
triggeredConversion = true;
} else if (triggeredConversion && (millis() > (timeDS1820 + (DS1820_INTERVAL_SEC * 1000)))) {
} else if (triggeredConversion && ((millis() - timeDS1820) > DS1820_INTERVAL_SEC * 1000UL)) {
timeDS1820 = millis();
triggeredConversion = false;
@@ -148,8 +148,8 @@ void MeasureDS1820Temp() {
if (current_temp[i] == -127) {
Log.error(F("DS1820: Device %s currently disconnected!" CR), (char*)ds1820_addr[i].c_str());
} else if (DS1820_ALWAYS || current_temp[i] != persisted_temp[i]) {
DS1820data["tempc"] = (float)DallasTemperature::toFahrenheit(current_temp[i]);
DS1820data["tempf"] = (float)current_temp[i];
DS1820data["tempf"] = (float)DallasTemperature::toFahrenheit(current_temp[i]);
DS1820data["tempc"] = (float)current_temp[i];
if (DS1820_DETAILS) {
DS1820data["type"] = ds1820_type[i];