is there anyway to monitor battery level with os?

Post Reply
rivencole
Posts: 10
Joined: Mon Jun 22, 2015 9:56 pm
languages_spoken: english
ODROIDs: none yet.
Has thanked: 0
Been thanked: 0
Contact:

is there anyway to monitor battery level with os?

Unread post by rivencole » Wed Apr 10, 2019 1:53 am

first i apologize if this has already been asked/described but my search-fu has failed to come up with anything here. i have found a few threads on making batteries but none that have gotten the xu4 to monitor said battery. i assume it has to be possible since if i read it right the 3000mah backup battery for the odroids seem to have this function, correct me if i am wrong please.
anyway, is there anyway to use gpio to allow the xu4 to communicate with the BMS in a homebuilt battery? i plan to use a 1s config with a boost converter and a BMS that can handle enough cells to hopefully get several hours of usable 5v 3-5a output for an AR project. the goal of sbc and battery communication is to, obviously, let the os monitor the battery percentage remaining or at least the voltage remaining, which i can then at least guesstimate the remaining run time.

i am not exactly a complete noob with electronics (did some lcd tv repair and some circuit work before, including using farad caps from old tube tvs to make a gauss cannon. good times) but this is my first foray into making a battery, especially one that can talk to the board, and i could use a little guidance for when i am able to get an xu4 when they are back in stock at my preferred source.

sorry to be a plzbro, but i appreciate any knowledge or ideas anyone could impart on this
thanks in advance

User avatar
mad_ady
Posts: 5659
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 7 times
Been thanked: 13 times
Contact:

Re: is there anyway to monitor battery level with os?

Unread post by mad_ady » Wed Apr 10, 2019 2:35 am


rivencole
Posts: 10
Joined: Mon Jun 22, 2015 9:56 pm
languages_spoken: english
ODROIDs: none yet.
Has thanked: 0
Been thanked: 0
Contact:

Re: is there anyway to monitor battery level with os?

Unread post by rivencole » Wed Apr 10, 2019 4:21 am

thank you! how in the blue blazes of h*ll did i miss that? much easier than what i was thinking of doing too.
sorry to bother with such a dumb question.
now heres another one: got an idea on how to make it autoswitch from battery to wall power or back without shutting down or getting detrimental voltage spikes or drops? like plugging in and unplugging a laptop? i suppose i could devise a battery that can handle simultaneous charge/discharge but that is a last resort option since in my experience that is not good for the battery in most instances.
this new question might be a stretch, though i found a few circuits that CAN do it if using different voltages on the wired power vs the battery. i need it to prefer wall power when both are present, to allow battery to charge when the xu4 is still in operation. best i can find to this effect is to use schottky diodes and have both sources supply power since they will have effectively the same voltage.
i just never worked with batteries in this manner, kinda new territory for me.

User avatar
mad_ady
Posts: 5659
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 7 times
Been thanked: 13 times
Contact:

Re: is there anyway to monitor battery level with os?

Unread post by mad_ady » Wed Apr 10, 2019 2:16 pm

I can't give you any hardware advice - maybe @phaseshifter can, but the xu4 has an 1.8v ADC GPIO that you can use for measurements with a suitable voltage divider.

rivencole
Posts: 10
Joined: Mon Jun 22, 2015 9:56 pm
languages_spoken: english
ODROIDs: none yet.
Has thanked: 0
Been thanked: 0
Contact:

Re: is there anyway to monitor battery level with os?

Unread post by rivencole » Wed Apr 10, 2019 9:55 pm

thanks. i do appreciate the info you already gave... hopefully i can work this out before i start the project. planning is a great way to prevent issues

bk_XU_AZ
Posts: 245
Joined: Sun Sep 08, 2013 3:51 pm
languages_spoken: english
ODROIDs: XU3, U3, XU4, C1+
Has thanked: 0
Been thanked: 0
Contact:

Re: is there anyway to monitor battery level with os?

Unread post by bk_XU_AZ » Sun Apr 14, 2019 3:04 pm

Unfortunately, LiIon (and similar Li- based batts) have a nonlinear discharge voltage, such that by the time the voltage drops significantly, they are almost dead. So just using an A/D to monitor voltage won't get you there. TI and others make battery gauge ICs that are much better, They monitor the I and V over time and use some pretty involved calcs to estimate remaining battery capacity. The have to be "programmed" initially and then calibrated with occasional discharges to within about 20% of remaining capacity. There might be software out there to do this with and ARM SOC (but it would have to be modified to work with this specific SOC).

joerg
Posts: 864
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Has thanked: 0
Been thanked: 4 times
Contact:

Re: is there anyway to monitor battery level with os?

Unread post by joerg » Sun Apr 14, 2019 5:25 pm

rivencole wrote:
Wed Apr 10, 2019 4:21 am
i need it to prefer wall power when both are present, to allow battery to charge when the xu4 is still in operation. best i can find to this effect is to use schottky diodes and have both sources supply power since they will have effectively the same voltage.
i just never worked with batteries in this manner, kinda new territory for me.
This is my own well proofed design for my car pc with a C2.
A basic overview:
ups circuit.png
ups circuit.png (10.14 KiB) Viewed 108 times
With breakout boards TP4056 charger and Adafruit PowerBoost as step up converter.
You see the D1 and D2 Shottky diodes. If 5V input is present, the current path is always over D1 and the LiPo could be charged by the TP4056. I know that this is not the best approach for theLiPo lifetime, but for my experience I had to replace one time a LiPo cell after about 3 years of use.
And here is a discrete variant where I have designed an interface board for my Car PC, to have it all more compact:
Bildschirmfoto vom 2019-04-14 09-08-38.png
Bildschirmfoto vom 2019-04-14 09-08-38.png (52.38 KiB) Viewed 108 times
The input 'Enable' is controlled by a gpio with my Shutdown app. It need also the diodes D21 and D22 that let the circuit Q21, Q22 and Q23 be supplied if the 5V input is missing.
This is only an example how it could be. I think it would need some adaption to use it on a XU Odroid due to different gpio voltage level and higher power consumption.

Krishna579
Posts: 1
Joined: Wed Apr 17, 2019 7:30 pm
languages_spoken: english
ODROIDs: ODROID-HC1
Has thanked: 0
Been thanked: 0
Contact:

Re: is there anyway to monitor battery level with os?

Unread post by Krishna579 » Wed Apr 17, 2019 7:45 pm

I was struggling with same issue,thanks for the help.

Post Reply

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 4 guests