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

reading pressure or humidity without temperature can result incorrect results #39

Closed
pbolduc opened this issue Nov 5, 2019 · 3 comments

Comments

@pbolduc
Copy link
Contributor

pbolduc commented Nov 5, 2019

The readings for the humidity and pressure can be off because they depend on the temperature reading. There is a instance variable t_fine that both humidity and pressure reference. It is only initialized in when reading the temperature. This fact should be documented.

I propose adding a single method that reads all three measurements in a single call to the sensor. In my measurements on a Moteino M0, the time required to read temperature, humidity and pressure can be reduced by about 35% (1139 us vs 1729 us). Reading all values in a single call ensures the sensor values are all from the same measurement.

My first prototype looks like this. However, I am thinking on changing this a bit to align it better with the style of BME280 class with various methods (ie temperature in C / F, altitude in meters / feet). Thoughts?

struct BME280_SensorMeasurements
{
  public:
	float temperature;
	float pressure;
	float humidity;
};

class BME280
{
  public:
    void read(BME280_SensorMeasurements *measurements);
}

edit: fixed units from ns to us.

@santaimpersonator
Copy link
Contributor

Thanks for the assist on the other issue. I think your suggestion is valid and convenient if users could specify the measurements they wanted (though, I'm not sure if that the best approach).

If you submit a pull request, I'd be happy to verify it on a few boards.

@cdonate
Copy link
Contributor

cdonate commented Dec 26, 2020

I've created a PR for this feature. I'm not a C++ guy, so please, check and make any changes you think are necessary. All measurements are read, I don't know if this would be a problem.
#50

@nseidle
Copy link
Member

nseidle commented Dec 31, 2020

Thanks @cdonate. Will be in next release.

@nseidle nseidle closed this as completed Dec 31, 2020
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

4 participants