Using the LC709203F with Arduino is a simple matter of wiring up the sensor to your Arduino-compatible microcontroller, installing the Adafruit LC709203F library we've written, and running the provided example code.
I2C Wiring
Use this wiring to connect via I2C interface. The LC709203F uses I2C address 0x0B and it cannot be changed
Here is how to wire up the sensor using one of the STEMMA QT connectors. The examples show a Metro but wiring will work the same for an Arduino or other compatible board.
- Connect board VIN (red wire) to Arduino 5V if you are running a 5V board Arduino (Uno, etc.). If your board is 3V, connect to that instead.
- Connect board GND (black wire) to Arduino GND
- Connect board SCL (yellow wire) to Arduino SCL
- Connect board SDA (blue wire) to Arduino SDA
Plug a 3.7/4.2V lithium polymer or lithium ion rechargable battery into either of the JST battery ports.
Watch out for battery polarity! A reversed battery will damage the monitor. There are + and - symbols on the PCB to indicate which is which.
Library Installation
You can install the Adafruit LC709203F library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries ... menu item, search for Adafruit LC709203F , and select the Adafruit LC709203F library.
Follow the same process for the Adafruit BusIO library.
Load Example
Open up File -> Examples -> Adafruit LC709203F -> LC709203F_demo
After opening the demo file, upload to your Arduino wired up to the battery breakout.
Once you upload the code, you will see the Battery Voltage, Charge Percentage, and Temperature values being printed when you open the Serial Monitor (Tools->Serial Monitor) at 115200 baud, similar to this:
The LC chip works best when queried every few seconds at the fastest. Don't disconnect the LiPo battery, it is used to power the LC chip!
You can tweak the calculation for the battery pack size, by changing the line setPackSize(LC709203F_APA_500MAH);
Pick the closest of the following values for your battery size:
LC709203F_APA_100MAH, LC709203F_APA_200MAH, LC709203F_APA_500MAH, LC709203F_APA_1000MAH, LC709203F_APA_2000MAH, LC709203F_APA_3000MAH,
You can set an alarm for voltage or percent with setAlarmRSOC (percent) or setAlarmVoltage (floating point voltage), and check the INT pin going low
Text editor powered by tinymce.