Skip to content

Commit

Permalink
implement offset calibration
Browse files Browse the repository at this point in the history
  • Loading branch information
hacknus committed Nov 26, 2023
1 parent 7e22411 commit 2bf9303
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use ads122x04::{interface::*, registers::*, ADS122x04, Error as ADS122x04Error};
{
let mut adc = ADS122x04::new_i2c(address, i2c);
adc.reset();
adc.calibrate_offset();
adc.set_input_mux(Mux::Ain1Ain0);
adc.set_conversion_mode(ConversionMode::Continuous);
adc.set_current_level(CurrentSource::Off);
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ impl<BUS, E> ADS122x04<BUS>
}

/// Calibrate the offset (according to 8.3.11 Offset Calibration in datasheet)
/// This is recommended upon startup and after changing the gain.
pub fn calibrate_offset(&mut self) -> Result<(), Error<E>> {
const NUM_AVG : usize = 10;
let timeout = 100;
Expand Down

0 comments on commit 2bf9303

Please sign in to comment.