npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

max17048

v1.0.1

Published

Communicate with the Maxim MAX17048 Battery Fuel Gauge IC, used on the Geekworm UPS HAT board for the Raspberry Pi

Readme

max17048

Communicate over the i2c bus with the Maxim MAX17048 battery fuel gauge circuit to get battery charge information. The MAX17048 integrated circuit (IC) is used on the Geekworm UPS HAT Board for the Raspberry Pi. This module is a thin wrapper around the IC's registers. See the data sheet for details about the meanings of the values retrieved.

Contents

Warning

LiPo batteries can catch fire and explode if handled improperly. Ensure that you know what you are doing, and I take no responsibility for damages caused by bugs in this code.

Installation

npm install max17048

Requirements

Requires the use of the async-i2c-bus module.

Usage

i2c = require('async-i2c-bus')
Max17048 = require('max17048');

async function printCellVoltage( max17048 )
{
  console.log( "Cell voltage: " + await max17048.getCellVoltage() + " V" );
}

async function main()
{
  const bus = i2c.Bus()

  await bus.open();

  var max17048 = new Max17048( bus )
  
  printCellVoltage( max17048 );
}

main()

API

max17048 = new Max17048( bus )

Pass an instance of Bus from the async-i2c-bus module. The returned object contains the API methods below:

async getCellVoltage()

Returns the cell voltage in volts.

async getStateOfCharge()

Returns a value between 0 and 1, representing the charge of the battery, where 1 = fully charged and 0 = empty

async getProductVersion()

Returns the IC production version.

async getHibernationThresholds()

Returns a dictionary keys "activeThreshold" and "hibernationThreshold". From the data sheet:

  • active threshold (volts): If at any ADC sample |OCVCELL| is greater than ActThr, the IC exits hibernate mode.
  • hibernate threshold (batery charge fraction per hour): If the absolute value of CRATE (charging rate) is less than hibernation threshold for longer than 6min, the IC enters hibernate mode.

async getAlergRange()

Returns a dictionary with keys "min" and "max", both values in volts. From the data sheet:

The IC alerts while VCELL > VALRT.MAX (max) or VCELL < VALRT.MIN (min)

async getChargingRate()

Returns the rate of charging (positive) or discharging (negative). The value is the fraction of the battery charge change per hour. 1.0 would represent the battery being charged from empty to full in one hour. -0.5 would represent the battery being discharged from full to empty in two hours (decrease of 50%/hour).

async getID()

From the data sheet:

ID is an 8-bit read-only value that is one-time programmable at the factory, which can be used as an identifier to distinguish multiple cell types in production.

async getVReset()

Returns a dictionary with keys "vreset" (value in volts) and enabled (boolean). From the data sheet:

...a fast analog comparator and a slower digital ADC threshold to detect battery removal and reinsertion.

enabled:

disable the analog comparator in hibernate mode to save approximately 0.5µA.

async getStatus()

Returns a dictionary with keys and boolean values:

  • reset_indicator: "is set when the device powers up. Any time this bit is set, the IC is not configured, so the model should be loaded and the bit should be cleared."
  • voltage_high: "is set when VCELL has been above ALRT.VALRTMAX."
  • voltage_low: "is set when VCELL has been below ALRT.VALRTMIN."
  • voltage_reset: "is set after the device has been reset if EnVr [enable_voltage_reset_alert] is set.
  • soc_low: "is set when SOC crosses the value in CONFIG.ATHD."
  • soc_change: "(1% SOC change) is set when SOC changes by at least 1% if CONFIG.ALSC is set."
  • enable_voltage_reset_alert: "when set to 1 asserts the ALRT pin when a voltage-reset event occurs under the conditions described by the VRESET/ ID register."