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.
User avatar
erik_gee
Posts: 356
Joined: Thu Jun 16, 2016 12:57 am
Location: United States
Has thanked: 137 times
Been thanked: 193 times

Re: On-Screen Battery Monitor Options

Post by erik_gee » 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
GBC AIO kit Sales Thread:https://www.sudomod.com/forum/viewtopic.php?f=38&t=9928

Bunch of different shoulder button kits Sales Thread:viewtopic.php?f=38&t=6233&p=63192#p63192

AIO board for DMG Sales Thread:
viewtopic.php?f=38&t=6431

6 Button Common Ground Board Sales Thread: viewtopic.php?f=38&t=4811

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 » 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....

.

User avatar
erik_gee
Posts: 356
Joined: Thu Jun 16, 2016 12:57 am
Location: United States
Has thanked: 137 times
Been thanked: 193 times

Re: On-Screen Battery Monitor Options

Post by erik_gee » Mon Nov 13, 2017 1:40 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....

.
Oh I didn't say it wasn't a good option. I think what he suggested should work just fine, as well as any other ADC. I just offered another option, the voltage comparator, for those who don't want to work with i2c as it can be a little more complicated. The voltage comparator would just output a high when it reaches predetermined voltages, set by using voltage dividers. So if you are looking for an easier coding experience, the comparator is much simpler as you don't have to worry about i2c communication . But you won't be able to fine tune it as you are working with the voltages you set, where the ADC is constantly reading the voltage and you can adjust at what voltage you want a certain action to happen much easier.

But either resolution should be fine for your ADC when determining how many bits. I'm not quite as experienced with monitoring via ADC, so perhaps someone else here can she'd a little more light. I know there has been quite a bit of discussion using the mcp3008 ADC and that there is some code floating around for that. That might be a good start since it's been developed on already
GBC AIO kit Sales Thread:https://www.sudomod.com/forum/viewtopic.php?f=38&t=9928

Bunch of different shoulder button kits Sales Thread:viewtopic.php?f=38&t=6233&p=63192#p63192

AIO board for DMG Sales Thread:
viewtopic.php?f=38&t=6431

6 Button Common Ground Board Sales Thread: viewtopic.php?f=38&t=4811

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 » Mon Nov 13, 2017 6:29 am

As I mentioned before, the link I posted earlier will work "out of the box". If your happy with the way the battery monitoring works on Wermy's minty image, then you will have the same experience.

That being said, if you want 16bit precision vs 12bit, then use this:

https://www.ebay.com/itm/ADS1115-4-Chan ... SwzgRW1510

Same board, just uses a 16bit chip instead of the 12bit. Only slight modification to the code would be needed. :)

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 » Mon Nov 13, 2017 7:14 am

HoolyHoo wrote:
Mon Nov 13, 2017 6:29 am
As I mentioned before, the link I posted earlier will work "out of the box". If your happy with the way the battery monitoring works on Wermy's minty image, then you will have the same experience.

That being said, if you want 16bit precision vs 12bit, then use this:

https://www.ebay.com/itm/ADS1115-4-Chan ... SwzgRW1510

Same board, just uses a 16bit chip instead of the 12bit. Only slight modification to the code would be needed. :)
For me it's just having a rough idea of what your left with (battery capacity) rather than suddenly being presented with a low battery message....
Plus it looks good on a build...

As long as their aren't any major issues with the mintyPi setup and people are happy with the way it performs, the 12bit ads1015 should be fine...

I've have ordered both, but would rather not get into too many script changes (it's a bit out of my wheelhouse)....


.

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 » Mon Nov 13, 2017 8:54 am

I have one of the 16bit boards so may be able to test the script at some point if I have time. Looking at the code though I think that you only need to change one line. Change adc = Adafruit_ADS1x15.ADS1015() to adc = Adafruit_ADS1x15.ADS1115() and I think it will work.

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 » Mon Nov 13, 2017 9:05 am

joeygbsn wrote:
Mon Nov 13, 2017 8:54 am
I have one of the 16bit boards so may be able to test the script at some point if I have time. Looking at the code though I think that you only need to change one line. Change adc = Adafruit_ADS1x15.ADS1015() to adc = Adafruit_ADS1x15.ADS1115() and I think it will work.
I'm not sure if it's that simple (could be wrong)

Because you get a higher resolution with 16bit, maybe some of the parameters need to be adjusted (could be wrong)

But if you've got it, there's no harm in testing it out...


.

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 » Mon Nov 13, 2017 9:07 am

joeygbsn wrote:
Mon Nov 13, 2017 8:54 am
I have one of the 16bit boards so may be able to test the script at some point if I have time. Looking at the code though I think that you only need to change one line. Change adc = Adafruit_ADS1x15.ADS1015() to adc = Adafruit_ADS1x15.ADS1115() and I think it will work.
You would also need to change the resolution as of right now the range is from -2048 to 2047. The 16bit uses a resolution from -32768 to 32767.

Editing the 2047 to 32767 in this bit of the script might be all thats needed other than the what joeygbsn mentioned.

Code: Select all

def convertVoltage(sensorValue):
    voltage = float(sensorValue) * (4.09 / 2047.0)
    return voltage

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 » Mon Nov 13, 2017 9:17 am

HoolyHoo wrote:
Mon Nov 13, 2017 9:07 am
joeygbsn wrote:
Mon Nov 13, 2017 8:54 am
I have one of the 16bit boards so may be able to test the script at some point if I have time. Looking at the code though I think that you only need to change one line. Change adc = Adafruit_ADS1x15.ADS1015() to adc = Adafruit_ADS1x15.ADS1115() and I think it will work.
You would also need to change the resolution as of right now the range is from -2048 to 2047. The 16bit uses a resolution from -32768 to 32767.

Editing the 2047 to 32767 in this bit of the script might be all thats needed other than the what joeygbsn mentioned.

Code: Select all

def convertVoltage(sensorValue):
    voltage = float(sensorValue) * (4.09 / 2047.0)
    return voltage
Ok awesome yeah i was just about to post that bit and see if that was the only other change, but you edited your post and confirmed.

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 » Sun Nov 19, 2017 9:42 am

Sticking here... i must confess that it’s harder to understand than i thought.

I’m really new to the whole stuff.
Follow me on instagram Image

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest