Crates.io | max170xx |
lib.rs | max170xx |
version | 1.0.0 |
source | src |
created_at | 2020-07-19 20:49:24.255639 |
updated_at | 2024-04-29 06:52:19.898447 |
description | Platform-agnostic Rust driver for the MAX170xx 1-cell/2-cell fuel-gauge systems with ModelGauge for lithium-ion (Li+) batteries. Compatible with MAX17043, MAX17044, MAX17048 MAX17049, MAX17058 and MAX17059. |
homepage | https://github.com/eldruin/max170xx-rs |
repository | https://github.com/eldruin/max170xx-rs |
max_upload_size | |
id | 266998 |
size | 47,867 |
This is a platform agnostic Rust driver for the ultra-compact, low-cost,
host-side fuel-gauge systems for lithium-ion (Li+) batteries in handheld
and portable equipment using the embedded-hal
traits.
It is compatible with MAX17043, MAX17044, MAX17048, MAX17049, MAX17058 and MAX17059.
This driver allows you to:
soc()
.voltage()
.reset()
.quickstart()
.version()
.charge_rate()
.set_table()
.The devices are ultra-compact, low-cost, host-side fuel-gauge systems for lithium-ion (Li+) batteries in handheld and portable equipment. There are models configured to operate with a single or dual lithium cell pack.
The devices use a sophisticated Li+ battery-modeling scheme, called ModelGauge(TM) to track the battery's relative state-of-charge (SOC) continuously over a widely varying charge/discharge profile. Unlike traditional fuel gauges, the ModelGauge algorithm eliminates the need for battery relearn cycles and an external current-sense resistor. Temperature compensation is possible in the application with minimal interaction between a μC and the device.
The communication is done through an I2C interface.
Datasheets: MAX17043/MAX17044, MAX17048/MAX17049, MAX17058/MAX17059
To use this driver, import this crate and an embedded_hal
implementation,
then instantiate the device.
Please find additional examples using hardware in this repository: driver-examples
use linux_embedded_hal::I2cdev;
use max170xx::Max17043;
fn main() {
let dev = I2cdev::new("/dev/i2c-1").unwrap();
let mut sensor = Max17043::new(dev);
loop {
let soc = sensor.soc().unwrap();
let voltage = sensor.voltage().unwrap();
println!("Charge: {:.2}%", soc);
println!("Voltage: {:.2}V", voltage);
}
}
For questions, issues, feature requests, and other changes, please file an issue in the github project.
This crate is guaranteed to compile on stable Rust 1.62 and up. It might compile with older versions but that may change in any new patch release.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.