On-Screen Battery Monitor Options

General GBZ-related chat goes here. Share ideas, tips and tricks, or ask questions that don't fit into the hardware/software help forums.
Post Reply
joeygbsn
Posts: 50
Joined: Sun Nov 06, 2016 11:07 pm
Has thanked: 6 times
Been thanked: 15 times

Re: On-Screen Battery Monitor Options

Post by joeygbsn » Wed Nov 22, 2017 9:24 pm

Hey I finally got a little time to try hoolyhoos script with my ads1115 board and it works. I just have it hooked up to my test breadboard so I'm not monitoring a battery. Just hooked up the A0 input on the adc to a potentiometer. I can turn the wheel and make the battery icon change. I had to change a lot of values around in the script because of the different voltage range though.
20171122_211903~01.jpg
20171122_211903~01.jpg (1.42 MiB) Viewed 8419 times
20171122_220743.jpg
20171122_220743.jpg (2.5 MiB) Viewed 8419 times

User avatar
VeteranGamer
Posts: 1738
Joined: Thu Jan 26, 2017 11:12 am
Location: London, UK
Has thanked: 528 times
Been thanked: 909 times

Re: On-Screen Battery Monitor Options

Post by VeteranGamer » Wed Nov 22, 2017 11:49 pm

joeygbsn wrote:
Wed Nov 22, 2017 9:24 pm
Hey I finally got a little time to try hoolyhoos script with my ads1115 board and it works. I just have it hooked up to my test breadboard so I'm not monitoring a battery. Just hooked up the A0 input on the adc to a potentiometer. I can turn the wheel and make the battery icon change. I had to change a lot of values around in the script because of the different voltage range though.
20171122_211903~01.jpg
20171122_220743.jpg
can you show what changes you made to the script.....


.

joeygbsn
Posts: 50
Joined: Sun Nov 06, 2016 11:07 pm
Has thanked: 6 times
Been thanked: 15 times

Re: On-Screen Battery Monitor Options

Post by joeygbsn » Thu Nov 23, 2017 9:01 am

VeteranGamer wrote:
Wed Nov 22, 2017 11:49 pm
can you show what changes you made to the script.....
Hey sorry I'm using an older version of the adafruit library so i needed to change some of the commands to get it to work. I need to start with a fresh image I think because I couldn't get it to run the newer examples. I also had to change all the volts25, volts50, etc to make the bar change between 0 and 3.3v because all i had was a pot hooked up. I will post the code later though but I really don't think you will have too much trouble getting it to work. Setting debug = 1 in the battery monitoring script prints the value of the adc to the command line. If you do this you should probably edit /etc/rc.local and comment out the line that runs the mintystart script at boot otherwise its annoying having the values pop up every time you want to enter a command. Just try the two changes we talked about before and see if the values printed make sense. I will hopefully have time to start fresh and try to get the original code working soon though.

codeman0624
Posts: 109
Joined: Wed Nov 23, 2016 10:19 am
Has thanked: 3 times
Been thanked: 74 times

Re: On-Screen Battery Monitor Options

Post by codeman0624 » Thu Nov 23, 2017 10:14 am

VeteranGamer wrote:
Wed Nov 22, 2017 7:59 am

for me personally im not looking for great accuracy, as long as there is a rough gauge of whats left that will work for me
.
It will give you a very rough gauge of the remaining battery capacity. But just keep in mind that when your measurement says it's at 50% capacity, it could actually be anywhere from ~35% to ~75% for actual capacity, and then your measurement is going to drop of very fast toward the bottom end! The voltage graphs give a lot of information about how it will behave. Just keep it in mind when you're measuring battery capacity this way.

kite wrote:
Wed Nov 22, 2017 11:52 am
Haha :) still kinda annoyed about those chips as on paper that would be perfect, easy to design and put on a board but the legit part (which is quite hard to find IN China, so would mean expensive shipping + import from US in the first place).. it's a shame but like i think was posted here on on discoord (e.g. this http://www.ti.com/product/BQ27621-G1/samplebuy) would be really good but it's BGA which is a little less friendly :)
That's too bad! These parts have been working great for me. I've been using the max17048 for a while. On my latest boards I got the max17040 assembled on the boards from china, and they seem to be working fine. From the datasheets it looks like for performance the 17040 is equivalent to the 17043, but the 43 has a battery alert output.

User avatar
kite
Posts: 972
Joined: Thu May 12, 2016 4:30 am
Location: UK
Has thanked: 246 times
Been thanked: 361 times
Contact:

Re: On-Screen Battery Monitor Options

Post by kite » Thu Nov 23, 2017 11:26 am

codeman0624 wrote:
Thu Nov 23, 2017 10:14 am
VeteranGamer wrote:
Wed Nov 22, 2017 7:59 am

for me personally im not looking for great accuracy, as long as there is a rough gauge of whats left that will work for me
.
It will give you a very rough gauge of the remaining battery capacity. But just keep in mind that when your measurement says it's at 50% capacity, it could actually be anywhere from ~35% to ~75% for actual capacity, and then your measurement is going to drop of very fast toward the bottom end! The voltage graphs give a lot of information about how it will behave. Just keep it in mind when you're measuring battery capacity this way.

kite wrote:
Wed Nov 22, 2017 11:52 am
Haha :) still kinda annoyed about those chips as on paper that would be perfect, easy to design and put on a board but the legit part (which is quite hard to find IN China, so would mean expensive shipping + import from US in the first place).. it's a shame but like i think was posted here on on discoord (e.g. this http://www.ti.com/product/BQ27621-G1/samplebuy) would be really good but it's BGA which is a little less friendly :)
That's too bad! These parts have been working great for me. I've been using the max17048 for a while. On my latest boards I got the max17040 assembled on the boards from china, and they seem to be working fine. From the datasheets it looks like for performance the 17040 is equivalent to the 17043, but the 43 has a battery alert output.
Do you use a dev board for that chip? Do you have a link to one?
Stock clearance - CLOSED: viewtopic.php?f=38&t=12064
Kite's Mailing List: https://goo.gl/forms/e97uUvPOfUxPWdz82
Kite's FAQ: https://kiteretro.com/faq/


ImageImageImageImageImage

codeman0624
Posts: 109
Joined: Wed Nov 23, 2016 10:19 am
Has thanked: 3 times
Been thanked: 74 times

Re: On-Screen Battery Monitor Options

Post by codeman0624 » Thu Nov 23, 2017 2:54 pm

kite wrote:
Thu Nov 23, 2017 11:26 am
Do you use a dev board for that chip? Do you have a link to one?
No I just designed it directly into my board. But the sparkfun board could be useful for development.

datasheet:
https://datasheets.maximintegrated.com/ ... X17041.pdf

on mouser:
https://www.mouser.com/ProductDetail/Ma ... Oks15HnB1L

User avatar
YaYa
Posts: 1719
Joined: Mon Jun 26, 2017 12:42 pm
Location: brittany - France
Has thanked: 871 times
Been thanked: 689 times
Contact:

Re: On-Screen Battery Monitor Options

Post by YaYa » Thu Nov 23, 2017 3:18 pm

How much amp can the sparkefun board sustain ? I need something able to get around 7A in his face without crying lol
Follow me on instagram Image

codeman0624
Posts: 109
Joined: Wed Nov 23, 2016 10:19 am
Has thanked: 3 times
Been thanked: 74 times

Re: On-Screen Battery Monitor Options

Post by codeman0624 » Thu Nov 23, 2017 3:28 pm

YaYa wrote:
Thu Nov 23, 2017 3:18 pm
How much amp can the sparkefun board sustain ? I need something able to get around 7A in his face without crying lol
Probably not 7A through the small traces they have on that board...but the nice thing about these maxim battery monitors is they don't actually go in the current path, so they don't care how much current you're drawing from the battery

salami738
Posts: 128
Joined: Sat Sep 09, 2017 6:06 am
Location: Germany
Has thanked: 60 times
Been thanked: 37 times

Re: On-Screen Battery Monitor Options

Post by salami738 » Fri Nov 24, 2017 5:54 am

VeteranGamer wrote:
Mon Nov 13, 2017 12:52 am
erik_gee wrote:
Sun Nov 12, 2017 2:33 am
You could probably get away with any basic ADC or even just a voltage comparator if you aren't worried too much about resolution.

With the ADC you can get continuos input of data and read it over i2c, and either write your own code or try to modify one of the existing scripts to trigger battery icon changes at certain values. Or use the voltage comparator as I've stated before, in conjunction with some voltage dividers to compare the voltage output of the battery with a reference voltage (I think 3.2v is when it's too low? Atleast That's what I've read, haven't tested). The downside here being these are hard wired values, where the ADC is continuos input. Either way make sure to bring down the voltages to an acceptable 3.3v or lower power voltage so you don't fry your pi gpio
ok....

so what are you say here....
the ADC that HoolyHoo recommended/suggested isnt a good option and cant be used out of the box....

and if so what are your recommendations instead (12Bit or 16Bit) please provide something that we can work with....

.
Hi, i like to share some experience/knowledge on adc's in general.
A resolution of an adc in bits is the smallest amount of voltage difference, the adc can detect.
To make it a little bit simplier, i excluded things like adc accurancy, temperature dependencies and so on.

Examples for 5V ADC reference voltage:
8 Bit ADC: 8 Bit = 256 Steps -> 5V / 256 steps = Resolution: 0,01953125 V. ADC(0) = 0V, ADC(1) = 0,01953V, ADC(2) = 0,0391V, ... , ADC(255) = 5V
10 Bit ADC: 10 Bit = 1024 Steps -> 5V / 1024 steps = Resolution: 0,0048828125 V. ADC(0)= 0V, ADC(1) = 0,0049V, ..., ADC(1023) = 5V

I think any adc with a resolution >= 8 Bit would be ok for liion battery monitoring.

If you want to perfectly measure the remaining battery capacity in percent, you have to
measure voltage and current flow, because the voltage of a battery under load is lower than without load.
See the attached graph for more details (from lygte-info.dk, a battery review specialist):

Image

A pragmatic way to measure the capacity would be to measure your average current flow with a multimeter,
and use the correct line from the graph for your battery overlay.

Maybe i missed something, but why do you want to use a separate ADC, if you can use
an arduino leonardo for controls and battery monitoring? It has a 10 Bit ADC build in,
i use it in my build and it works perfectly.

User avatar
HoolyHoo
Posts: 766
Joined: Sat Jul 09, 2016 9:34 pm
Has thanked: 206 times
Been thanked: 741 times

Re: On-Screen Battery Monitor Options

Post by HoolyHoo » Fri Nov 24, 2017 6:17 am

Maybe i missed something, but why do you want to use a separate ADC, if you can use
an arduino leonardo for controls and battery monitoring? It has a 10 Bit ADC build in,
i use it in my build and it works perfectly.
Well probably because not everyone uses an arduino with their build. Some prefer to go bare bones GPIO for their controls. As the saying goes, there is more than one way of skinning a cat. This thread is just about another option. 😉

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest