newAM / bme280-multibus

Embedded rust driver for the Bosch BME280.
MIT License
6 stars 3 forks source link

Align with ESP IDF HAL embedded-hal #42

Closed mbuesch closed 1 year ago

mbuesch commented 1 year ago

Latest ESP IDF HAL is on embedded-hal 1.0.0-rc.1. It might be a good idea to release the current main branch of bme280-multibus as version 0.4 to align it with the latest ESP toolkit.

Thanks :)

mbuesch commented 1 year ago

Oh I just noticed that it doesn't support I2C with embedded-hal 1.0.0.x anymore. That's a show stopper for me. I can look into that, if you want.

Or am I misinterpreting it?

newAM commented 1 year ago

I just haven't gotten around to it yet, feel free to open a PR with an EH-1 I2C implementation!

mbuesch commented 1 year ago

Great. Yes, I will do that. I need support for that.

mbuesch commented 1 year ago

cool. Thanks :)

newAM commented 1 year ago

No problem, sorry it took a while to review :)

ds2k5 commented 11 months ago

@mbuesch

Could you be so kind an share your code

Try to get ESP32 & BME280 with Rust but I am lost....

use esp_idf_hal::i2c::*;
use esp_idf_hal::delay::FreeRtos;
use esp_idf_hal::peripherals::Peripherals;
use bme280_multibus::{Address, Bme280, Sample};

const SETTINGS: bme280_multibus::Settings = bme280_multibus::Settings {
    config: bme280_multibus::Config::RESET
        .set_standby_time(bme280_multibus::Standby::Millis1000)
        .set_filter(bme280_multibus::Filter::X16),
    ctrl_meas: bme280_multibus::CtrlMeas::RESET
        .set_osrs_t(bme280_multibus::Oversampling::X8)
        .set_osrs_p(bme280_multibus::Oversampling::X8)
        .set_mode(bme280_multibus::Mode::Normal),
    ctrl_hum: bme280_multibus::Oversampling::X8,
};

fn main() {
    // It is necessary to call this function once. Otherwise some patches to the runtime
    // implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71
    esp_idf_svc::sys::link_patches();

    // Bind the log crate to the ESP Logging facilities
    esp_idf_svc::log::EspLogger::initialize_default();

    log::info!("Hello, world!");

use bme280_multibus::{Address, Bme280, Sample};

let peripherals = Peripherals::take().unwrap();
let i2c = peripherals.i2c0;
let sda = peripherals.pins.gpio21;
let scl = peripherals.pins.gpio22;
let mut bme: Bme280<_> = Bme280::from_i2c0(i2c, Address::SdoGnd)?;
bme.settings(&SETTINGS)?;
let sample: Sample = bme.sample().unwrap();

}