Get battery information.

npm install node-battery
12 downloads in the last week
18 downloads in the last month

Node.js Battery Module

This module provides information on linux and osx about the power sources.


Node-battery provides two methods:

var nodeBattery = require("node-battery");


    // Linux only
    // "data" Is an array containing paths to the battery files


    // "data" Is an array containing a percentage of power left for each battery.


    // "data" Is an array containing a 0 or a 1 depending on wheter the battery is being charged.

On Linux this module works by reading out the BAT* files in '/sys/class/power_supply'.

If no batteries are detected this could be caused by the fact that your BAT* files start with BAT0 instead of BAT1, to fix this just pass in a 0 as the second argument.

npm loves you