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. Sensebender Micro Battery Code

Sensebender Micro Battery Code

Scheduled Pinned Locked Moved Development
10 Posts 5 Posters 2.5k Views 7 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
    meddie
    wrote on last edited by
    #1

    Hello together,

    i have bought a sensebender micro to test as temp and humidity sensor. I use the example sketch from sensebender, and for test i used a cd2032 battery but the battery is after 14 days empty.
    So i have to optimize my code and would like to ask you which settings are you using for battery nodes.

    How often do you transmit the temp / humidity?
    Which threshold for changing the temp / humidity?

    Thanks a lot
    Greets Eddie

    TigroenotT 1 Reply Last reply
    0
    • M meddie

      Hello together,

      i have bought a sensebender micro to test as temp and humidity sensor. I use the example sketch from sensebender, and for test i used a cd2032 battery but the battery is after 14 days empty.
      So i have to optimize my code and would like to ask you which settings are you using for battery nodes.

      How often do you transmit the temp / humidity?
      Which threshold for changing the temp / humidity?

      Thanks a lot
      Greets Eddie

      TigroenotT Offline
      TigroenotT Offline
      Tigroenot
      wrote on last edited by
      #2

      @meddie As far as I'm concerned you should use the sleep() function. Also it's a good idea to use internal oscillator down to 1mhz and set the BOD to 1,8v. Also I think reading the temperature and humidity once in 5-10 minutes is enough,and transmit if it changes. There is a thread of the forum about cr2032 temperature node.

      alexsh1A 1 Reply Last reply
      0
      • TigroenotT Offline
        TigroenotT Offline
        Tigroenot
        wrote on last edited by
        #3

        Here it is. link

        Hope it will help.

        1 Reply Last reply
        0
        • TigroenotT Tigroenot

          @meddie As far as I'm concerned you should use the sleep() function. Also it's a good idea to use internal oscillator down to 1mhz and set the BOD to 1,8v. Also I think reading the temperature and humidity once in 5-10 minutes is enough,and transmit if it changes. There is a thread of the forum about cr2032 temperature node.

          alexsh1A Offline
          alexsh1A Offline
          alexsh1
          wrote on last edited by
          #4

          @Tigroenot BOD is increasing the sleep consumption. I am not using any BOD for the battery nodes.

          1 Reply Last reply
          0
          • rozpruwaczR Offline
            rozpruwaczR Offline
            rozpruwacz
            wrote on last edited by
            #5

            I throw my 2 cents, because I am now also designing some battery powered nodes and have some thoughts.
            First of all, You have to minimize power consumption during sleep, for cr2032 batteries it should be around 10uA or less. To do that all the peripheral devices must be also in sleep mode (the radio sleep is handled by the MySensors sleep function). Check also for any passive components (pull-up resistors {CPU internal pull-ups also} that are held to the ground for a long time , LEDs), those will drain Your battery fast.
            The next step is to implement the proper algorithm for sending the data. On the one side you want to send as little as possible (so send only when the value changes more that x%) but on the other side You want the reliable transmission that is resistant to packet loses. One way to implement that is to just send always at the given interval, but that will contradict the fist requirement. So I would suggest to use ack'ing, that way You know when You really need to resend the data. But this is not all, You can't just resend every time immediately when you do not get ack from the GW - that would drain your battery very fast if the GW would be out of reach for an hour or more. So You need to resend smart. I do this by increasing sleep time after every consecutive send failure, so after first failure i sleep for 1s, then if retransmission fails, i sleep for 2s, if next also fails sleep for 4s, then 8s, then 16s and so on up to 1 or 2 hours.
            I have some code to handle this resending algorith, so If You are interested I could put it on github.

            D TigroenotT 2 Replies Last reply
            1
            • rozpruwaczR rozpruwacz

              I throw my 2 cents, because I am now also designing some battery powered nodes and have some thoughts.
              First of all, You have to minimize power consumption during sleep, for cr2032 batteries it should be around 10uA or less. To do that all the peripheral devices must be also in sleep mode (the radio sleep is handled by the MySensors sleep function). Check also for any passive components (pull-up resistors {CPU internal pull-ups also} that are held to the ground for a long time , LEDs), those will drain Your battery fast.
              The next step is to implement the proper algorithm for sending the data. On the one side you want to send as little as possible (so send only when the value changes more that x%) but on the other side You want the reliable transmission that is resistant to packet loses. One way to implement that is to just send always at the given interval, but that will contradict the fist requirement. So I would suggest to use ack'ing, that way You know when You really need to resend the data. But this is not all, You can't just resend every time immediately when you do not get ack from the GW - that would drain your battery very fast if the GW would be out of reach for an hour or more. So You need to resend smart. I do this by increasing sleep time after every consecutive send failure, so after first failure i sleep for 1s, then if retransmission fails, i sleep for 2s, if next also fails sleep for 4s, then 8s, then 16s and so on up to 1 or 2 hours.
              I have some code to handle this resending algorith, so If You are interested I could put it on github.

              D Offline
              D Offline
              dakipro
              wrote on last edited by
              #6

              @rozpruwacz I am very interested in handling the ack, I think it is not that well documented feature, great if you can share your take on it

              C: OpenHAB2 with node-red on linux laptop
              GW: Arduino Nano - W5100 Ethernet, Nrf24l01+ 2,4Ghz mqtt
              GW: Arduino Mega, RFLink 433Mhz

              1 Reply Last reply
              0
              • rozpruwaczR rozpruwacz

                I throw my 2 cents, because I am now also designing some battery powered nodes and have some thoughts.
                First of all, You have to minimize power consumption during sleep, for cr2032 batteries it should be around 10uA or less. To do that all the peripheral devices must be also in sleep mode (the radio sleep is handled by the MySensors sleep function). Check also for any passive components (pull-up resistors {CPU internal pull-ups also} that are held to the ground for a long time , LEDs), those will drain Your battery fast.
                The next step is to implement the proper algorithm for sending the data. On the one side you want to send as little as possible (so send only when the value changes more that x%) but on the other side You want the reliable transmission that is resistant to packet loses. One way to implement that is to just send always at the given interval, but that will contradict the fist requirement. So I would suggest to use ack'ing, that way You know when You really need to resend the data. But this is not all, You can't just resend every time immediately when you do not get ack from the GW - that would drain your battery very fast if the GW would be out of reach for an hour or more. So You need to resend smart. I do this by increasing sleep time after every consecutive send failure, so after first failure i sleep for 1s, then if retransmission fails, i sleep for 2s, if next also fails sleep for 4s, then 8s, then 16s and so on up to 1 or 2 hours.
                I have some code to handle this resending algorith, so If You are interested I could put it on github.

                TigroenotT Offline
                TigroenotT Offline
                Tigroenot
                wrote on last edited by
                #7

                @rozpruwacz Sure, please share. It will all help a lot to see from the other perspective all the smart lifehucks and to finally get to desirable 3uA sleep consumption :)

                1 Reply Last reply
                0
                • rozpruwaczR Offline
                  rozpruwaczR Offline
                  rozpruwacz
                  wrote on last edited by rozpruwacz
                  #8

                  @Tigroenot said in Sensebender Micro Battery Code:

                  consumption

                  OK, i upload my code to github and share it with all, but I must warn that it is work in progress and it will change a lot and is not tested very well (just on my 3 different sensors).
                  @Tigroenot 3uA ? hehe :P my multimeter showed 4uA on 2000uA range (the lowest i have) for a door/window sensor (atmega + nrf24 + battery voltage divider + pull up resistor on one of the gpios + all powered with directly from cr2032 battery), but probably the measurement error is significant ...

                  TigroenotT 1 Reply Last reply
                  0
                  • rozpruwaczR rozpruwacz

                    @Tigroenot said in Sensebender Micro Battery Code:

                    consumption

                    OK, i upload my code to github and share it with all, but I must warn that it is work in progress and it will change a lot and is not tested very well (just on my 3 different sensors).
                    @Tigroenot 3uA ? hehe :P my multimeter showed 4uA on 2000uA range (the lowest i have) for a door/window sensor (atmega + nrf24 + battery voltage divider + pull up resistor on one of the gpios + all powered with directly from cr2032 battery), but probably the measurement error is significant ...

                    TigroenotT Offline
                    TigroenotT Offline
                    Tigroenot
                    wrote on last edited by
                    #9

                    @rozpruwacz said in Sensebender Micro Battery Code:

                    @Tigroenot said in Sensebender Micro Battery Code:

                    consumption

                    OK, i upload my code to github and share it with all, but I must warn that it is work in progress and it will change a lot and is not tested very well (just on my 3 different sensors).
                    @Tigroenot 3uA ? hehe :P my multimeter showed 4uA on 2000uA range (the lowest i have) for a door/window sensor (atmega + nrf24 + battery voltage divider + pull up resistor on one of the gpios + all powered with directly from cr2032 battery), but probably the measurement error is significant ...

                    No error, it's just a matter of faith :)

                    1 Reply Last reply
                    0
                    • rozpruwaczR Offline
                      rozpruwaczR Offline
                      rozpruwacz
                      wrote on last edited by
                      #10

                      The lib for handling sensors values (sending them to GW when needed and resending on filures) is here https://github.com/mczerski/MyMySensors and the example that uses it is here https://github.com/mczerski/DHTSensor. It probably have bugs :) so any suggestions will be appreciated.

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


                      24

                      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