Page 1 of 2

Battery monitoring help

Posted: Tue Sep 24, 2019 9:39 am
by matt2mi
Hi sudomoders,

I'm building a Game boy Pi 3A+, and I'm coming in to the power part.
I bought this Bllutech 5000mAh battery: https://bllutech.com/collections/frontp ... po-battery
and this tinkerboy powerswitch: https://www.tinkerboy.xyz/setup-and-wir ... werswitch/

I now ask for battery monitoring help. I wanted a retroPSU but helder told me that he doesnt ship to France anymore...
So my problem is that i saw many solution to monitor the battery level ! And i'm scared about finishing it without, at least, the system shutting down safely the gameboy with alert message if the battery power is too low.

I assume there is 2 important things here, the auto shutdown system and the battery icon on the top of the screen.

I think it's not possible with only the tinkerboy switch (it's not written in the doc..), so what are the options knowing that the best for me is obviously an icon appearing on the screen (the Helder'way https://heldergametech.com/shop/gameboy-zero/retropsu/) and the auto shutdown displaying an alert message.

I found that we can achieve it with a Leonardo Micro (here viewtopic.php?f=44&t=3537&start=20 and here viewtopic.php?f=44&t=7830&p=73108&hilit ... ing#p73108)
but i plugged my controlls with GPIO so is this board overkill if i just use it for battery monitoring ?

I read another example with an ADS1x15 (here: https://github.com/sixteenbit/Mintybatt ... Monitor.py)

I just dont know what to choose for my build and how to do it (what to plug where ?)

If someone can help, i would apreciate :)

And sorry for my english if i'm not clear, just tell me ! You know, french people...

Re: Battery monitoring help

Posted: Tue Sep 24, 2019 11:48 am
by infinitLoop
first off - you do not need helder's PSU if you already have Tinkerboy's PSU/switch. you would want one or the other, not both. Tinkerboy's includes a "safe shutdown" (a way to trigger software shutdown before cutting the power), Helder's doesn't. But, you are correct, Tinkerboy's switch does not have the battery monitor built into it (Helder's does).

Or, in other words...
Tinkerboy's => power + recharge + safe shutdown
Helder's RetroPSU => power + recharge + battery monitor + analog controls

Tinkerboy integrated his battery monitor into his v3 board, with his pro micro controller: https://www.tinkerboy.xyz/battery-monit ... roller-v3/

So, if you didn't use that board, you can still get an ADS-1015, and use the Minty script you link to, to do the battery monitoring, in the same way the RetroPSU does. you hook it up by wiring the A0 to the battery positive, the ground to the battery ground, SDA to GPIO 2, SCL to GPIO 3, and the VIN to 5v somewhere.

Typically, I think you'd also want to include an in-line 10k resistor at the battery positive, but tinkerboy's switch might already have that built-in (you should ask)

Re: Battery monitoring help

Posted: Wed Sep 25, 2019 1:20 am
by matt2mi
First of all, thanks a lot for your answer, it is really clear and it makes me more confident to do as you said.

When you talk about Vin you mean the VDD port on the ads1015, right ?

Last, in terms of schematic, i'm not sure of the order of these boards, do I have to put the tinkerboy board first and then the ADS, or the two in parallel ?

What do you think about this schematic ?
SpoilerShow
Image
Thanks again for your time !!

Re: Battery monitoring help

Posted: Wed Sep 25, 2019 6:07 am
by infinitLoop
matt2mi wrote:
Wed Sep 25, 2019 1:20 am
First of all, thanks a lot for your answer, it is really clear and it makes me more confident to do as you said.

When you talk about Vin you mean the VDD port on the ads1015, right ?

Last, in terms of schematic, i'm not sure of the order of these boards, do I have to put the tinkerboy board first and then the ADS, or the two in parallel ?

What do you think about this schematic ?
SpoilerShow
Image
Thanks again for your time !!
Yes, on VIN / VDD -- that is your positive voltage input.

And yes - The battery voltage in parallel, like in your schematic.

The SDA and SCL should go to the BCM 2 and 3 pins, see here: https://pinout.xyz/ (they are labelled on there with SCA and SCL too - the pins just under the 3v3 pin at the top of the picture)

The "S" and "P" pins on the switch are for "Shutdown" and "Power-Off". Those go to GPIO pins that will need to be configured using Tinkerboy's guide to 1) Trigger the software Shutdown and then 2) Keep the power active until that is complete, then Power-Off at the end. Those can go to just about any unused GPIO pin (that isn't a Ground or 3v3 or 5v)... with one caveat - The "P" / Power-Off one should be configured with a GPIO greater than 8. The GPIO pins 0-7 start High, and the rest start Low, so if you pick one that is in the 0-7 range, it might not work when it gets to the point of turning the power off. In his guide, it looks like Tinkerboy uses 10 and 11 for those, which is fine. If you use others, you just need to adjust the pins in the /boot/config.txt file for those dtoverlays.

The others look OK, I think, but you will need to bring the 5v over to the Pi from the switch.

Re: Battery monitoring help

Posted: Thu Sep 26, 2019 12:49 am
by matt2mi
Thanks again for these precisions about the High and Low GPIO pins, i didn't know that point !
The others look OK, I think, but you will need to bring the 5v over to the Pi from the switch.
Yes, you're right, i forget that point on my schematic :? !

Thanks again, that cristal clear, let's go !! :D

Re: Battery monitoring help

Posted: Thu Sep 26, 2019 6:53 am
by infinitLoop
Good luck! :) (bon chance! ;) - that’s almost all the French I remember from school) and make sure to show us how it turns out! :)

Re: Battery monitoring help

Posted: Thu Sep 26, 2019 7:08 pm
by tinkerBOY
infinitLoop wrote:
Tue Sep 24, 2019 11:48 am
first off - you do not need helder's PSU if you already have Tinkerboy's PSU/switch. you would want one or the other, not both. Tinkerboy's includes a "safe shutdown" (a way to trigger software shutdown before cutting the power), Helder's doesn't. But, you are correct, Tinkerboy's switch does not have the battery monitor built into it (Helder's does).

Or, in other words...
Tinkerboy's => power + recharge + safe shutdown
Helder's RetroPSU => power + recharge + battery monitor + analog controls

Tinkerboy integrated his battery monitor into his v3 board, with his pro micro controller: https://www.tinkerboy.xyz/battery-monit ... roller-v3/

So, if you didn't use that board, you can still get an ADS-1015, and use the Minty script you link to, to do the battery monitoring, in the same way the RetroPSU does. you hook it up by wiring the A0 to the battery positive, the ground to the battery ground, SDA to GPIO 2, SCL to GPIO 3, and the VIN to 5v somewhere.

Typically, I think you'd also want to include an in-line 10k resistor at the battery positive, but tinkerboy's switch might already have that built-in (you should ask)
The PowerSwitch does not include any battery monitoring circuitry because I already have that on the v3. I might include it in future version.

Re: Battery monitoring help

Posted: Fri Sep 27, 2019 12:31 am
by matt2mi
Good luck! :) (bon chance! ;) - that’s almost all the French I remember from school) and make sure to show us how it turns out! :)
:lol: Merci !! (thank you ;) ) And yes i took pictures during the development to create a post when i finish it.
The PowerSwitch does not include any battery monitoring circuitry because I already have that on the v3. I might include it in future version.
Yes, i know, sadly tinkerBOY, I had already bought some PCB and stuff before I found your website with all your nice components, that's why I'm in this situation...
So you agree with infinitLoop to include an in-line 10k resistor at the battery positive ??

Re: Battery monitoring help

Posted: Fri Sep 27, 2019 7:42 am
by tinkerBOY
matt2mi wrote:
Fri Sep 27, 2019 12:31 am
Good luck! :) (bon chance! ;) - that’s almost all the French I remember from school) and make sure to show us how it turns out! :)
:lol: Merci !! (thank you ;) ) And yes i took pictures during the development to create a post when i finish it.
The PowerSwitch does not include any battery monitoring circuitry because I already have that on the v3. I might include it in future version.
Yes, i know, sadly tinkerBOY, I had already bought some PCB and stuff before I found your website with all your nice components, that's why I'm in this situation...
So you agree with infinitLoop to include an in-line 10k resistor at the battery positive ??
Yes for the 10k resistor but im not sure if it's needed with the ADS.

Re: Battery monitoring help

Posted: Sun Sep 29, 2019 3:15 am
by matt2mi
Ok, thanks, I'll investigate a bit, and I keep this in mind !

Thank you all for your time :)