BMP38x-ya
A Rust crate for Bosch Sensortec BMP38x and BMP390 air pressure sensor (-ya = Yet Another)
fix https://github.com/marvinrobot42/bmp38x-ya.git
The Bosch Sensortec BMP 384 (388) and 390 air pressure and temperature sensor with I2C interface.
Most I2C API functions are implemented.
Features
- uses embedded-hal version 1.0.x
- no_std embedded compatible
- async support included as a feature, default is sync or blocking
- designed for embedded use (ESP32-C3, -C6 and -S3 and Raspberry Pi)
- ESP32 RISC V and Raspberry Pi examples included
- most BMP384 IO functions implemented
- configurable interrupt pin function
- FIFO functions with configuration and easier "frame" based reads
- includes sealevel equivalent air pressure calculation when altitude is provided
Notes
Developed using Sparkfun BMP384 (QWIIC) model: https://www.sparkfun.com/sparkfun-pressure-sensor-bmp384-qwiic.html
It is recommended to enable both temperature and pressure measurements so that the air pressure can be accurate compensated (as it requires current temperature). This is a BMP3xx compensation algorthim design, not this driver.
Recent version history
- 0.1.0 Initial release
- 0.1.1 Fixed docs link
- 0.1.2 Updated docs
Usage
Add the dependency to Cargo.toml.
[]
= "0.1"
- Create a hardward specific I²C driver interface and a Delay object
- Create an BMP38x struct with the I²C interface and a delay object as parameters
- Initialize the BMP38x instance
- Create a new Bmp3Configuration using either the handy const builder or initial the struct's properties as required
- then call set_bmp3_configuration(new_bmp3Configuration)
- Optional: create a new InterruptPinControl instance and set its properties as required and call set_interrupt_pin_config fn
- Optional: create a new Fifo_Config instance and set its properties as required call set_fifo_config
- call get_status() and if (status.get_temp_ready() && status.get_press_ready())
- then call ither read_measurements or read_measurements_with_altitude fn
Simple Example
A more complete example is in the repository examples path
use Result; // add dependency for this
use ;
use ;
...
For async set bmp38x-ya dependency features = ["async"] and Bmp38x::new method requires async I2C and delay
parameters. Default features is sync (blocking)
License
You are free to copy, modify, and distribute this application with attribution under the terms of either
- Apache License, Version 2.0 (LICENSE-Apache-2.0 or https://opensource.org/licenses/Apache-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
This project is not affiliated with nor endorsed in any way by Silicon Labs or Adafruit.