Arduino Uno + BME280 compilation error #340
-
I decided to move my question from #301 to a separate discussion I am trying to use a bme280 environmental sensor connected to an Arduino Uno using I2C. I do it like this: fn measure_bme() {
let dp = Peripherals::take().unwrap();
let pins = arduino_hal::pins!(dp);
let mut i2c = arduino_hal::i2c::I2c::new(
dp.TWI,
pins.a4.into_pull_up_input(),
pins.a5.into_pull_up_input(),
50000,
);
let mut bme280= BME280::new_primary(i2c);
} The compilation error looks like this:
Dependencies are: arduino-hal = { git = "https://github.com/rahix/avr-hal", rev = "81edfcd908be8d3b2cd763cf2dc76aedbb22286b", features = ["arduino-uno"] }
embedded-hal = "0.2.7"
panic-halt = "0.2.0"
bme280 = "0.4.4" I tried to implement it as it was in https://github.com/maspetsberger/rust-esp32-bme280/blob/master/src/main.rs#L30. The library (https://github.com/VersBinarii/bme280-rs) also contains an example of using I2C. Could you help me fix the compilation error? Is it worth to try using SPI? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hi, the problem is that the library in question uses embedded-hal version What you can try doing is building a compatibility wrapper around our type which then implements the trait from
|
Beta Was this translation helpful? Give feedback.
Hi, the problem is that the library in question uses embedded-hal version
1.0.0-alpha.7
(https://github.com/VersBinarii/bme280-rs/blob/efd5a52273014d98d41b85e454142c5c75ef6139/Cargo.toml#L16) while we're still using0.2.7
. These two are incompatible so there isn't an easy way to get them to work together...What you can try doing is building a compatibility wrapper around our type which then implements the trait from
1.0.0-alpha.7
. Something like this:Cargo.toml
main.rs