BMP180 Driver
This library provides an interface for interacting with the BMP180 pressure sensor.
Installation
You can install the package via Cargo:
cargo add bmp180-driver
Then, you can use the library in your code as follows:
use std::error::Error;
use bmp180_driver::{Common, Resolution, BMP180};
use esp_idf_svc::hal::delay::FreeRtos;
use esp_idf_svc::hal::i2c::config::Config;
use esp_idf_svc::hal::i2c::I2cDriver;
use esp_idf_svc::hal::prelude::Peripherals;
fn main() -> Result<(), Box<dyn Error>> {
let peripherals = Peripherals::take()?;
let sda = peripherals.pins.gpio6;
let scl = peripherals.pins.gpio5;
let i2c = I2cDriver::new(peripherals.i2c0, sda, scl, &Config::default())?;
let mut sensor = BMP180::new(i2c, FreeRtos);
sensor.check_connection()?;
let mut sensor = sensor.initialize()?;
loop {
let (temperature, pressure, altitude) = sensor.read_all(Resolution::UltraHighResolution)?;
println!("Temperature: {} °C", temperature);
println!("Pressure: {} Pa", pressure);
println!("Altitude: {} meters", altitude);
}
}
References
License
The MIT License (MIT). Please see License File for more information.