finitespace / BME280

Provides an Arduino library for reading and interpreting Bosch BME280 data over I2C, SPI or Sw SPI.
GNU General Public License v3.0
212 stars 105 forks source link

Correct implementation of forced measurements #91

Open FlorianFranzen opened 6 years ago

FlorianFranzen commented 6 years ago

Issue

The current implementation does not allow you to trigger the sensor correctly and with as little overhead as possible.

A measurement always results in unnecessary computation followed by the actual forcing and then by a read-out of the old value, as the sensor needs at least 5.5ms to acquire even a single measurement.

Description of changes/fixes

These patches introduce the force() function to trigger a sensor measurement. The result can then be read out in the usual way at any later point in time (till it is triggered again). To know if the device is busy measuring or what mode it is in, it also introduces access to the state and mode register through the busy() and mode() function call.

It also includes a patch to support the use on none-default Wire interfaces and some minor cleanups.

All the examples were updated as well.

If necessary, I can also split the commit in separate requests.

Steps to test

@kvoit significantly contributed to this work.

finitespace commented 6 years ago

@FlorianFranzen thanks for your pull. I haven't had time to go through all of the changes or to look at whether this is a better way of polling the sensor.

I do have a lot of questions on some changes you made such as why you switched to TwoWire? There are a lot of architectural changes that I will likely have to change to match the style of the library.

I don't necessarily like the idea of having unused portions of the API that only pertain to certain sensor modes, so that might need to be changed.

The I2C address enum should not be in the base BME280 class.

Member variable names should start with 'm_'. Also, the ctrlHum, ctrlMeas and config variables have been added as member variables when I don't see them used anywhere else.

What was the reasoning behind changing the delays to 1000?

So suffice to say, I am grateful for the submission and I will have the check the validity of the changes, but there is a lot that needs to be changed in order to incorporate it into the main branch.

finitespace commented 3 years ago

@FlorianFranzen any luck updating this pull request?