Rust BME280 Crate
A Rust crate to query temperature, pressure and humidity from sensor BME280
https://gitlab.com/claudiomattera/bme280-rs/
This crate support both embedded-hal and embedded-hal-async.
See the changelog for this project.
Usage
Add the dependency to Cargo.toml.
[]
= "0.2.0"
A Bme280 structure can be created from an I²C interface and a delay function.
The initial sampling configuration disables all measurements, so it is necessary to reconfigure the chip with the desired settings before read samples.
use ;
let i2c = ...
let delay = ...
let mut bme280 = new;
bme280.init?;
bme280.set_sampling_configuration?;
if let Some = bme280.read_temperature? else
An AsyncBme280 structure can be used with asynchronous HALs.
Its API is completely identical to Bme280, just with .async at the end of function calls.
use ;
let i2c = ...
let delay = ...
let mut bme280 = new;
bme280.init?;
bme280.set_sampling_configuration.await?;
if let Some = bme280.read_temperature.await? else
Unit of Measurements
By default, this crate uses f32 values for all the measurements temperature, pressure and humidity.
When instead enabling the Cargo feature uom, it uses quantities from crate uom.
Temperature measurements have type uom::si::f32::ThermodynamicTemperature, pressure measurements have type uom::si::f32::Pressure, and humidity measurements have type uom::si::f32::Ratio.
License
Copyright Claudio Mattera 2022-2024
You are free to copy, modify, and distribute this application with attribution under the terms of either
- Apache License, Version 2.0
(file
LICENSE-APACHE-2.0.txtor https://opensource.org/licenses/Apache-2.0) - MIT license
(file
LICENSE-MIT.txtor https://opensource.org/licenses/MIT)
at your option.
This project is entirely original work, and it is not affiliated with nor endorsed in any way by Bosch Sensortec.