VersBinarii / bme280-rs

A platform agnostic Rust driver for the Bosch BM[PE]-280
Other
59 stars 73 forks source link

Use configurable readout delay #32

Open avsaase opened 6 months ago

avsaase commented 6 months ago

The measurement time is hardcoded using a delay of 40ms: https://github.com/VersBinarii/bme280-rs/blob/051071f898630c0fd8845cc7eea966a5654e74af/src/lib.rs#L691 This limits the measurement rate to 25Hz, while both the BMP280 and BME280 datasheets say faster updates rates are supported when using lower oversampling and IIR values. Would it make sense to add a measurement delay field to the Configuration struct? The datasheets don't provide the correct values for all combinations of oversampling and IRR filter settings so I think setting the delay is best left to the user.

oddlama commented 6 months ago

The datasheets don't provide the correct values for all combinations of oversampling and IRR filter settings so I think setting the delay is best left to the user.

What do you mean exactly? The measurement delay seems to be defined precisely in chapter 9 of the datasheet. And the IIR Filter doesn't add any delay to measurements. I think the 40ms should just be replaced by the correct value for the specific device settings. Unfortunately the owner of this crate hasn't responded or updated the crate for 11 months, so in the meantime I implemented my own driver which respects this. If you want to fork this one and replace the 40ms by the precise calculation, you can view the code here.