Use
First include in your sketch MAX17043 and Wire libraries:
#include "MAX17043.h"
#include "Wire.h"
Define a new object from the MAX17043 class:
MAX17043 batteryMonitor;
In the setup() section, initialize the Wire library; then call reset() and quickStart() method:
Wire.begin();
batteryMonitor.reset();
batteryMonitor.quickStart();
You can now call the following methods:
float getVCell();
returns the battery’s voltage
float getSoC();
returns the battery’s state of charge (%)
int getVersion();
returns the IC version
byte getCompensateValue();
returns the compensation value; that is the value, related to the chemistry of your particular battery, that improves IC accuracy (Maxim offers a service to analize your battery and to give you the best value)
byte getAlertThreshold();
returns the value (%) of remaining charge under which the alert is triggered
void setAlertThreshold(byte threshold);
sets the value (%) of remaining charge under which the alert is triggered
boolean inAlert();
returns the alert state of the IC (is actual charge under threshold?)
void clearAlert();
clears the alert: you always have to clear it manually
1 Comment