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. Battery power (cr2032) on 2.0?

Battery power (cr2032) on 2.0?

Scheduled Pinned Locked Moved Hardware
batterycr2032
12 Posts 5 Posters 4.0k Views 3 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.
  • CrankyCoderC CrankyCoder

    Having no end of problems getting a sensor to run on a cr2032 with 2.0. Anyone get this working? Would you mind sharing your setup?

    m26872M Offline
    m26872M Offline
    m26872
    Hardware Contributor
    wrote on last edited by
    #2

    @Jason-Brunk So, it is working with <2.0 ?

    1 Reply Last reply
    0
    • CrankyCoderC Offline
      CrankyCoderC Offline
      CrankyCoder
      wrote on last edited by
      #3

      well, i am fairly new and came in right before the 2.0 release. But i have seen other projects that worked with the cr2032 in older mysensors versions.

      Home Automation Tinkerer
      www.CrankyCoder.net

      Controller: HomeAssistant in Kubernetes
      Gateway: MQTTClientGateway
      MySensors: 2.3

      1 Reply Last reply
      0
      • Nca78N Offline
        Nca78N Offline
        Nca78
        Hardware Contributor
        wrote on last edited by Nca78
        #4

        Hello,
        I have door/window sensors working with CR2032 cells with good results.
        Problem with those batteries is they can only provide a very low current, they have a relatively high internal resistance, so the more current you draw from them, the more energy you waste through this internal resistance, and the more the voltage drops. You need to use a few tricks to compensate, and then it's all fine.

        I do the following things to have good results and from what I see until now, good battery life:

        • use pro mini 3.3V / 8 MHz, put 1MHz bootloader so you can set BOD at 1.8V. No regulator/step up or anything similar, it would kill the battery.
        • put a 200uF capacitor in parallel with your battery. If you have a temp/humidity sensor sending with long intervals you could be fine with 100uF but it's not the case if I open/close a few times my door/windows.
        • never have 2 data sending actions without a sleep in the middle. I use a 250ms sleep between sending in the presentation() method, and 100ms in the code (when I send battery level after status, it's not all the time)
        • use branded cells and not the cheap chinese stuff from aliexpress/ebay, there is really a difference !
        YveauxY CrankyCoderC 2 Replies Last reply
        2
        • Nca78N Nca78

          Hello,
          I have door/window sensors working with CR2032 cells with good results.
          Problem with those batteries is they can only provide a very low current, they have a relatively high internal resistance, so the more current you draw from them, the more energy you waste through this internal resistance, and the more the voltage drops. You need to use a few tricks to compensate, and then it's all fine.

          I do the following things to have good results and from what I see until now, good battery life:

          • use pro mini 3.3V / 8 MHz, put 1MHz bootloader so you can set BOD at 1.8V. No regulator/step up or anything similar, it would kill the battery.
          • put a 200uF capacitor in parallel with your battery. If you have a temp/humidity sensor sending with long intervals you could be fine with 100uF but it's not the case if I open/close a few times my door/windows.
          • never have 2 data sending actions without a sleep in the middle. I use a 250ms sleep between sending in the presentation() method, and 100ms in the code (when I send battery level after status, it's not all the time)
          • use branded cells and not the cheap chinese stuff from aliexpress/ebay, there is really a difference !
          YveauxY Offline
          YveauxY Offline
          Yveaux
          Mod
          wrote on last edited by
          #5

          @Nca78 said:

          never have 2 data sending actions without a sleep in the middle

          There's no way to guarantee this without modifying the library...

          http://yveaux.blogspot.nl

          Nca78N 1 Reply Last reply
          0
          • YveauxY Yveaux

            @Nca78 said:

            never have 2 data sending actions without a sleep in the middle

            There's no way to guarantee this without modifying the library...

            Nca78N Offline
            Nca78N Offline
            Nca78
            Hardware Contributor
            wrote on last edited by
            #6

            @Yveaux said:

            @Nca78 said:

            never have 2 data sending actions without a sleep in the middle

            There's no way to guarantee this without modifying the library...

            Yes I'm talking about the "user" sketch. The 200uF capacitor can keep up with the sendings from the library from what I have seen so far. Only the sketch startup is problematic that's why I put longer pauses, including one before the presentation messages.

            1 Reply Last reply
            0
            • Nca78N Nca78

              Hello,
              I have door/window sensors working with CR2032 cells with good results.
              Problem with those batteries is they can only provide a very low current, they have a relatively high internal resistance, so the more current you draw from them, the more energy you waste through this internal resistance, and the more the voltage drops. You need to use a few tricks to compensate, and then it's all fine.

              I do the following things to have good results and from what I see until now, good battery life:

              • use pro mini 3.3V / 8 MHz, put 1MHz bootloader so you can set BOD at 1.8V. No regulator/step up or anything similar, it would kill the battery.
              • put a 200uF capacitor in parallel with your battery. If you have a temp/humidity sensor sending with long intervals you could be fine with 100uF but it's not the case if I open/close a few times my door/windows.
              • never have 2 data sending actions without a sleep in the middle. I use a 250ms sleep between sending in the presentation() method, and 100ms in the code (when I send battery level after status, it's not all the time)
              • use branded cells and not the cheap chinese stuff from aliexpress/ebay, there is really a difference !
              CrankyCoderC Offline
              CrankyCoderC Offline
              CrankyCoder
              wrote on last edited by
              #7

              @Nca78

              great feed back :) couple of follow up questions :).

              1. i am using a 3.3v 8mhz. I put a 1mhz boot loader on it and set my BOD. - This seems to have helped ALOT on my node. Question, my wake up out of sleep doesn't seem to be working (timing issue?) and my serial communications do not work. Is there something I have to do to tell the mysensors sketch I am running at 1mhz to keep the timing correct?
              2. I have not put a 200uF on mine yet. I have a 100uf on this node and it's just 2 buttons to send on/off and the battery level. So I may not need more than 100uf
              3. This is something I had not touched yet, and will definitely add those pauses on boot up. This might help some more!!
              4. I have energizers no cheapy ali express batteries for me :)

              BIG thanks here!!

              Home Automation Tinkerer
              www.CrankyCoder.net

              Controller: HomeAssistant in Kubernetes
              Gateway: MQTTClientGateway
              MySensors: 2.3

              Nca78N m26872M 2 Replies Last reply
              0
              • CrankyCoderC CrankyCoder

                @Nca78

                great feed back :) couple of follow up questions :).

                1. i am using a 3.3v 8mhz. I put a 1mhz boot loader on it and set my BOD. - This seems to have helped ALOT on my node. Question, my wake up out of sleep doesn't seem to be working (timing issue?) and my serial communications do not work. Is there something I have to do to tell the mysensors sketch I am running at 1mhz to keep the timing correct?
                2. I have not put a 200uF on mine yet. I have a 100uf on this node and it's just 2 buttons to send on/off and the battery level. So I may not need more than 100uf
                3. This is something I had not touched yet, and will definitely add those pauses on boot up. This might help some more!!
                4. I have energizers no cheapy ali express batteries for me :)

                BIG thanks here!!

                Nca78N Offline
                Nca78N Offline
                Nca78
                Hardware Contributor
                wrote on last edited by
                #8

                @Jason-Brunk

                1. Serial communication must be at 9600 bauds max if you are at 1MHz with internal clock. There is a define you can set in your sketch to fix it :
                #define MY_BAUD_RATE 9600
                

                I don't know for the waking up, I didn't notice any problem until now. Do you use the default sleep function from MySensors to set this duration ? Maybe post your sketch, it could help ;)
                2) I think it's better to put 200 instead of 100 in your case, you can just add another 100 in parallel. If you click on-off on-off in a relatively short time, with the addition of sending battery level your voltage will probably start to drop. Put voltage measurement+sending just after sending the on/off value, you will know if it's fine or not.

                CrankyCoderC 1 Reply Last reply
                1
                • Nca78N Nca78

                  @Jason-Brunk

                  1. Serial communication must be at 9600 bauds max if you are at 1MHz with internal clock. There is a define you can set in your sketch to fix it :
                  #define MY_BAUD_RATE 9600
                  

                  I don't know for the waking up, I didn't notice any problem until now. Do you use the default sleep function from MySensors to set this duration ? Maybe post your sketch, it could help ;)
                  2) I think it's better to put 200 instead of 100 in your case, you can just add another 100 in parallel. If you click on-off on-off in a relatively short time, with the addition of sending battery level your voltage will probably start to drop. Put voltage measurement+sending just after sending the on/off value, you will know if it's fine or not.

                  CrankyCoderC Offline
                  CrankyCoderC Offline
                  CrankyCoder
                  wrote on last edited by
                  #9

                  @Nca78 ok, I added that baud rate to mine just like that. Still can't see the serial :/

                  Below is my sketch.

                  Thanks!

                  #define SKETCH_NAME "WallSwitch"
                  #define SKETCH_MAJOR_VER "1"
                  #define SKETCH_MINOR_VER "1"
                  // Enable debug prints to serial monitor
                  #define MY_DEBUG 
                  #define MY_NODE_ID 1
                  // Enable and select radio type attached
                  #define MY_RADIO_NRF24
                  #define MY_BAUD_RATE 9600
                  
                  #include <SPI.h>
                  #include <MySensors.h>
                  
                  
                  int BATTERY_SENSE_PIN = A0;  // select the input pin for the battery sense point
                  int oldBatteryPcnt = 0;
                  
                  #define CHILD_LIGHT_ID 1
                  
                  #define ON_PIN 3  
                  #define OFF_PIN 2  
                  int OFF_VAL = 0;
                  int ON_VAL = 0;
                  
                  // Change to V_LIGHT if you use S_LIGHT in presentation below
                  MyMessage msg_light(CHILD_LIGHT_ID,V_LIGHT);
                  
                  
                  void setup()  
                  {  
                    // Setup the buttons
                    
                    pinMode(ON_PIN,INPUT);
                    pinMode(OFF_PIN,INPUT);
                  
                    digitalWrite(ON_PIN,HIGH);  
                    digitalWrite(OFF_PIN,HIGH);  
                    
                   #if defined(__AVR_ATmega2560__)
                     analogReference(INTERNAL1V1);
                  #else
                     analogReference(INTERNAL);
                  #endif
                  
                    
                  }
                  
                  void presentation() {
                    
                    sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER);
                    present(CHILD_LIGHT_ID, S_LIGHT);  
                   
                   CheckBattery();
                   }
                  
                  
                  //  Check if digital input has changed and send in new value
                  void loop() 
                  {
                  int whichbutton = 0;
                  whichbutton = sleep(digitalPinToInterrupt(2),LOW,digitalPinToInterrupt(3),LOW,3600000);//86400000);
                  
                  switch (whichbutton) {
                    case digitalPinToInterrupt(2):
                        {//off
                        send(msg_light.set(0),true);
                        wait(300);
                        break;
                        }
                    case digitalPinToInterrupt(3):
                        {//on
                        send(msg_light.set(1),true);
                        wait(300);
                        break;
                        }
                      
                    } 
                  
                  CheckBattery();
                  
                  }
                  
                  
                  void CheckBattery()
                  {
                      // battery stuff
                     // get the battery Voltage
                     int sensorValue = analogRead(BATTERY_SENSE_PIN);
                     #ifdef MY_DEBUG
                     Serial.println(sensorValue);
                     #endif
                     
                     // 1M, 470K divider across battery and using internal ADC ref of 1.1V
                     // Sense point is bypassed with 0.1 uF cap to reduce noise at that point
                     // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts
                     // 3.44/1023 = Volts per bit = 0.003363075
                     
                     int batteryPcnt = sensorValue / 10;
                  
                     #ifdef MY_DEBUG
                     float batteryV  = sensorValue * 0.0029325513196481;
                     Serial.print("Battery Voltage: ");
                     Serial.print(batteryV);
                     Serial.println(" V");
                  
                     Serial.print("Battery percent: ");
                     Serial.print(batteryPcnt);
                     Serial.println(" %");
                     #endif
                  
                     if (oldBatteryPcnt != batteryPcnt) {
                       // Power up radio after sleep
                       sendBatteryLevel(batteryPcnt);
                       oldBatteryPcnt = batteryPcnt;
                     }
                  
                  
                  
                  
                  }
                  

                  Home Automation Tinkerer
                  www.CrankyCoder.net

                  Controller: HomeAssistant in Kubernetes
                  Gateway: MQTTClientGateway
                  MySensors: 2.3

                  1 Reply Last reply
                  0
                  • CrankyCoderC CrankyCoder

                    @Nca78

                    great feed back :) couple of follow up questions :).

                    1. i am using a 3.3v 8mhz. I put a 1mhz boot loader on it and set my BOD. - This seems to have helped ALOT on my node. Question, my wake up out of sleep doesn't seem to be working (timing issue?) and my serial communications do not work. Is there something I have to do to tell the mysensors sketch I am running at 1mhz to keep the timing correct?
                    2. I have not put a 200uF on mine yet. I have a 100uf on this node and it's just 2 buttons to send on/off and the battery level. So I may not need more than 100uf
                    3. This is something I had not touched yet, and will definitely add those pauses on boot up. This might help some more!!
                    4. I have energizers no cheapy ali express batteries for me :)

                    BIG thanks here!!

                    m26872M Offline
                    m26872M Offline
                    m26872
                    Hardware Contributor
                    wrote on last edited by
                    #10

                    @Jason-Brunk Also remember to have the cap on battery side if you're starting with some kind of power on.

                    1 Reply Last reply
                    0
                    • CrankyCoderC Offline
                      CrankyCoderC Offline
                      CrankyCoder
                      wrote on last edited by
                      #11

                      So in my case 2 caps. 1 at the main power rail between battery and controller and then 1 on the radio. Any recommendations on the values?

                      Home Automation Tinkerer
                      www.CrankyCoder.net

                      Controller: HomeAssistant in Kubernetes
                      Gateway: MQTTClientGateway
                      MySensors: 2.3

                      1 Reply Last reply
                      0
                      • scalzS Offline
                        scalzS Offline
                        scalz
                        Hardware Contributor
                        wrote on last edited by scalz
                        #12

                        You can put 100uf on each ;) even 200uf would not be able to handle only one tx, so..
                        but you need them at least for coin cells.

                        you would need more capa to handle tx..but the more capa the more time they take for recharging, and the recharging if big, increase internal res of the coin cell and that's not so good too; to prevent this that would need a current resistor limiter..etc a whole balance!
                        On mine for instance, I have 100uF for coincell, 100uF for PIR and 86uf on radio. Fresh varta coincell 3.02V, after multiple presentation tx 2.85V if I remember, not so bad. but that's an homemade pcb.

                        Another notes, it's better to use ceramic capacitor (because of leakage, if you want to optimize), and better smd, but that's not your case I think.

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


                        19

                        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