View on GitHub

MAX1704X Arduino Library

Arduino library for MAX17043/MAX17044 lithium ion battery fuel gauge.

Home - Getting Started - Constructor - Initialization - Functions - Examples

Basic Initialization - Initialize Wire Yes/No - Custom Address - Custom Address and Initialize Wire Yes/No - Custom Wire - Custom Wire and Address - Custom Wire, Address and Initialize Wire Yes/No

Initialize Wire Yes/No

Description

Performs a basic initialization of the library buts allows you to specify whether or not a call to Wire.begin() is made. If allowed, the default SDA and SCL pins for your board are used.

Parameters

initializeWire : bool

Returns

successful: bool

Example

#include <MAX17043.h>

void setup()
{
  Serial.begin(9600);

  //
  // Initialize Wire.
  //
  Wire.begin();
  
  //
  // Initialize the fuel gauge.
  //
  FuelGauge.begin(false);
}

void loop()
{
  Serial.print("Battery percentage is ");
  Serial.print(_fuelGauge.percent());
}

or

#include <MAX1704X.h>

MAX1704X _fuelGauge = MAX1704X(MAX17043_mV); 

void setup()
{
  Serial.begin(9600);
  
  //
  // Initialize Wire.
  //
  Wire.begin();
  
  //
  // Initialize the fuel gauge.
  //
  _fuelGauge.begin(false);
}

void loop()
{
  Serial.print("Battery percentage is ");
  Serial.print(_fuelGauge.percent());
}

Notes

Making a call FuelGauge.begin(true) is functionally equivalent to FuelGauge.begin().

The default fuel gauge address used by the library is 0x36 (I2C_DEFAULT_ADDRESS).