Crates.io | i2cdev-bmp280 |
lib.rs | i2cdev-bmp280 |
version | 0.1.4 |
source | src |
created_at | 2017-08-06 15:52:41.32686 |
updated_at | 2017-10-18 22:27:39.107794 |
description | I2C driver for the BMP280 barometer, thermometer. |
homepage | |
repository | https://github.com/martindeegan/i2cdev-sensors |
max_upload_size | |
id | 26679 |
size | 20,412 |
An I2C driver for the BMP280 barometer, thermometer.
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;
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.