Ubuntu上笔记本充一次电的电费计算

Ubuntu上笔记本充一次电的电费计算_第1张图片
1度电 = 1.5元
1度电的能量 = 1000瓦时
功率(瓦特W) = 电压(伏特V) * 电流(安培A)
12.5V,4.04A电池的能量 = 12.5V * 4.04A * 1h = 50.5瓦时
笔记本充一次电的电费: 50.5/1000*1.5=0.07575元 (1毛钱都不到)
<?php
$charge_full = file_get_contents('/sys/class/power_supply/BAT1/charge_full');
$voltage_now = file_get_contents('/sys/class/power_supply/BAT1/voltage_now');
$energy = $charge_full/1000000 * $voltage_now/1000000 * 1;
$energy_charge = $energy / 1000 * 1.5;
echo $energy_charge.'元';
充满电后,电池电量能够待机55小时.

高级配置和电源管理接口ACPI:
sudo apt-get install acpi
acpi -i 或者 acpi -V(查看全部信息)
Battery 0: Full, 100%
Battery 0: design capacity 4400 mAh, last full capacity 4363 mAh = 99%
直接访问Linux获取电池信息( 一切皆文件的思想就是伟大):
/sys/class/power_supply/BAT1/charge_full_design 设计电池容量(4400000,4.4Ah)
/sys/class/power_supply/BAT1/charge_full 实际电池容量(4040000)
/sys/class/power_supply/BAT1/charge_now 当前电池容量(4040000)
/sys/class/power_supply/BAT1/status 电池状态(比如充满Full)
/sys/class/power_supply/BAT1/voltage_min_design 设计最小电压(10800000,10.8V)
/sys/class/power_supply/BAT1/voltage_now 当前电压(12516000,12.5V)
/sys/class/power_supply/BAT1/manufacturer 制作商(LGC)

你可能感兴趣的:(Ubuntu上笔记本充一次电的电费计算)