Temperature resolution for low power node

I managed to build two low powered temperature nodes and an RFM12Pi expansion board on a Raspberry Pi, all configured and working properly.  More thanks to your excellent website than my proficiency, so many thanks for the detailed build instructions.
However I have a question regarding the resolution.  I set this to 10 bits using the emontx_lowpower_temperature example sketch and expected temperature data in steps of 0.25°C, yet my data are in steps of approximately 0.063°C.
Does the DS18B20 not default to 12 bits i.e. 0.0625°C each time it is powered up, and therefore the resolution would need to be set on each power up cycle?
Would setting the resolution to 10 bits on each power cycle actually save any power or would it be better just leaving it to the default?
 

o_cee's picture

Re: Temperature resolution for low power node

Did you change "const int sensorResolution" (https://github.com/openenergymonitor/emonTxFirmware/blob/master/emonTx_t...)? If you did, it changes the resolution on every startup in setup(), yes it defaults to 12 bit.

The normal way of reading the temperature will use delay() for 750ms when in 12bit mode. 11 bit is 750/2ms, 10 bit is 750/4 and 9 bit is 750/8ms if I remember correct. Sure it will affect power consumption, but I'll leave those calculations to someone else :)

It is also possible to read the temperature async and do some sleeping in the mean time instead.

john.b's picture

Re: Temperature resolution for low power node

Yes I changed line 45 to "const int sensorResolution = 10; " .

Although if I understand the sketch correctly (I'm new to this so I may not) the DS18B20 will be switched on and off within loop() and therefore will default to 12 bits at line 99 when the DS18B20 is turned on again.

Isn't setup() run only when the node is powered up i.e. when the batteries are inserted and the sketch first starts?

o_cee's picture

Re: Temperature resolution for low power node

Ah you mean like that. Yes could be true, easy enough to check with getResolution() after wakeup.

john.b's picture

Re: Temperature resolution for low power node

I can confirm that when using the emontx_lowpower_temperature sketch the resolution is only changed for the first reading, subsequent temperature readings are at the default 12 bit resolution, since the sensor has powered down.

Setting the resolution on every cycle within loop() does not seem to save any power as the increased time to set the resolution negates any time / power saving from reducing the resolution.

Therefore I believe it’s better to just remove the lines concerning the resolution and just let the sensor default to 12 bits.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.