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 » Fri Dec 01, 2017 4:34 pm

Hey just wanted to let you know that I finally had a chance to reinstall hoolyhoo's script and use it with the ads1115. I can confirm that the only changes needed are changing line 24 to adc = Adafruit_ADS1x15.ADS1115() and changing line 55 to voltage = float(sensorValue) * (4.09 / 32767.0). At first i thought the range wasnt right because i was getting readings of ~2.6V but when I double checked with my meter the voltage actually was 2.6v on the 3.3v rail from the raspberry pi. I was powering my BW screen off of the 5V rail and it was causing a lot of voltage drop. It's drawing 350mA. I switched it to a separate 5V supply and my readings went up to 3.3V along with all my voltages.

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 Dec 11, 2017 6:48 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
Noob question.....

i've got a couple ADS1015 and a couple of ADS1115 in hand now......
i know the ADS1015 (if wire correctly) only needs the script installed and is good to go....


i want to try the ADS1115

after i wire it up and install the script

how do i go about editing the script, so thats it more geared towards the 16bit chip....

a complete noob in this department, so as much info as possible would be appreciated.....

Thanks.


.

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 Dec 11, 2017 7:17 am

VeteranGamer wrote:
Mon Dec 11, 2017 6:48 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
Noob question.....

i've got a couple ADS1015 and a couple of ADS1115 in hand now......
i know the ADS1015 (if wire correctly) only needs the script installed and is good to go....


i want to try the ADS1115

after i wire it up and install the script

how do i go about editing the script, so thats it more geared towards the 16bit chip....

a complete noob in this department, so as much info as possible would be appreciated.....

Thanks.


.
If you installed the original script to your pi then you could just ssh and edit using nano (ex. sudo nano pathoffile/file). Then it’s just a matter of changing the values mentioned above and then saving the file. Keep in mind that with python, indents matter so make sure those stay as is. Simply then, reboot, and hopefully it should work for you.

joao
Posts: 36
Joined: Fri Jun 02, 2017 6:49 am
Been thanked: 18 times

Re: On-Screen Battery Monitor Options

Post by joao » Mon Dec 11, 2017 9:37 am

Hi HoolyHoo, if I use the same ADS1015 for battery monitor (channel 2) and joystick (channel 0 and 1). Using both your script (changing the readVoltage() function to read channel 2) and the Joy Bonnet from Adafruit, the system starts giving me wrong values and due to this I get a shutdown even with full battery.
Do you have any ideas how can I solve this?

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 Dec 11, 2017 9:58 am

joao wrote:
Mon Dec 11, 2017 9:37 am
Hi HoolyHoo, if I use the same ADS1015 for battery monitor (channel 2) and joystick (channel 0 and 1). Using both your script (changing the readVoltage() function to read channel 2) and the Joy Bonnet from Adafruit, the system starts giving me wrong values and due to this I get a shutdown even with full battery.
Do you have any ideas how can I solve this?
I suspect there may be a conflict as they are both accessing the ADS1015. I used Adafruit's library for the chip which made it easy to read while the joy bonnet script accesses the ADS1015 in script without library. I would try to merge the script so that its all in one either using the library or as in the joy bonnet script.

joao
Posts: 36
Joined: Fri Jun 02, 2017 6:49 am
Been thanked: 18 times

Re: On-Screen Battery Monitor Options

Post by joao » Mon Dec 11, 2017 3:39 pm

Thank you. That was also my idea. Now I just need to see if I can do it :D
And thanks for sharing the script.

Lpoolm
Posts: 392
Joined: Thu Jun 09, 2016 4:17 am
Location: uk
Has thanked: 76 times
Been thanked: 51 times

Re: On-Screen Battery Monitor Options

Post by Lpoolm » Thu Dec 14, 2017 11:23 am

has this been mentioned/used?
https://fr.aliexpress.com/item/1S-Singl ... 0.0.ferk1G

i saw it on a french youtube build guide
20171214_182413.jpg
20171214_182413.jpg (6.21 MiB) Viewed 8049 times
Check out my modding and repair channel of retro and modern consoles:
https://www.youtube.com/channel/UCFz7yW ... GtQ/videos

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 » Thu Dec 14, 2017 11:41 am

Lpoolm wrote:
Thu Dec 14, 2017 11:23 am
has this been mentioned/used?
https://fr.aliexpress.com/item/1S-Singl ... 0.0.ferk1G

i saw it on a french youtube build guide
20171214_182413.jpg
not really on-screen....

i have seen those....
and i've seen them in some builds (dont look great, IMHO)
and i think they're impractical, you have to turn the system around to see what you've got left....
and you have to accommodate another bit of hardware.....

but its an option if people want there builds to look like that.....


.

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 Jan 11, 2018 11:57 am

Continuing the conversation from the other thread...
While it my not be an ideal situation, it seems like just powering the module from 5v without removing any pull-ups should work fine. The raspberry has 1.8k ohm pull-up resistors to 3v3 on the sda and scl lines on board. The module has 10k pull-ups to 5v on the same sda and scl lines. So the actual circuit for one of the lines is something like this:
IIC.PNG
IIC.PNG (10.11 KiB) Viewed 7820 times
I used 5.11v because that's what i measured with my DVM. Simulating this we get around 3.58v on the data line:
Graph.PNG
Graph.PNG (26.83 KiB) Viewed 7820 times
I have verified this with my DVM I'm seeing 3.58v. Seeing as its not very high above the 3.3v rating of the pi's pins it seems like it wont hurt anything. This does work perfectly so far on my breadboard.

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 » Thu Jan 11, 2018 12:27 pm

joeygbsn wrote:
Thu Jan 11, 2018 11:57 am
Continuing the conversation from the other thread...
While it my not be an ideal situation, it seems like just powering the module from 5v without removing any pull-ups should work fine. The raspberry has 1.8k ohm pull-up resistors to 3v3 on the sda and scl lines on board. The module has 10k pull-ups to 5v on the same sda and scl lines. So the actual circuit for one of the lines is something like this:
IIC.PNG

I used 5.11v because that's what i measured with my DVM. Simulating this we get around 3.58v on the data line:
Graph.PNG

I have verified this with my DVM I'm seeing 3.58v. Seeing as its not very high above the 3.3v rating of the pi's pins it seems like it wont hurt anything. This does work perfectly so far on my breadboard.
Thanks for the info! I'm making a control board rright now with an ads1115/1015 circuit integrated. I placed a 1n4001 diode in series with the 5v vdd to (theoretically) drop down to around ~~ 4.3v . So that the output is below the 3.3v required of the pi. If there is a flaw in my logic please let me know haha
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

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest