Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Problem with battery powered temperature sensor

Problem with battery powered temperature sensor

Scheduled Pinned Locked Moved Development
12 Posts 5 Posters 1.2k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    waspie
    wrote on last edited by
    #3

    @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 voltage
    

    but 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.

    mfalkviddM 1 Reply Last reply
    0
    • W waspie

      @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 voltage
      

      but 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.

      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by mfalkvidd
      #4

      Thanks for clarifying @waspie
      Could you post your sketch?
      EDIT: Sorry, you already did that. I'll take a look at it.

      1 Reply Last reply
      0
      • mfalkviddM Offline
        mfalkviddM Offline
        mfalkvidd
        Mod
        wrote on last edited by mfalkvidd
        #5

        I can't see anything that looks odd in the sketch. Easiest way to troubleshoot is probably to add Serial.println statements to see where the code execution stops.

        1 Reply Last reply
        0
        • W Offline
          W Offline
          waspie
          wrote on last edited by waspie
          #6

          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?

          1 Reply Last reply
          0
          • W Offline
            W Offline
            waspie
            wrote on last edited by
            #7
            This post is deleted!
            1 Reply Last reply
            0
            • N Offline
              N Offline
              nekitoss
              wrote on last edited by nekitoss
              #8

              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:

              1. 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).

              2. 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); with wait(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.

              SebexS 1 Reply Last reply
              0
              • N nekitoss

                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:

                1. 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).

                2. 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); with wait(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.

                SebexS Offline
                SebexS Offline
                Sebex
                wrote on last edited by
                #9

                @nekitoss very helpful and clear post regarding battery powering!
                I have Atmega328 16mhz, is it possible to change the 16 to 8mhz so that it can be powered by two AA batteries?

                1 Reply Last reply
                0
                • O Offline
                  O Offline
                  olka
                  wrote on last edited by
                  #10

                  @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...

                  SebexS W 2 Replies Last reply
                  0
                  • O olka

                    @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...

                    SebexS Offline
                    SebexS Offline
                    Sebex
                    wrote on last edited by
                    #11
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • O olka

                      @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...

                      W Offline
                      W Offline
                      waspie
                      wrote on last edited by
                      #12

                      @olka
                      Can't say I remember what I did anymore. Probably suppressed sending in the case of 85 degrees.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      13

                      Online

                      11.7k

                      Users

                      11.2k

                      Topics

                      113.1k

                      Posts


                      Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • MySensors
                      • OpenHardware.io
                      • Categories
                      • Recent
                      • Tags
                      • Popular