element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Data Conversion
  • Challenges & Projects
  • Project14
  • Data Conversion
  • More
  • Cancel
Data Conversion
Blog The Unnecessarily Complex Battery Tester
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Data Conversion to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: ntewinkel
  • Date Created: 30 Jan 2021 7:06 AM Date Created
  • Views 2320 views
  • Likes 17 likes
  • Comments 7 comments
  • battery_tester
  • digital
  • dataconverch
  • arduino
  • analog
Related
Recommended

The Unnecessarily Complex Battery Tester

ntewinkel
ntewinkel
30 Jan 2021

This is the story of the sage of my vintage battery tester update into the digital world.

We take a good old fashioned, mostly unreliable and hard-to-use tester, and turn it into an equally difficult to use and equally unreliable micro controller powered tester!

 

So, in a nutshell, the finished project takes:

1) an analog value (battery voltage)

2) converts it into digital (Arduino analogRead)

3) thinks about it a bit and categorizes it into one of 5 output categories, and then

4) using PWM (Arduino analogWrite) outputs an analog value to the gauge, but...

5) Rather than using the full infinite range of the gauge in good ole analog fashion, it steps to 1 of 5 areas... kind of a digital thing to do.

 

So, short story made much too long... here are the details. And a cat picture for bonus points.

 

I recently found an old household battery tester while cleaning up, and it was terribly unreliable to use - the gauge doesn't always work, the contacts are sketchy at best. I was about to recycle it, but then I thought the gauge on it might be fun for a project so I tucked it away in a drawer.

 

When this Data Conversion challenge popped up, I immediately had an idea - maybe I could digitize the thing to make it more useful for my purpose: identify what a battery can be used for.

I've found that some tech items need nearly full batteries to operate well, and even wall clocks can be fussy. The one thing that's not fussy is the cheap little LED string lights - they can light up with nearly dead batteries, though not as bright.

 

I try not to leave batteries in my devices, because they tend to leak if left over time. So we end up with a pile of batteries that are often still near-new, mixed with nearly-dead well used old batteries.

 

So I often use my digital multimeter to check if:

a) the battery is still new: generally 1.55v or higher

b) the battery is slightly used but still quite good: 1.4v - 1.55v

c) the battery is kinda low, but will light LED strings brightly: 1.3v - 1.4v

d) the battery is still fine enough for LED string lights: 1.0v - 1.3v -> these I keep as a last resort for the LED lights

e) the battery is too empty for anything useful, and is ready for recycling: less than 1 volt. It's also at a higher risk of leaking at this point.

 

image

My stunt batteries randomly happened to all be of different brands, which does help keep them sorted out.

I tried the old battery tester, holding it carefully and having cleaned the contacts. The results are ok, but it really makes even the mostly-dead battery look like it's fine.

image

 

So this is where I think, with a little bit of technology, that I can do better!

spoiler alert: I can't image

 

So I took the tester apart to look inside - thankfully, old technology was built in a way that allows easy access = 2 little screws!

imageimage

And it looks like it has a few resistors making a voltage divider in there - note the extra resistors to also allow testing of a 9 volt battery.

So I clipped on some probes to see the range of values I could expect to see at the gauge itself. Turns out to be very low fraction of a volt values. the 0.18v above is for a new battery.

 

So to keep things easy I decided to add some wires to intercept the voltage to the gauge, and use it directly as input into a Digispark clone ATTiny85 micro controller, given the low voltages.

Using the full battery voltage might've given a more accurate reading within the controller, but I'm not going back in there now!

 

I carefully snipped the power side apart to get the new wires in between, but the ground was just an easy direct addition.

image

I was able to fit the little board directly behind the gauge, using a bit of tack to hold it in place. The USB power cord runs out a hole in the back.

image

 

Then I went to program the board, and... it wouldn't program it! argh!

After disconnecting everything, rebooting my computer, and trying a different board, I finally realized I was using a charge-only USB cable. sigh.

But problem solved, and onward we go.

 

The next issue was that I needed to fine tune the expected Analog-input input ranges to get the desired categories, as well as the desired Analog-out value to properly position the needle of the gauge.

 

I had some numbers written down, but was faced with some interference which slowed me down considerably:

image

 

Also of note, the Analog input for Digisparks is really screwy - the pin numbers are all over the place! make sure to read the docs on that:

https://digistump.com/wiki/digispark/tutorials/basics

Also, from another project I learned that the clones have P5 set to be a reset pin by default. That gets REALLY interesting when you try to use it as a button input image

For this project though, I only needed the one input and the one output, so I only used P0 and P2.

 

I tried just entering some values and adjusting them to be roughly correct and then tune it, but I was so far off that nothing really worked... so much for my attempt at math-ing it out.

Turns out the Digisparks are really limited and don't have the ability to debug with the usual serial console, so it's a bit tougher to work with in this kind of scenario.

 

So I grabbed a trusty ole Uno and used it, along with a variable-voltage power supply I received from element14 in a previous competition a few years ago (what a great tool to have!!), to test what all the voltage input ranges end up being in the world of the controller.

image

 

After getting some good values figured out, I then did the same to test the desired Analog Output values.

Here's a video of that in action, powered by a Uno:

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

And here is the finished project:

image

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Here is a video of the final product giving me a hard time and untrustworthy results image

You might notice I'm not getting the accuracy I had hoped for. While I was testing with the variable power supply the results were far more consistent, so I don't know why it would be different using the batteries themselves - it's possible the contacts are just not making a good enough connection, but I don't know for sure.

 

 

In summary... this was fun to do, and the results are more of a "useless-box" type gadget!

The battery tester now needs external USB power to run the micro controller.

It seems that the micro controller is not really all that accurate and reliable at reading the input voltages properly all the time, but it does actually get a fairly decent result.

 

So... it's a lot like the old tester was!! sort of sketchy and unreliable... terrible contacts... a gauge with a loose display card that jams the needle... hard to tell if the result can be trusted. Yup! just like vintage tech image

 

Best,

-Nico

 

Edit: I think the unreliable final results may be a factor of the varying input voltages (computer USB while testing vs USB charger to run it later) - the default uses the I/O voltage, or 5v in this case. I noticed there is an internal 1.1v reference on the ATTiny85 chip that would actually be perfect for the input range we get from the battery tester voltage divider:

  analogReference(INTERNAL1V1); 

 

The Arduino code is very simple. I've pasted it here:

 

/*
  Unnecessarily Complex Battery Tester


  Powered by an ATTiny85 (a Digispark clone), intercepts modified battery voltage, and outputs a more specific reading.


  Instead of the original fully analog battery tester,
    where the battery voltage is modified with a voltage divider to suit the analog gauge,
  the modified voltage is now read by the chip, and the chip outputs a specific level depending on the input value.


  The outputs, however, will point to specific levels:
  > 1.55 volts = New, and the needle points at the far right of the green section on the analog scale
  1.40 - 1.55 volts = Good, and the needle points to the middle of the green section
  1.30 - 1.40 volts = Meh, and points to the middle of the yellow section
  1.0 - 1.30 volts = Lame, and points to the middle of the red section
  < 1.0 is considered to be "no battery", or battery is terrible, and will keep the pointer to the far left.


  As such, we have:
  Analog input -> converted to digital number in chip -> converted to analog (PWM) output value for the gauge.
  However, the analog output value is set to specific levels... kind of digital.


  Using 2 pins:
  * P2 for the input voltage from the battery (after the existing voltage divider)
  * P0 for the output to the gauge
*/


/*
   NOTE: Digispark Analog-Read is wonky when it comes to pin numbering!!
   See https://digistump.com/wiki/digispark/tutorials/basics
    
    sensorValue = analogRead(1); //Read P2 -> for input, pin number DOES NOT MATCH the port number


    P0, P1, and P4 are capable of hardware PWM (analogWrite).
    pinMode(0, OUTPUT); //0 is P0 -> for output, pin number matches port number
  
 */
int sensorValue = 0;
int outputValue = 0;


void setup() {
  pinMode(0, OUTPUT); // to gauge
}


void loop() {
  // read the voltage-divider modified value from the battery:
  sensorValue = analogRead(1); //Read P2


  // output to the gauge:


  if (sensorValue > 272) { // > 1.55v = top green
    outputValue = 12;
  }
  else if (sensorValue > 246) {  // > 1.4 v = mid green
    outputValue = 10;
  }
  else if (sensorValue > 227) { // > 1.3 v = mid yellow
    outputValue = 6;
  }
  else if (sensorValue > 168) { // > 1.0 v = mid red
    outputValue = 3;
  }
  else {
    outputValue = 0;
  }


  analogWrite(0,outputValue);
  
  delay(500); // milliseconds
}

  • Sign in to reply

Top Comments

  • ajcc
    ajcc over 4 years ago +5
    A great and fun project! Those charge only USB-cables are a nuisance.
  • neilk
    neilk over 4 years ago +5
    Nico - a great project, with the story well told. Perhaps your cat didn't provide enough input? Neil
  • bigsexy
    bigsexy over 4 years ago +4
    Not a total loss. We now know the cat has a analog input!
  • electronicbiker
    electronicbiker over 4 years ago

    Here's what I do to test batteries and cells. It is all done using a Model 7 Avometer except the visual inspection.

     

    First I look around the terminals for any sign of leakage, corrosion, green powdery stuff, and white powdery stuff. If there is any, I dispose of the battery in a safe and responsible manner.

    Then I check the voltage using an analogue multi-meter set to the correct range. If it starts to droop after a few seconds I dispose of the battery etc etc. Even if the reading is steady, a too-high or too-low voltage is good reason to be suspicious.

    I also check the available current using an analogue multi-meter set to the correct range. If it is well below what I expect then I dispose of etc etc...  I don't recommend anybody to try this unless they know what they are doing as it can be very dangerous, and in any case never do it with high-power batteries such as lithium, silver, lead-acid, Ni-Cad, etc. Or anything big. Even something as small as a good AA cell can be harmful. You have been warned.

    The Avometer, with the famous cut-out that pops up on overload, is a marvellous device for testing batteries. The 10 amp AC range also makes it useful for testing the permanent-magnet alternators as fitted to vintage motor-cycles. Never be without an Avo! (Other ancient analogue multi-meters are still available)

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • bigsexy
    bigsexy over 4 years ago

    Not a total loss. We now know the cat has a analog input!

    • Cancel
    • Vote Up +4 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • joespez
    joespez over 4 years ago

    Awesome project dude, surely it will work really great with some more tinkering!

    I remember fiddling with one of these testers once and I remember a resistor in addition to the voltage divider resistors, which added a small load to the battery to get a more meaningful reading.
    But as you said the real problem lies in the contacts, I can’t believe those unreliable spring contacts are still with us   

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 4 years ago

    Nice mix of analog, digital, and back to analog technology.

     

    DAB

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dubbie
    dubbie over 4 years ago

    Nico,

     

    A nice concept. And, it looks like one of those things that should work but somehow, doesn't seem to.

     

    Dubbie

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube