Crate spl06_007

source ·
Expand description

I2C driver for the SPL06-007 pressure and temperature sensor. This sensor is available as a breakout board for the Arduino platform. This driver may also work with the SPL06-001, but this has not been tested.

Instantiate the Barometer struct with a reference to the I2C bus. The sensor will then be ready to read temperature and pressure values.

use spl06_007::*;
use embedded_hal_mock::i2c::Mock as I2c;
let mut i2c = I2c::new(&[]);
 
let mut barometer = Barometer::new(&mut i2c).expect("Failed to instantiate barometer");
let temp = barometer.get_temperature().unwrap();
let pressure = barometer.get_pressure().unwrap();
let altitude = barometer.altitude(1020.0).unwrap();

You can set the mode, sample rate, and oversampling values manually:

barometer.set_pressure_config(SampleRate::One, SampleRate::Eight);
barometer.set_temperature_config(SampleRate::One, SampleRate::Eight);

This is useful for more rapid updates, better precsion, or lower power draw.

It is also possible to set the mode to Mode::Standby to reduce power consumption.:

barometer.set_mode(Mode::Standby);

Structs

Enums