-
Notifications
You must be signed in to change notification settings - Fork 174
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
bmx280 getTemperature returns same -incorrect- value #102
Comments
The SensorDriver code is calling
Can you provide more information about this? Maybe some code snippets or a sample project? |
My code is 90% the code from the example on the readme of the Rainbow HAT section. I'll post it once I get to my laptop. I know it calls readTemperature internally, I spent more than 1 hour digging into the source code and debugging it. That's what makes this bug more strange. |
First Example:
Second example:
If I run the first example, the reading is always the same. That's why I think there is some initialization as part of the driver setup that is missing on the first example, the chip keeps the initialized state from the 2nd Activity and that's why running the 1st one again works.. For the record, the same issue happens with pressure. |
@jdkoren could you replicate this issue? |
We can replicate the issue. The difference is that the sensor driver sets the power mode of the chip to NORMAL before attempting readings. The MVP init code for using the
This is generally the default state of the chip, but the user shouldn't assume that. In your case, the chip is powering up in sleep mode. We'll update the usage docs to reflect this. |
Thanks Dave! it really sounded like a missing initialization, but I could not find it. |
Actually, just a thought, it would make sense to put it to sleep a part of close, or recommend to put it into sleep mode as part of the release, to save power. Does that make sense? |
It's heavily use case dependent, but it might make sense to include it in the documented example for clarity. We'll think about the best way to communicate this. We can't assume that you want to sleep the chip on close any more than we can assume you want to wake the chip immediately after opening it (the sensor driver waits until readings are required, for example). But I see your point. |
@devunwired Thank you so much! 👍 |
In short, if you use a SensorDriver it works fine, but if you use just the Bmx280 object and call readTemperature, you get the same value every time. It is even the same value after a restart or in different days.
The most annoying part is that if you first initilize the sensor driver (on its own Activity) to then release it, then readTemperature works properly, so it sounds like there is some initialization missing.
Steps to replicate:
Expected result:
Actual result:
Given the placement of the sensor on the Rainbow HAT (close to the CPU of the Raspberry Pi), this is very noticeable, because the temperature slowly increases.
The text was updated successfully, but these errors were encountered: