bmpe280 0.2.5

An I2C driver for the Bosch BMP280/BME280 barometer , thermometer.
Documentation

BMP280-driver

An I2C driver for the BMP280 barometer, thermometer.

Usage Add the following to your Cargo.toml:

[dependencies]
bmpe280 = "0.1.5-ehal02"

Use embedded-hal implementation to get I2C handle and delay then create handle.

For BMP280 and esp32 no_std:


#![no_std]
#![no_main]


use esp_backtrace as _;
use esp_hal::i2c::master::{ Config, I2c};
use esp_hal::{delay::Delay, main};

use esp_println::println;
use  bmp280_driver::BMP280;

#[main]
fn main() -> ! {
    let config=esp_hal::Config::default();

    let   delay = Delay::new();

    let peripherals = esp_hal::init(config);
    let i2c0 = I2c::new(peripherals.I2C0, Config::default())
        .unwrap()
        .with_sda(peripherals.GPIO3)
        .with_scl(peripherals.GPIO1);
    let mut bmp = BMP280::new(i2c0);
    loop {
        let m=bmp.measure();
        println!("1:temperature:{0}℃, pressure:{1}",m.temperature,m.pressure);
        delay.delay_millis(1000);
    }
}

For BMP280 and stm32f103 no_std:

 use  bmp280_driver::BMP280;

    let mut gpiob = dp.GPIOB.split();
    let scl = gpiob.pb8.into_alternate_open_drain(&mut gpiob.crh);
    let sda = gpiob.pb9.into_alternate_open_drain(&mut gpiob.crh);

    let mut afio = dp.AFIO.constrain();
    let i2c = I2c::i2c1(
        dp.I2C1,
        (scl, sda),
        &mut afio.mapr,
        Mode::Standard {
            frequency: 100.kHz(),
        },
        clocks,
    );
    let mut i2c1 = i2c.blocking_default(clocks);
    let mut delay = dp.TIM2.delay_us(&clocks);
    let mut bmp =  BMP280::new(i2c1);

    loop {
        let m=bmp.measure();
        println!("1:temperature:{0}℃, pressure:{1}",m.temperature,m.pressure);
        delay.delay_ms(2000_u16);
    }