#i2c #sensor #embedded-hal-driver #battery-gauge

no-std lc709203

Platform-agnostic Rust driver for the LC709302 battery gauge sensor

3 unstable releases

0.2.1 Dec 30, 2021
0.2.0 Dec 30, 2021
0.1.0 Dec 30, 2021

#1097 in Embedded development

Download history 2/week @ 2024-03-10 45/week @ 2024-03-31 1/week @ 2024-04-07

64 downloads per month

MIT license

26KB
518 lines

LC709203

A Rust library for interfacing with ON Semiconductor LC709203 battery gauge chips. Based on embedded-hal traits and requires a concrete implementation of at least the i2c::Write and i2c::WriteRead traits.

Documentation

View on docs.rs.


lib.rs:

A platform agnostic Rust driver for the LC709302 battery gauge sensor.

Example usage

// some concrete type implementing I2C access, i.e. the embedded_hal::blocking::i2c::WriteRead
// and embedded_hal::blocking::i2c::Write traits
let i2c = I2C::new();

// create a builder
let lc709203 = lc709203::Builder::default()
    .with_battery_capacity(2500) // battery capacity (specified in mAh) must be set!
    .build(&mut i2c)?; // initialize the lc709203 chip
let battery_voltage = lc709203.cell_voltage_v(&mut i2c)?; // query current battery voltage

Dependencies

~160KB