Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to stand by time and filter could be ignored #40

Open
pbolduc opened this issue Nov 10, 2019 · 1 comment
Open

Changes to stand by time and filter could be ignored #40

pbolduc opened this issue Nov 10, 2019 · 1 comment
Assignees

Comments

@pbolduc
Copy link
Contributor

pbolduc commented Nov 10, 2019

The the Bosch BME280 data sheet state,

5.4.6 Register 0xF5 "config"
The "config" register sets the rate, filter and interface options of the device. Writes to the "config" register in normal mode may be ignored. In sleep mode writes are not ignored.

Since at the end of the begin call, the mode is set to normal. Calls to setStandbyTime or setFilter may be ignored. It should also be noted about the sensor mode transitions,

3.3.1 Sensor mode transitions
If the device is currently performing a measurement, the execution of mode switching commands is delayed until the end of the currently running measurement period.

These two functions should check the current mode, if it is not in sleep mode, change to sleep mode, make the change and return to the original mode. If the device is currently measuring, it should wait until the measurement is complete before setting the values.

It is unclear in the data sheet, if in forced mode if the writes would be ignored or not. In forced mode, once the measurement is complete, the mode transitions back to sleep automatically.

The error is easy for someone to come across, for example Issue 27, the person calls begin and subsequently calls setStandbyTime andsetFilter.

I can also see setTempOverSample, setPressureOverSample and setHumidityOverSample use this get mode, set mode to sleep, change setting and set mode to original pattern. I was not able to find anything in the data sheet about requiring sleep mode for the over sample settings to take effect. The temperature and pressure settings use the same ctrl_meas register which is shared with the mode. The humidity oversampling does not take effect util a write to ctrl_meas, but it does not state the device needs to be in sleep mode.

@santaimpersonator santaimpersonator self-assigned this Dec 28, 2019
@santaimpersonator
Copy link
Contributor

While I agree that the automated functionality would be useful for novice users; I would argue that these are more advanced functions of the library and users should be referring to the datasheet and source code when using them. Currently, my hesitation is that it makes the code "repetitive" for advanced users.

  • With the proposed modifications, changing 2 settings would require 10 transactions.
    • (1) Checking the "current mode".
    • (2) Changing to sleep mode.
    • (3-4) Adjusting the settings (2 transactions).
    • (5) Changing back to the "current mode".
    • (6-10) Repeat steps.
  • Whereas, with the current library, it is completed in 6 transactions
    • (1) Changing to sleep mode.
    • (2-5) Adjusting the 2 settings (4 transactions).
    • (6) Changing to the preferred mode.
  • While the proposed changes shouldn't cause backwards compatibility issues, it does create a situation where other customers' code would now compile with redundant sleep mode transactions as well.
    • Would timing delay of added transactions be an issue?

Notes:

  • I could add comments in the source code and hookup guides for users.
  • Example4.ino probably needs to be updated for this issue. Test to confirm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants