Battery stats in Ubuntu
#1
I have the battery pack for the Pine, and my goal was to use it sort of like a battery backup for a server. What I'm wondering is if there is a way in Ubuntu to pull any stats on the battery. Mostly I'd like to track the charge percentage if possible just for monitoring purposes. I know it's not connected like an actual UPS, so I assume it can't be managed the same way. Does anybody know if this is possible?
  Reply
#2
The PMIC for the A64 supports reading out the battery stats, I just dont know if the Linux kernel driver exposes that information to userspace already... /sys/class/power_supply/battery on my Ubuntu running on the pine has all the necessary entries:

Code:
ubuntu@pine64:/sys/class/power_supply/battery$ ls -l
total 0
-r--r--r-- 1 root root 4096 Jun 16 18:51 capacity
-r--r--r-- 1 root root 4096 Jun 16 18:51 current_now
lrwxrwxrwx 1 root root    0 Jun 16 18:51 device -> ../../../axp81x-supplyer.47
-r--r--r-- 1 root root 4096 Jun 16 18:51 energy_full_design
-r--r--r-- 1 root root 4096 Jun 16 18:51 health
-r--r--r-- 1 root root 4096 Jun 16 18:51 model_name
-r--r--r-- 1 root root 4096 Jun 16 18:51 online
drwxr-xr-x 2 root root    0 Jun 16 18:51 power
-r--r--r-- 1 root root 4096 Jun 16 17:30 present
-r--r--r-- 1 root root 4096 Jun 16 18:51 status
lrwxrwxrwx 1 root root    0 Jun 16 18:51 subsystem -> ../../../../../../class/power_supply
-r--r--r-- 1 root root 4096 Jun 16 18:51 technology
-r--r--r-- 1 root root 4096 Jun 16 18:51 temp
-r--r--r-- 1 root root 4096 Jun 16 18:51 type
-rw-r--r-- 1 root root 4096 Jun 16 18:51 uevent
-r--r--r-- 1 root root 4096 Jun 16 18:51 voltage_max_design
-r--r--r-- 1 root root 4096 Jun 16 18:51 voltage_min_design
-r--r--r-- 1 root root 4096 Jun 16 18:51 voltage_now
ubuntu@pine64:/sys/class/power_supply/battery$

I dont have a battery attached to test if the files contain actual values....
Come have a chat in the Pine IRC channel >>
  Reply
#3
Thanks for the pointer. It looks like there are actual values there:

Code:
/sys/class/power_supply/battery/capacity: 98
/sys/class/power_supply/battery/current_now: 416000
/sys/class/power_supply/battery/energy_full_design: 4800
/sys/class/power_supply/battery/health: Good
/sys/class/power_supply/battery/model_name: battery
/sys/class/power_supply/battery/online: 0
/sys/class/power_supply/battery/present: 1
/sys/class/power_supply/battery/status: Charging
/sys/class/power_supply/battery/technology: LiFe
/sys/class/power_supply/battery/temp: 290
/sys/class/power_supply/battery/type: Battery
/sys/class/power_supply/battery/uevent: POWER_SUPPLY_NAME=battery
POWER_SUPPLY_MODEL_NAME=battery
POWER_SUPPLY_STATUS=Charging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_ONLINE=0
POWER_SUPPLY_HEALTH=Good
POWER_SUPPLY_TECHNOLOGY=LiFe
POWER_SUPPLY_VOLTAGE_MAX_DESIGN=4200000
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=3300
POWER_SUPPLY_VOLTAGE_NOW=4181000
POWER_SUPPLY_CURRENT_NOW=416000
POWER_SUPPLY_ENERGY_FULL_DESIGN=4800
POWER_SUPPLY_CAPACITY=98
POWER_SUPPLY_TEMP=290
/sys/class/power_supply/battery/voltage_max_design: 4200000
/sys/class/power_supply/battery/voltage_min_design: 3300
/sys/class/power_supply/battery/voltage_now: 4181000
  Reply
#4
Thats nice to see since I am about to order a battery for my Pine. The PMIC has some more features for battery charging and monitoring that can be / need to be configured... that's something that needs to be worked out I guess... it has a "Fuel Gauge" feature for example that needs to be calibrated (like the battery gauges in the smart batteries for laptops ...) and programmable charge current / cut off voltage....

Just FYI, you can also read out the system voltages (set values) from the PMIC from the sysfs:

Code:
ubuntu@pine64:~$ ./pmic_state
Regulator  1 (   axp81x_dcdc1) : vcc-nand vcc-emmc vcc-sdc vcc-usb-30 vcc-io vcc-pd :  enabled ( 2 users) = 3300 mV (min=   1600 mV, max=   3400 mV
Regulator  2 (   axp81x_dcdc2) :                                           vdd-cpua :  enabled ( 0 users) = 1040 mV (min=    500 mV, max=   1300 mV
Regulator  3 (   axp81x_dcdc3) :                                               none :  enabled ( 0 users) = 1100 mV (min=    500 mV, max=   1300 mV
Regulator  4 (   axp81x_dcdc4) :                                               none : disabled ( 0 users) = 1100 mV (min=    500 mV, max=   1300 mV
Regulator  5 (   axp81x_dcdc5) :                                           vcc-dram :  enabled ( 0 users) = 1500 mV (min=    800 mV, max=   1840 mV
Regulator  6 (   axp81x_dcdc6) :                                            vdd-sys :  enabled ( 0 users) = 1100 mV (min=    600 mV, max=   1520 mV
Regulator  7 (   axp81x_dcdc7) :                                               none : disabled ( 0 users) = 1000 mV (min=    600 mV, max=   1520 mV
Regulator  8 (     axp81x_rtc) :                                               none : disabled ( 0 users) = 3000 mV (min=   3000 mV, max=   3000 mV
Regulator  9 (   axp81x_aldo1) :                       vdd-csi-led iovdd-csi vcc-pe : disabled ( 0 users) = 2800 mV (min=    700 mV, max=   3300 mV
Regulator 10 (   axp81x_aldo2) :                                             vcc-pl :  enabled ( 0 users) = 1800 mV (min=    700 mV, max=   3300 mV
Regulator 11 (   axp81x_aldo3) :                                   vcc-avcc vcc-pll :  enabled ( 0 users) = 3000 mV (min=    700 mV, max=   3300 mV
Regulator 12 (   axp81x_dldo1) :                                        vcc-hdmi-33 :  enabled ( 1 users) = 3300 mV (min=    700 mV, max=   3300 mV
Regulator 13 (   axp81x_dldo2) :                                           vcc-mipi : disabled ( 0 users) = 3300 mV (min=    700 mV, max=   4200 mV
Regulator 14 (   axp81x_dldo3) :                                           avdd-csi : disabled ( 0 users) = 2800 mV (min=    700 mV, max=   3300 mV
Regulator 15 (   axp81x_dldo4) :                                       vcc-deviceio :  enabled ( 0 users) = 3300 mV (min=    700 mV, max=   3300 mV
Regulator 16 (   axp81x_eldo1) :                vcc-cpvdd vcc-wifi-io vcc-pc vcc-pg :  enabled ( 2 users) = 1800 mV (min=    700 mV, max=   1900 mV
Regulator 17 (   axp81x_eldo2) :                                          vcc-lcd-0 : disabled ( 0 users) = 1800 mV (min=    700 mV, max=   1900 mV
Regulator 18 (   axp81x_eldo3) :                                        dvdd-csi-18 : disabled ( 0 users) = 1800 mV (min=    700 mV, max=   1900 mV
Regulator 19 (   axp81x_fldo1) :                                        vcc-hsic-12 : disabled ( 0 users) = 1200 mV (min=    700 mV, max=   1450 mV
Regulator 20 (   axp81x_fldo2) :                                           vdd-cpus :  enabled ( 0 users) = 1100 mV (min=    700 mV, max=   1450 mV
Regulator 21 (axp81x_gpio0ldo) :                                            vcc-ctp : disabled ( 0 users) = 3100 mV (min=    700 mV, max=   3300 mV
Regulator 22 (axp81x_gpio1ldo) :                                               none : disabled ( 0 users) = 3300 mV (min=    700 mV, max=   3300 mV
Regulator 23 (   axp81x_dc1sw) :                                vcc-lvds vcc-dsi-33 :  enabled ( 1 users) = 1600 mV (min=      0 mV, max=      0 mV
ubuntu@pine64:~$
Come have a chat in the Pine IRC channel >>
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Ubuntu server 20.04 request phi0x 2 5,284 12-30-2020, 08:02 PM
Last Post: phi0x
  SPI on ubuntu IlyaM 4 9,084 07-16-2018, 03:00 AM
Last Post: kingflab
  Ubuntu password not working joemassimino 4 8,509 05-18-2018, 03:33 PM
Last Post: Luke
  After flashing Ubuntu- how to get graphical desktop Partymack711 6 10,828 02-01-2018, 09:45 AM
Last Post: Partymack711
  (ARCHIVED) Ubuntu Xenial Image (BSP Kernel) longsleep 337 633,680 01-31-2018, 11:58 AM
Last Post: Luke
  PPTP doesnt work with ubuntu escovedo 2 8,656 08-23-2017, 09:28 AM
Last Post: gilbertotcc
Question HELP Ubuntu Mate password recovery procedure Captain Anni Hilator 5 9,901 08-03-2017, 03:52 PM
Last Post: Luke
  Ubuntu boot very slow with wifi driver remainder 9 20,654 08-03-2017, 07:23 AM
Last Post: victorssantos
  Recovering root access in Ubuntu Scientomancer 3 5,827 07-28-2017, 02:53 PM
Last Post: Scientomancer
  Pine64 2Gb Ubuntu Mono not updating and stuck petec 0 2,873 07-08-2017, 09:34 AM
Last Post: petec

Forum Jump:


Users browsing this thread: 1 Guest(s)