5 releases
Uses old Rust 2015
0.1.4 | Oct 18, 2017 |
---|---|
0.1.3 | Aug 23, 2017 |
0.1.2 | Aug 12, 2017 |
0.1.1 | Aug 6, 2017 |
0.1.0 | Aug 6, 2017 |
#6 in #thermometer
26KB
502 lines
BMP280
An I2C driver for the BMP280 barometer, thermometer.
Usage
Add the following to your Cargo.toml
:
[dependencies]
i2csensors = "0.1.*"
i2cdev-bmp280 = "0.1.*"
Next, add this to your crate root:
extern crate i2cdev_bmp280;
extern crate i2csensors;
Initializing and reading from a BMP280
use i2cdev_bmp280::*;
use i2csensors::{Barometer, Thermometer};
fn main() {
let i2c_device = i2cdev_bmp280::get_linux_bmp280_i2c_device().unwrap();
let settings = BMP280Settings
{
compensation: BMP280CompensationAlgorithm::B64,
t_sb: BMP280Timing::ms0_5,
iir_filter_coeff: BMP280FilterCoefficient::Medium,
osrs_t: BMP280TemperatureOversampling::x1,
osrs_p: BMP280PressureOversampling::StandardResolution,
power_mode: BMP280PowerMode::NormalMode
};
let bmp280 = BMP280::new(device, settings);
let temperatue = bmp280.temperature_celsius().unwrap();
let pressure = bmp280.pressure_kpa().unwrap());
}
Settings can be adjusted according to the datasheet.
Dependencies
~2–3.5MB
~59K SLoC