Gbertaz / NonBlockingDallas

Arduino library for the DS18B20 temperature sensor. Avoid blocking the sketch while reading the sensor.
MIT License
11 stars 4 forks source link

conversion time and intervals #12

Open Jay-esp opened 7 months ago

Jay-esp commented 7 months ago

Nice work, just what i needed but ran into an issue. I tried a conversion time of 1000 millis but i only get 1 reading, the 1500 millis as in the example works until.... If _conversionMillis is higher than the set interval, requestTemperature is never called, should not be a problem if the interval is higher than 750 millis for 12 bit but there is a catch.. _conversionMillis is adaptive to the actual conversion time but that is where the problem is, the time calculated for the new _conversionMillis includes the overhead in my main loop, not the actual convertion time of the sensor so in my main loop i interact with a rotary encoder, switchs menus, rebuild a screen etc, the time this takes is included in the new _conversionMillis and once this is higher than the set interval, no more readings. This is also why it does not work with a setting of 1000 millis because i build my screen at the start and that takes a little bit more time than the interval.

Gbertaz commented 5 months ago

@Jay-esp So you have some procedure that is taking longer than the set interval. Are you using delay function in your main loop?

Jay-esp commented 4 months ago

No delays but yes the screen handling can take some time but its the adaptive part that is causing it, it should not adapt the timing or at least have a switch on it to disable, after all we more or less know how long the real conversion will take, once triggered it is not depending on what goes on in the loop, i solved it by using the raw code i used before but split it up, a start of conversion, no longer wait for it but check back in my loop after enough time has expired and then read it