EasyManua.ls Logo

Adafruit ESP32-S3 - LC709203 Simple Data Example

Adafruit ESP32-S3
263 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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!
}
After opening the LC709203F_demo file, upload it to your microcontroller. Open the S
erial Monitor at 115200 baud. You should see the following as the sketch starts up.
©Adafruit Industries Page 210 of 263

Table of Contents

Related product manuals