As of February 8, 2023, the now-discontinued LC709203 battery monitor chip has been replaced with the MAX17048. Unsure which one you have? Check the silk on the back of the board. If your board does NOT have "MAX17048 Monitor" in the upper left corner, then you have the LC709203 version.

Your microcontroller board comes with an LC709203 lithium ion polymer (lipoly) battery monitor built right onto the board. The LC709203 is available over I2C.

The sensor comes with its own Adafruit CircuitPython library that makes it simple to write code to read data from it. This example will be using, among other things, the Adafruit LC709203F library.

The example simply reads data from the sensor and prints it to the serial console. It is designed to show you how to get data from the sensor.

The LC709203 battery monitor (highlighted in red) is located along the top of the board below the USB pin label. Its I2C address is 0x0B. (0xb, which is returned by I2C scan, is the same as 0x0B, which simply has leading zeros.)

Arduino Library Installation

You can install the necessary libraries from the Library Manager. To open, click Sketch > Include Library > Manage Libraries...

Search for LC709203F, and install the Adafruit LC709203F library.

When asked about installing dependencies, click Install all

LC709203 Simple Data Example

Click File > Examples > Adafruit LC709203F > LC709203F_demo to open the example.

#include "Adafruit_LC709203F.h"

Adafruit_LC709203F lc;

void setup() {
  Serial.begin(115200);
  delay(10);
  Serial.println("\nAdafruit LC709203F demo");

  // For the Feather ESP32-S2, we need to enable I2C power first!
  // this section can be deleted for other boards
#if defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2)
  // turn on the I2C power by setting pin to opposite of 'rest state'
  pinMode(PIN_I2C_POWER, INPUT);
  delay(1);
  bool polarity = digitalRead(PIN_I2C_POWER);
  pinMode(PIN_I2C_POWER, OUTPUT);
  digitalWrite(PIN_I2C_POWER, !polarity);
#endif

  if (!lc.begin()) {
    Serial.println(F("Couldnt find Adafruit LC709203F?\nMake sure a battery is plugged in!"));
    while (1) delay(10);
  }
  Serial.println(F("Found LC709203F"));
  Serial.print("Version: 0x"); Serial.println(lc.getICversion(), HEX);

  lc.setThermistorB(3950);
  Serial.print("Thermistor B = "); Serial.println(lc.getThermistorB());

  lc.setPackSize(LC709203F_APA_500MAH);

  lc.setAlarmVoltage(3.8);
}

void loop() {
  Serial.print("Batt_Voltage:");
  Serial.print(lc.cellVoltage(), 3);
  Serial.print("\t");
  Serial.print("Batt_Percent:");
  Serial.print(lc.cellPercent(), 1);
  Serial.print("\t");
  Serial.print("Batt_Temp:");
  Serial.println(lc.getCellTemperature(), 1);

  delay(2000);  // dont query too often!
}
Make sure to press the reset button after uploading code from the Arduino IDE to the ESP32-S3.

After opening the LC709203F_demo file, upload it to your microcontroller. Open the Serial Monitor at 115200 baud. You should see the following as the sketch starts up.

The thermistor pin on the LC709203F, used to measure the battery temperature, is not broken out for connection to an external thermistor. So the temperature values printed out by the LC709203F_demo will not be meaningful.

Once the sketch begins running, you should see something like the following.

That's all there is to reading battery data from the LC709203 using Arduino!

This guide was first published on Apr 20, 2022. It was last updated on Jul 23, 2024.

This page (LC709203 Simple Data) was last updated on Jul 19, 2024.

Text editor powered by tinymce.