I have been uneasy with the conversion time that the DS18B20 temperature sensors have, it is 750 ms when using the 12-bit resolution:
The 12-bit resolution is the default power-on, so when powering the sensor from a digital pin, you always end up in 12-bit resolution (this is the typical approach when a sensor is powered from a GPIO pin).
Checking further, the DallasTemperature Arduino library uses simple delay() function to wait for the conversion to happen, that is a waste of power:
Fortunately, the library provides option for async mode, available by running:
The user code must provide the appropriate delay, which can be done in sleeping, rather than a delay().
It is also important to chose the sufficient resolution for your application. I consider 10 or 11 bits sufficient for room/outdoor temperature monitoring, but that has to be set every time the sensor is powered up. Still, much better than waiting 750ms..
Another thing to mind is that the function getTempCByIndex(n) first needs to resolve the index ‘n’ to an address, so saving the sensor addresses to an array and calling getTempC(addr) directly should be faster. I added some code to scan the 1 Wire bus and store the addresses in an array during the setup() phase, that should be a saver.
I have updated the DS18B20 example for Funky v2 with these considerations, it is much more power efficient now.
As a conclusion, I should say that the DS18B20 is slow, maybe inappropriate for room/outdoor temperature monitoring. Its strong side is that you can have many of them on a single wire, but for room monitoring, a TMP36 would be more power efficient.
Page views: 11111