make temperature request async

This commit is contained in:
interfisch 2024-06-27 20:39:12 +02:00
parent b11e3dc9b2
commit fe93d9eff6
1 changed files with 4 additions and 1 deletions

View File

@ -113,9 +113,12 @@ void temperature_loop(unsigned long loopmillis) {
Serial.println("Warn: Request Temperatures Timeout!"); Serial.println("Warn: Request Temperatures Timeout!");
publishInfo("error/temperature","Warn: Request Temperatures Timeout!"); publishInfo("error/temperature","Warn: Request Temperatures Timeout!");
flag_requestTemperatures=false; flag_requestTemperatures=false;
last_read_ds18b20=loopmillis;
} }
if (!flag_requestTemperatures) { if (!flag_requestTemperatures) {
sensors.requestTemperatures(); //this takes ~600ms sensors.setWaitForConversion(false); //make async
sensors.requestTemperatures(); //this takes ~600ms in non async mode. about 2ms in async mode
sensors.setWaitForConversion(true);
flag_requestTemperatures=true; flag_requestTemperatures=true;
} }
if (sensors.isConversionComplete()) { if (sensors.isConversionComplete()) {