Problem with battery powered temperature sensor
-
@mfalkvidd said in Problem with battery powered temperature sensor:
Could you describe the problem you are experiencing?
The temperature/voltage isn't being sent when battery powered.
from the good log:4349 TSF:MSG:SEND,5-5-0-0,s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:28.0 <---temperature 4362 TSF:MSG:SEND,5-5-0-0,s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=OK:100 <---battery percentage 4372 TSF:MSG:SEND,5-5-0-0,s=1,c=1,t=38,pt=7,l=5,sg=0,ft=0,st=OK:3.39 <---- vcc voltagebut those items aren't sent when it is powered by 2xAA. Also, it doesn't seem to go to sleep or wakeup (one or the other).
If I keep watching the serial log while battery powered it never does anything more. Not after the allotted 30 seconds or longer. As if it is stuck.
-
@mfalkvidd said in Problem with battery powered temperature sensor:
Could you describe the problem you are experiencing?
The temperature/voltage isn't being sent when battery powered.
from the good log:4349 TSF:MSG:SEND,5-5-0-0,s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:28.0 <---temperature 4362 TSF:MSG:SEND,5-5-0-0,s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=OK:100 <---battery percentage 4372 TSF:MSG:SEND,5-5-0-0,s=1,c=1,t=38,pt=7,l=5,sg=0,ft=0,st=OK:3.39 <---- vcc voltagebut those items aren't sent when it is powered by 2xAA. Also, it doesn't seem to go to sleep or wakeup (one or the other).
If I keep watching the serial log while battery powered it never does anything more. Not after the allotted 30 seconds or longer. As if it is stuck.
-
i stripped out enough stuff to see it post 85 degrees the first time around. after that it is reporting the temperature consistently on battery (including going to sleep, waking up, reporting, and going back to sleep).
Any thoughts on why it fails the first time through?
My hack solution would be to remove the check and let it throw out 85 the first time through and discard that on the other send (openhab) but surely there's a better way?
-
Hi, @waspie !
First of all i'd like to say about value "85" - according to DS18B20 datasheet page 6, note after table 4.1:
*The power-on reset value of the temperature register is +85°C.Your code looks fine and similar to my mains-powered DS18B20 sensor (because we used same example).
I have some thoughts:
-
you may have power problems:
a. from logs i see that you have 1 sensor, but you left defined#define MAX_ATTACHED_DS18B20 16. If (suddenly) you would have 16 sensors - when you ask them for conversion they would consume 16* 1.5mA(max at 5v) = 24mA which is above recomended 20mA for atmega pin
b. you are powering from battery: DS18B20 oficially requres minimum of 3 v (as for datasheet). People say that with lower voltage it may have strange readings or even do not work at all
c. you are powering from battery through pin: is voltage raise fast enougth before start reading? is voltage drop low enought so voltage supplied to ds18b20 is >=3v?
i'd suggest you to measure voltages (but multimeter won't show you short drop-outs when start conmsuming) and try to feed VCC of DS18b20 directly from power source. If not possible - at least measure voltage and try to add some wait() after powering up pin (or also before measure start or after sleep). -
When running from 3v, what frequency of atmega processor is? If it is 16mHz - that it is not in safe operating area for that voltage. you should run 8 mHz. (>=2.4v for 8mHz and >=3.78v for 16mHz)
Also i suggest you try to change
sleep(conversionTime);withwait(conversionTime);and check if it will change anything (especially when ds18b20 directly powered from source). Also try with fresh batteries.If nothing helped, then for "85" value simple solution will be
if (temperature != 85) send();because it is very rarely that people need to measure 85 degrees of Celsius at home...
~~ ~~
For advanced battery-powering i highly recommend to read this. Also you can find there about frequency vs voltage.And for internal battery voltage reading:
i don't remember where i found it: here1 or here2 or somwhere else..
but you may want to get more accurate readings by measuring and setting Internal Reference Voltage value and using it in the code, and give it some time to stabilize and/or use some type of averaging. -
-
Hi, @waspie !
First of all i'd like to say about value "85" - according to DS18B20 datasheet page 6, note after table 4.1:
*The power-on reset value of the temperature register is +85°C.Your code looks fine and similar to my mains-powered DS18B20 sensor (because we used same example).
I have some thoughts:
-
you may have power problems:
a. from logs i see that you have 1 sensor, but you left defined#define MAX_ATTACHED_DS18B20 16. If (suddenly) you would have 16 sensors - when you ask them for conversion they would consume 16* 1.5mA(max at 5v) = 24mA which is above recomended 20mA for atmega pin
b. you are powering from battery: DS18B20 oficially requres minimum of 3 v (as for datasheet). People say that with lower voltage it may have strange readings or even do not work at all
c. you are powering from battery through pin: is voltage raise fast enougth before start reading? is voltage drop low enought so voltage supplied to ds18b20 is >=3v?
i'd suggest you to measure voltages (but multimeter won't show you short drop-outs when start conmsuming) and try to feed VCC of DS18b20 directly from power source. If not possible - at least measure voltage and try to add some wait() after powering up pin (or also before measure start or after sleep). -
When running from 3v, what frequency of atmega processor is? If it is 16mHz - that it is not in safe operating area for that voltage. you should run 8 mHz. (>=2.4v for 8mHz and >=3.78v for 16mHz)
Also i suggest you try to change
sleep(conversionTime);withwait(conversionTime);and check if it will change anything (especially when ds18b20 directly powered from source). Also try with fresh batteries.If nothing helped, then for "85" value simple solution will be
if (temperature != 85) send();because it is very rarely that people need to measure 85 degrees of Celsius at home...
~~ ~~
For advanced battery-powering i highly recommend to read this. Also you can find there about frequency vs voltage.And for internal battery voltage reading:
i don't remember where i found it: here1 or here2 or somwhere else..
but you may want to get more accurate readings by measuring and setting Internal Reference Voltage value and using it in the code, and give it some time to stabilize and/or use some type of averaging. -
-
@Sebex The quickest way is to upload a new bootloader that use the Atmega 8mhz internal oscillator, like this one: https://github.com/MCUdude/MiniCore
As serial timing will be less accurate with the internal oscillator you might also need to include #define MY_BAUD_RATE 9600 in your scetch.@waspie Did you try using Serial.print for step by step debugging to narrow in on the issues? For example; in the function readVcc(), what is the actual returned value when running on batteries? and so on...
-
@Sebex The quickest way is to upload a new bootloader that use the Atmega 8mhz internal oscillator, like this one: https://github.com/MCUdude/MiniCore
As serial timing will be less accurate with the internal oscillator you might also need to include #define MY_BAUD_RATE 9600 in your scetch.@waspie Did you try using Serial.print for step by step debugging to narrow in on the issues? For example; in the function readVcc(), what is the actual returned value when running on batteries? and so on...
-
@Sebex The quickest way is to upload a new bootloader that use the Atmega 8mhz internal oscillator, like this one: https://github.com/MCUdude/MiniCore
As serial timing will be less accurate with the internal oscillator you might also need to include #define MY_BAUD_RATE 9600 in your scetch.@waspie Did you try using Serial.print for step by step debugging to narrow in on the issues? For example; in the function readVcc(), what is the actual returned value when running on batteries? and so on...