Skip to content
  • 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. General Discussion
  3. Battery Level Measurement
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store

Battery Level Measurement

Scheduled Pinned Locked Moved General Discussion
arduinobattery
11 Posts 3 Posters 11.8k Views 1 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.
  • funky81F Offline
    funky81F Offline
    funky81
    wrote on last edited by
    #1

    Hi Guys,

    Need your advice for arduino battery level measurement.
    The goal is that I want to monitor my battery consumption so I can get notice for battery replacement if it's already low.
    This is my setup. is it correct already? I'm using this link as reference.

    check-battery.png

    Thanks

    m26872M 1 Reply Last reply
    0
    • tbowmoT Offline
      tbowmoT Offline
      tbowmo
      Admin
      wrote on last edited by
      #2

      Do you want to power it directly with battery connected to VCC of the atmega? Then it's possible to measure the battery voltage without any external components.

      http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/

      funky81F 1 Reply Last reply
      0
      • funky81F funky81

        Hi Guys,

        Need your advice for arduino battery level measurement.
        The goal is that I want to monitor my battery consumption so I can get notice for battery replacement if it's already low.
        This is my setup. is it correct already? I'm using this link as reference.

        check-battery.png

        Thanks

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

        @funky81 The wiring priciple is correct but you have to think of the components. Try six 1,5V cells in series, use R1=5Mohm (=two 10Mohm in parallell) and R2=680kohm and preferably a 0.1uF capacitor in parallell with R2. And some of the code below.
        One (major) drawback with the "secret external-component-less" method from @tbowmo is the Vcc becomes unregulated and it will be more difficult to use and interact with other things like sensors.

        /* BATTERY METER
          Internal_ref=1.1V, res=10bit=2^10-1=1023, 
          Some different 1.5V cell (I use AAs) configurations and some suggested corresponding resistor value relations:
          2AA: Vin/Vbat=470e3/(1e6+470e3), 3AA: Vin/Vbat=680e3/(2.5e6+680e3), 4AA: Vin/Vbat=1e6/(1e6+5e6), 5-6AA: Vin/Vbat=680e3/(5e6+680e3), 6-8AA: Vin/Vbat=1e6/(1e6+10e6)  
          Example with 6AAs and R1=5Mohm (=two 10Mohm in parallell) and R2=680kohm:
          Vlim = 1.1*Vbat/Vin = 9.188235 V (Set eventually to Vmax) 
                                  (9.2V = 1.53V/cell which is a little low for a fresh cell but let's say it's ok to stay at 100% for the first period of time)
          Volts per bit = Vlim/1023 = 0.008982
          Vmin = 6V (Min input voltage to regulator according to datasheet. Or guess Vout+1V )   DEFINE
          Vmax = 9.188235V (Known or desired voltage of full batteries. If not, set to Vlim.)  DEFINE
          Vpercent = 100*(Vbat-Vmin)/(Vmax-Vmin)
        */
          // some code
        #define VMIN 6.0 // (Min input voltage to regulator according to datasheet or guessing. (?) )
        #define VMAX 9.188235 // (Known or desired voltage of full batteries. If not, set to Vlim.)
          // some code
        int BATTERY_SENSE_PIN = A0;  // select the input pin for the battery sense point
        int oldBatteryPcnt = 0;
          // some code
          
        void setup() {
        
          analogReference(INTERNAL);    // use the 1.1 V internal reference for battery level measuring
        
          // some code
        
        }
        
        void loop() {
        
            // some code
            
          int sensorValue = analogRead(BATTERY_SENSE_PIN);    // Battery monitoring reading
        //  Serial.println(sensorValue);
          float Vbat  = sensorValue * 0.008982;
        //  Serial.print("Battery Voltage: "); Serial.print(Vbat); Serial.println(" V");
         //int batteryPcnt = sensorValue / 10;
          int batteryPcnt = static_cast<int>(((Vbat-VMIN)/(VMAX-VMIN))*100.);   
        //  Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %");
          if (oldBatteryPcnt != batteryPcnt) {
            gw.sendBatteryLevel(batteryPcnt);
            oldBatteryPcnt = batteryPcnt;
          }  
          
          // some code 
        
        }
        
        funky81F 1 Reply Last reply
        0
        • tbowmoT Offline
          tbowmoT Offline
          tbowmo
          Admin
          wrote on last edited by
          #4

          @m26872
          It highly depends on what sensors you want to use.

          If you want to go battery powered, you really should invest some time in finding the right sensors that can be used at low voltages.

          1 Reply Last reply
          0
          • m26872M Offline
            m26872M Offline
            m26872
            Hardware Contributor
            wrote on last edited by
            #5

            @tbowmo I agree.
            ... and something else than an Uno. Given that it actually is an Uno, I expect we're not really in to specialized sensors yet.
            And, sometimes opinions are not as helpful when we don't know the specification or application.

            1 Reply Last reply
            0
            • tbowmoT tbowmo

              Do you want to power it directly with battery connected to VCC of the atmega? Then it's possible to measure the battery voltage without any external components.

              http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/

              funky81F Offline
              funky81F Offline
              funky81
              wrote on last edited by
              #6

              @tbowmo right now, the battery will be connected only to vin, coz it raw.
              my step up power converter (in this link) havent arrived yet. So i will use vin only.

              if it stable enough I will connect battery => step up power converter => vcc
              then i will use the link that you provide before

              is my theory correct?

              m26872M 1 Reply Last reply
              0
              • m26872M m26872

                @funky81 The wiring priciple is correct but you have to think of the components. Try six 1,5V cells in series, use R1=5Mohm (=two 10Mohm in parallell) and R2=680kohm and preferably a 0.1uF capacitor in parallell with R2. And some of the code below.
                One (major) drawback with the "secret external-component-less" method from @tbowmo is the Vcc becomes unregulated and it will be more difficult to use and interact with other things like sensors.

                /* BATTERY METER
                  Internal_ref=1.1V, res=10bit=2^10-1=1023, 
                  Some different 1.5V cell (I use AAs) configurations and some suggested corresponding resistor value relations:
                  2AA: Vin/Vbat=470e3/(1e6+470e3), 3AA: Vin/Vbat=680e3/(2.5e6+680e3), 4AA: Vin/Vbat=1e6/(1e6+5e6), 5-6AA: Vin/Vbat=680e3/(5e6+680e3), 6-8AA: Vin/Vbat=1e6/(1e6+10e6)  
                  Example with 6AAs and R1=5Mohm (=two 10Mohm in parallell) and R2=680kohm:
                  Vlim = 1.1*Vbat/Vin = 9.188235 V (Set eventually to Vmax) 
                                          (9.2V = 1.53V/cell which is a little low for a fresh cell but let's say it's ok to stay at 100% for the first period of time)
                  Volts per bit = Vlim/1023 = 0.008982
                  Vmin = 6V (Min input voltage to regulator according to datasheet. Or guess Vout+1V )   DEFINE
                  Vmax = 9.188235V (Known or desired voltage of full batteries. If not, set to Vlim.)  DEFINE
                  Vpercent = 100*(Vbat-Vmin)/(Vmax-Vmin)
                */
                  // some code
                #define VMIN 6.0 // (Min input voltage to regulator according to datasheet or guessing. (?) )
                #define VMAX 9.188235 // (Known or desired voltage of full batteries. If not, set to Vlim.)
                  // some code
                int BATTERY_SENSE_PIN = A0;  // select the input pin for the battery sense point
                int oldBatteryPcnt = 0;
                  // some code
                  
                void setup() {
                
                  analogReference(INTERNAL);    // use the 1.1 V internal reference for battery level measuring
                
                  // some code
                
                }
                
                void loop() {
                
                    // some code
                    
                  int sensorValue = analogRead(BATTERY_SENSE_PIN);    // Battery monitoring reading
                //  Serial.println(sensorValue);
                  float Vbat  = sensorValue * 0.008982;
                //  Serial.print("Battery Voltage: "); Serial.print(Vbat); Serial.println(" V");
                 //int batteryPcnt = sensorValue / 10;
                  int batteryPcnt = static_cast<int>(((Vbat-VMIN)/(VMAX-VMIN))*100.);   
                //  Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %");
                  if (oldBatteryPcnt != batteryPcnt) {
                    gw.sendBatteryLevel(batteryPcnt);
                    oldBatteryPcnt = batteryPcnt;
                  }  
                  
                  // some code 
                
                }
                
                funky81F Offline
                funky81F Offline
                funky81
                wrote on last edited by
                #7

                @m26872 right now, i dont have any plans to use more than 2 batteries in series.
                but if i do, i will use step up power converter to stable it.

                but ofcourse this is my theory. am I correct ?

                1 Reply Last reply
                0
                • tbowmoT Offline
                  tbowmoT Offline
                  tbowmo
                  Admin
                  wrote on last edited by
                  #8

                  @funky81

                  If you use a step-up converter, then you need to use the design you made in first post.

                  My method can only be used if you don't have any voltage regulators etc. between the battery and the atmel chip (f.ex. something like http://forum.mysensors.org/topic/510/minimal-design-thoughts, which do not use any regulators, and the battery is connected directly to the atmel.

                  funky81F 1 Reply Last reply
                  0
                  • funky81F funky81

                    @tbowmo right now, the battery will be connected only to vin, coz it raw.
                    my step up power converter (in this link) havent arrived yet. So i will use vin only.

                    if it stable enough I will connect battery => step up power converter => vcc
                    then i will use the link that you provide before

                    is my theory correct?

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

                    @funky81 I'm confused. Are you trying to use a 3.3v step-up to an 5V Uno?
                    One or two 1.5V cells works great with a 3V-step-up setup like to power a 3V Arduino Pro Mini to Vcc as I do myself here BUT you can NOT supply a 5V-configuration.

                    funky81F 1 Reply Last reply
                    0
                    • m26872M m26872

                      @funky81 I'm confused. Are you trying to use a 3.3v step-up to an 5V Uno?
                      One or two 1.5V cells works great with a 3V-step-up setup like to power a 3V Arduino Pro Mini to Vcc as I do myself here BUT you can NOT supply a 5V-configuration.

                      funky81F Offline
                      funky81F Offline
                      funky81
                      wrote on last edited by
                      #10

                      @m26872 said:

                      I'm confused. Are you trying to use a 3.3v step-up to an 5V Uno?

                      I'm sorry to make you confused. Currently I'm using 3.3v arduino pro mini.
                      What I mean is not step up converter, but step up power converter (http://goo.gl/PFt99R) => to stablize 3.3v to maintain a steady 3.3 VDC even as the battery capacity diminishes. (like in this page http://www.mysensors.org/build/battery)

                      Hmm..after I read your post (http://forum.mysensors.org/topic/486/my-2aa-battery-sensor/4), it seems I have the same goal like you. I'll asked few thing in your thread, if that's okay with you :)

                      1 Reply Last reply
                      0
                      • tbowmoT tbowmo

                        @funky81

                        If you use a step-up converter, then you need to use the design you made in first post.

                        My method can only be used if you don't have any voltage regulators etc. between the battery and the atmel chip (f.ex. something like http://forum.mysensors.org/topic/510/minimal-design-thoughts, which do not use any regulators, and the battery is connected directly to the atmel.

                        funky81F Offline
                        funky81F Offline
                        funky81
                        wrote on last edited by funky81
                        #11

                        Hi @tbowmo, do you mind to explain a bit about the design? I'm interested with your design.

                        I will use these steps for removing voltage regulator, http://goo.gl/CsZaNg
                        So the design will be battery > external step up regulator (http://goo.gl/PFt99R - to stabilize 3.3v) > vcc pin ?

                        with these then I can use my first post design?

                        Thanks

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


                        6

                        Online

                        11.7k

                        Users

                        11.2k

                        Topics

                        113.0k

                        Posts


                        Copyright 2019 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
                        • OpenHardware.io
                        • Categories
                        • Recent
                        • Tags
                        • Popular