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. Hardware
  3. [SOLVED] Poor battery life on door sensor

[SOLVED] Poor battery life on door sensor

Scheduled Pinned Locked Moved Hardware
21 Posts 5 Posters 1.8k 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.
  • M Offline
    M Offline
    martinb
    wrote on last edited by Yveaux
    #1

    I’m running a door sensor on an Arduino Pro Mini 3.3v using a 3.2v 1,800 mAh LiFePo4 battery. I’ve removed the LED and voltage regulator and am using an interrupt driven sketch so that the sensor is asleep most of the time. I added some code to also report battery percentage using the Vcc library which uses the 1.1v internal reference of the MCU.

    Everything works great except that the battery life is Very poor. Each time the sensor is triggered I can see the battery percentage falling until the sensor stops responding after about 10 days, at which time the battery is fully discharged.

    Does anyone have any suggestions as to why the sensor is draining the battery so quickly?

    mfalkviddM zboblamontZ YveauxY 3 Replies Last reply
    0
    • M martinb

      I’m running a door sensor on an Arduino Pro Mini 3.3v using a 3.2v 1,800 mAh LiFePo4 battery. I’ve removed the LED and voltage regulator and am using an interrupt driven sketch so that the sensor is asleep most of the time. I added some code to also report battery percentage using the Vcc library which uses the 1.1v internal reference of the MCU.

      Everything works great except that the battery life is Very poor. Each time the sensor is triggered I can see the battery percentage falling until the sensor stops responding after about 10 days, at which time the battery is fully discharged.

      Does anyone have any suggestions as to why the sensor is draining the battery so quickly?

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

      Welcome to the MySensors community @martinb !

      Do you have a multimeter? If so, use it to measure how much current the node is using when it is in sleep mode.

      A debug log from the node can be useful as well, to verify that the node is actually sleeping.

      If you share your sketch, we could see if there is something strange in it.

      M 2 Replies Last reply
      0
      • M martinb

        I’m running a door sensor on an Arduino Pro Mini 3.3v using a 3.2v 1,800 mAh LiFePo4 battery. I’ve removed the LED and voltage regulator and am using an interrupt driven sketch so that the sensor is asleep most of the time. I added some code to also report battery percentage using the Vcc library which uses the 1.1v internal reference of the MCU.

        Everything works great except that the battery life is Very poor. Each time the sensor is triggered I can see the battery percentage falling until the sensor stops responding after about 10 days, at which time the battery is fully discharged.

        Does anyone have any suggestions as to why the sensor is draining the battery so quickly?

        zboblamontZ Offline
        zboblamontZ Offline
        zboblamont
        wrote on last edited by
        #3

        @martinb If the Node is indeed sleeping, perhaps check the reed circuit for leakage?
        The reeds I've used are fed from the junction of two resistors from Vcc to Int, with the reed closing to ground with a cap across.

        M 1 Reply Last reply
        0
        • mfalkviddM mfalkvidd

          Welcome to the MySensors community @martinb !

          Do you have a multimeter? If so, use it to measure how much current the node is using when it is in sleep mode.

          A debug log from the node can be useful as well, to verify that the node is actually sleeping.

          If you share your sketch, we could see if there is something strange in it.

          M Offline
          M Offline
          martinb
          wrote on last edited by
          #4

          @mfalkvidd

          The power usage is showing as around 6.5 mA all the time.

          This is the sketch I am using:

          // Enable debug prints to serial monitor
          #define MY_DEBUG 
          
          // Enable and select radio type attached
          #define MY_RADIO_NRF24
          //#define MY_RADIO_RFM69
          
          #include <SPI.h>
          #include <MySensors.h>
          #include <Vcc.h>
          
          #define SKETCH_NAME "Binary Sensor"
          #define SKETCH_MAJOR_VER "1"
          #define SKETCH_MINOR_VER "0"
          
          #define PRIMARY_CHILD_ID 3
          #define PRIMARY_BUTTON_PIN 3   // Arduino Digital I/O pin for button/reed switch
          
          const float VccMin   = 2.5;           // Minimum expected Vcc level, in Volts.
          const float VccMax   = 3.5;           // Maximum expected Vcc level, in Volts.
          const float VccCorrection = 1.0/1.0;  // Measured Vcc by multimeter divided by reported Vcc
          
          Vcc vcc(VccCorrection);
          
          // Change to V_LIGHT if you use S_LIGHT in presentation below
          MyMessage msg(PRIMARY_CHILD_ID, V_TRIPPED);
          
          void setup()  
          {  
            // Setup the buttons
            pinMode(PRIMARY_BUTTON_PIN, INPUT_PULLUP);
          }
          
          void presentation() {
            // Send the sketch version information to the gateway and Controller
            sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER);
          
            // Register binary input sensor to sensor_node (they will be created as child devices)
            // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
            // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
            present(PRIMARY_CHILD_ID, S_DOOR);  
          }
          
          // Loop will iterate on changes on the BUTTON_PINs
          void loop() 
          {
            uint8_t value;
            static uint8_t sentValue=2;
          
            // Short delay to allow buttons to properly settle
            sleep(5);
            
            value = digitalRead(PRIMARY_BUTTON_PIN);
            
            if (value != sentValue) {
               // Value has changed from last transmission, send the updated value
               send(msg.set(value==HIGH ? 1 : 0));
               sentValue = value;
            }
          
            float p = vcc.Read_Perc(VccMin, VccMax);
            sendBatteryLevel(p);
            
            // Sleep until something happens with the sensor
            sleep(PRIMARY_BUTTON_PIN - 2, CHANGE, 0);
          }
          
          1 Reply Last reply
          0
          • M martinb

            I’m running a door sensor on an Arduino Pro Mini 3.3v using a 3.2v 1,800 mAh LiFePo4 battery. I’ve removed the LED and voltage regulator and am using an interrupt driven sketch so that the sensor is asleep most of the time. I added some code to also report battery percentage using the Vcc library which uses the 1.1v internal reference of the MCU.

            Everything works great except that the battery life is Very poor. Each time the sensor is triggered I can see the battery percentage falling until the sensor stops responding after about 10 days, at which time the battery is fully discharged.

            Does anyone have any suggestions as to why the sensor is draining the battery so quickly?

            YveauxY Offline
            YveauxY Offline
            Yveaux
            Mod
            wrote on last edited by
            #5

            @martinb Did you build according to https://www.mysensors.org/build/binary ?
            Is the sensor normally-open, or normally-closed; does the door sensor conduct when the door is closed?

            http://yveaux.blogspot.nl

            M 1 Reply Last reply
            0
            • YveauxY Yveaux

              @martinb Did you build according to https://www.mysensors.org/build/binary ?
              Is the sensor normally-open, or normally-closed; does the door sensor conduct when the door is closed?

              M Offline
              M Offline
              martinb
              wrote on last edited by
              #6

              @yveaux
              I did follow the build instructions in your link, with the reed switch on D3. When the door is closed, the reed switch is closed (conducting).

              mfalkviddM 1 Reply Last reply
              0
              • zboblamontZ zboblamont

                @martinb If the Node is indeed sleeping, perhaps check the reed circuit for leakage?
                The reeds I've used are fed from the junction of two resistors from Vcc to Int, with the reed closing to ground with a cap across.

                M Offline
                M Offline
                martinb
                wrote on last edited by
                #7

                @zboblamont
                The current draw is the same, whether the door is open or closed.

                mfalkviddM 1 Reply Last reply
                0
                • mfalkviddM mfalkvidd

                  Welcome to the MySensors community @martinb !

                  Do you have a multimeter? If so, use it to measure how much current the node is using when it is in sleep mode.

                  A debug log from the node can be useful as well, to verify that the node is actually sleeping.

                  If you share your sketch, we could see if there is something strange in it.

                  M Offline
                  M Offline
                  martinb
                  wrote on last edited by
                  #8

                  @mfalkvidd
                  It looks as if the node is going to sleep OK, as I get this from the nodes debug log:

                  7116 MCO:SLP:MS=0,SMS=0,I1=1,M1=1,I2=255,M2=255
                  "Sleep node, duration 0 ms, SmartSleep=0, Int1=1, Mode1=1, Int2=255, Mode2=255"

                  7122 TSF:TDI:TSL
                  "Set transport to sleep"

                  mfalkviddM 1 Reply Last reply
                  0
                  • M martinb

                    @mfalkvidd
                    It looks as if the node is going to sleep OK, as I get this from the nodes debug log:

                    7116 MCO:SLP:MS=0,SMS=0,I1=1,M1=1,I2=255,M2=255
                    "Sleep node, duration 0 ms, SmartSleep=0, Int1=1, Mode1=1, Int2=255, Mode2=255"

                    7122 TSF:TDI:TSL
                    "Set transport to sleep"

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

                    @martinb after those lines, there is no debug activity until you open/close the door?

                    M 1 Reply Last reply
                    0
                    • mfalkviddM mfalkvidd

                      @martinb after those lines, there is no debug activity until you open/close the door?

                      M Offline
                      M Offline
                      martinb
                      wrote on last edited by
                      #10

                      @mfalkvidd
                      That's correct, no further log activity until the next change in state of the door

                      1 Reply Last reply
                      1
                      • M martinb

                        @yveaux
                        I did follow the build instructions in your link, with the reed switch on D3. When the door is closed, the reed switch is closed (conducting).

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

                        @martinb sorry for asking, but what pin is D3 on a promini?

                        Edit: is it the one opposite A2?

                        M 2 Replies Last reply
                        0
                        • M martinb

                          @zboblamont
                          The current draw is the same, whether the door is open or closed.

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

                          @martinb is the current draw the same if you disconnect the reed switch?

                          The sketch looks good btw.

                          M 1 Reply Last reply
                          1
                          • mfalkviddM mfalkvidd

                            @martinb sorry for asking, but what pin is D3 on a promini?

                            Edit: is it the one opposite A2?

                            M Offline
                            M Offline
                            martinb
                            wrote on last edited by
                            #13

                            @mfalkvidd
                            It may be my terminology! It's using digital pin 3 (just marked "3" on the Arduino)

                            1 Reply Last reply
                            0
                            • mfalkviddM mfalkvidd

                              @martinb is the current draw the same if you disconnect the reed switch?

                              The sketch looks good btw.

                              M Offline
                              M Offline
                              martinb
                              wrote on last edited by
                              #14

                              @mfalkvidd
                              The current draw is the same whether the reed switch is open or closed. There is a momentary increase after a change (which I assume is the radio drawing additional power to transmit?)

                              1 Reply Last reply
                              0
                              • mfalkviddM mfalkvidd

                                @martinb sorry for asking, but what pin is D3 on a promini?

                                Edit: is it the one opposite A2?

                                M Offline
                                M Offline
                                martinb
                                wrote on last edited by
                                #15

                                @mfalkvidd
                                Yes, I'm using pin 3 which is opposite A2

                                1 Reply Last reply
                                1
                                • M Offline
                                  M Offline
                                  martinb
                                  wrote on last edited by
                                  #16

                                  I'm beginning to wonder if it's the NRF24L01 that's the problem. I found this post which might explain my continuous power draw.

                                  M 1 Reply Last reply
                                  1
                                  • M martinb

                                    I'm beginning to wonder if it's the NRF24L01 that's the problem. I found this post which might explain my continuous power draw.

                                    M Offline
                                    M Offline
                                    martinb
                                    wrote on last edited by
                                    #17

                                    @martinb
                                    I replaced the NRF24L01 and now the power consumption has dramatically reduced. Thanks for all the help, as I’m new to MySensors it helped to eliminate other potential issues.

                                    mfalkviddM F 2 Replies Last reply
                                    2
                                    • M martinb

                                      @martinb
                                      I replaced the NRF24L01 and now the power consumption has dramatically reduced. Thanks for all the help, as I’m new to MySensors it helped to eliminate other potential issues.

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

                                      @martinb nice work! Thanks for reporting back.

                                      F 1 Reply Last reply
                                      1
                                      • mfalkviddM mfalkvidd

                                        @martinb nice work! Thanks for reporting back.

                                        F Offline
                                        F Offline
                                        FrankVK
                                        wrote on last edited by FrankVK
                                        #19

                                        @mfalkvidd Interesting discussion!

                                        I've got the same issue with a lux sensor based upon BH1750; battery life is limited to 7-10 days (3V, 9900mAh)
                                        I gather that it's not possible to use the interrupt method in this case?

                                        Do you have any suggestions how I can improve battery life?

                                        1 Reply Last reply
                                        0
                                        • M martinb

                                          @martinb
                                          I replaced the NRF24L01 and now the power consumption has dramatically reduced. Thanks for all the help, as I’m new to MySensors it helped to eliminate other potential issues.

                                          F Offline
                                          F Offline
                                          FrankVK
                                          wrote on last edited by
                                          #20

                                          @martinb Did you replace the NRF24L01 with another NRF24L01? iow was it a bad device?

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


                                          11

                                          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