Skip to content

Commit

Permalink
Change INA219 base address and calibration value
Browse files Browse the repository at this point in the history
  • Loading branch information
samderanova committed Apr 26, 2024
1 parent b1102c1 commit 02c6c1f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pod-operation/src/components/ina219.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
use ina219::{INA219, INA219_ADDR};
use ina219::INA219;
use rppal::i2c::I2c;
use tracing::debug;

pub async fn read_current() {
let device = I2c::new().unwrap();
let mut ina = INA219::new(device, INA219_ADDR);

// Use the default INA219 address, located at 0x40. This changes depending
// on whether we've set A0 and A1 to high.
let mut ina = INA219::new(device, 0x40);
debug!("Initialized I2C and INA219");

ina.calibrate(0x0100).unwrap();
// In the Adafruit INA219 Python Driver, the calibration value is set to
// 4096 (0x1000) and Current_LSB is set to 0.1 by default.
ina.calibrate(0x1000).unwrap();
debug!("Calibrating INA219");

loop {
Expand Down

0 comments on commit 02c6c1f

Please sign in to comment.