You ever wanted to monitor the charging of your Nexus 5 from the commandline? Here is how it works.

The Nexus 5 uses two chips to control the charging:

While the first chip controls the maximum current which is drawn from the USB, the second chip monitors the current charging current.

Both chips can be read over their I2C interface:

$ ls -al /sys/bus/i2c/drivers/max17048
total 0
drwxr-xr-x  2 root root    0 2018-06-27 21:03 .
drwxr-xr-x 17 root root    0 2018-06-27 20:58 ..
lrwxrwxrwx  1 root root    0 2018-06-27 21:03 84-0036 -> ../../../../devices/f9923000.i2c/i2c-84/84-0036
--w-------  1 root root 4096 2018-06-27 21:03 bind
--w-------  1 root root 4096 2018-06-27 21:03 uevent
--w-------  1 root root 4096 2018-06-27 21:03 unbind

$ ls -al /sys/bus/i2c/drivers/bq24192/
total 0
drwxr-xr-x  2 root root    0 2018-06-27 20:58 .
drwxr-xr-x 17 root root    0 2018-06-27 20:58 ..
lrwxrwxrwx  1 root root    0 2018-06-27 20:58 84-006b -> ../../../../devices/f9923000.i2c/i2c-84/84-006b
--w-------  1 root root 4096 2018-06-27 20:58 bind
--w-------  1 root root 4096 2018-06-27 20:58 uevent
--w-------  1 root root 4096 2018-06-27 20:58 unbind

To get the current current, you can do the following:

$ cat /sys/bus/i2c/drivers/max17048/84-0036/power_supply/battery/uevent
POWER_SUPPLY_NAME=battery
POWER_SUPPLY_STATUS=Discharging
POWER_SUPPLY_HEALTH=Good
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_VOLTAGE_MAX_DESIGN=4350000
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=3200000
POWER_SUPPLY_VOLTAGE_NOW=3825000
POWER_SUPPLY_TEMP=290
POWER_SUPPLY_CAPACITY=55
POWER_SUPPLY_CURRENT_NOW=-303005
POWER_SUPPLY_CHARGE_FULL_DESIGN=2300

or while charging:

$ cat /sys/bus/i2c/drivers/max17048/84-0036/power_supply/battery/uevent
POWER_SUPPLY_NAME=battery
POWER_SUPPLY_STATUS=Charging
POWER_SUPPLY_HEALTH=Good
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_VOLTAGE_MAX_DESIGN=4350000
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=3200000
POWER_SUPPLY_VOLTAGE_NOW=4005000
POWER_SUPPLY_TEMP=285
POWER_SUPPLY_CAPACITY=55
POWER_SUPPLY_CURRENT_NOW=1009776
POWER_SUPPLY_CHARGE_FULL_DESIGN=2300