Skip to content

Lightweight library for bme280

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

jacksonn97/avr-bme280

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

avr-bme280

Library based on avr-hal

Using

First you need to add this crate as dependence:

[dependencies]
avr-bme280 = { git = "https://github.com/jacksonn97/avr-bme280" }

Then you can use library just like:

use avr_bme280::i2c::BME280; // you can change i2c to spi as you want
let mut bme280 = BME280::init(&mut i2c, 0x76); // specify your i2c bus and address of sensor
                                               // for spi is spi bus and SS pin
let measure = bme280.get_measures(&mut i2c);
           // Return type is structure with temperature, humidity as pressure

Connection SPI

Board pin1 Sensor pin
SCK 13 SCL
MOSI 11 SDA
MISO 12 SDO
SS 10 CSB

You can you SPI definition like this:

let (mut spi, ss) = Spi::new(dp.SPI,
    pins.d13.into_output(),
    pins.d11.into_output(),
    pins.d12.into_pull_up_input(),
    pins.d10.into_output(),
    spi::Settings {
        data_order: arduino_hal::spi::DataOrder::MostSignificantFirst,
        clock: arduino_hal::spi::SerialClockRate::OscfOver4,
        mode: embedded_hal::spi::MODE_0, // you can also use MODE_3
    }
 );

Connection I2C

Board pin1 Sensor pin
SCL A5 SCL
SDA A4 SDA

Roadmap

  • I2C support
  • SPI support
  • Docs
  • Datasheet brief

Footnotes

  1. Specified pin numbers for Nano, watch pinout 2