Closed coelner closed 6 years ago
The datasheet is a little ambiguous, but it sounds like we could do a measurement without filtering and this will cause the filter buffer to be initialized with values. Is that your interpretation as well? See the section under Table 6.
Yes, I see it in the same way. I'm not sure why we get no valid values for the first time. They should be copied directly like it is done for the following measurements.
Alright, I have added a routine to initialize the filter buffer. Could you pull down the filtering branch and check if it fixes the problem?
Yes, it does work for me. I used your BME_280_I2C_Test sketch.
Found BME280 sensor! Success.
Temp: 22.42°C Humidity: 44.26% RH Pressure: 97900.85Pa
Temp: 22.33°C Humidity: 44.31% RH Pressure: 97908.03Pa
Temp: 22.32°C Humidity: 44.28% RH Pressure: 97907.81Pa
Temp: nan°C Humidity: nan% RH Pressure: nanPa
Temp: 23.53°C Humidity: 63.39% RH Pressure: 69626.69Pa
Temp: 24.06°C Humidity: 40.52% RH Pressure: 97906.53Pa
Temp: 24.07°C Humidity: 40.53% RH Pressure: 97906.59Pa
Temp: 24.07°C Humidity: 40.51% RH Pressure: 97906.31Pa
I disconnect the BME from 3.3V (nan values) and reattach it.
@coelner In your output the first read after your disconnect is still way off, especially the pressure. Is this still to be expected?
@AndreKR
1)
Could not find BME280 sensor!
Could not find BME280 sensor!
Could not find BME280 sensor!
2)
Found BME280 sensor! Success.
Temp: 22.18°C Humidity: 68.12% RH Pressure: 73302.31Pa
Temp: 26.73°C Humidity: 66.95% RH Pressure: 101237.52Pa
Temp: 26.70°C Humidity: 48.61% RH Pressure: 101237.36Pa
Temp: 26.66°C Humidity: 41.93% RH Pressure: 101237.63Pa
Temp: 26.62°C Humidity: 38.96% RH Pressure: 101237.44Pa
Temp: 26.57°C Humidity: 37.40% RH Pressure: 101237.91Pa
Temp: 26.51°C Humidity: 36.45% RH Pressure: 101237.97Pa
Temp: 26.46°C Humidity: 35.89% RH Pressure: 101237.78Pa
Temp: 26.40°C Humidity: 35.58% RH Pressure: 101237.60Pa
Temp: 26.34°C Humidity: 35.41% RH Pressure: 101237.97Pa
Temp: 26.28°C Humidity: 35.18% RH Pressure: 101238.09Pa
Temp: 25.36°C Humidity: 33.31% RH Pressure: 101231.35Pa
Temp: 25.36°C Humidity: 33.13% RH Pressure: 101231.18Pa
Temp: 25.36°C Humidity: 36.83% RH Pressure: 101231.12Pa
3)
Temp: nan°C Humidity: nan% RH Pressure: nanPa
Temp: nan°C Humidity: nan% RH Pressure: nanPa
Temp: nan°C Humidity: nan% RH Pressure: nanPa
Temp: nan°C Humidity: nan% RH Pressure: nanPa
Temp: nan°C Humidity: nan% RH Pressure: nanPa
4)
Temp: 25.37°C Humidity: 38.29% RH Pressure: 101230.91Pa
Temp: 25.39°C Humidity: 47.79% RH Pressure: 101231.15Pa
Temp: 25.42°C Humidity: 45.15% RH Pressure: 101231.32Pa
Temp: 25.44°C Humidity: 39.14% RH Pressure: 101231.70Pa
Temp: 25.65°C Humidity: 33.12% RH Pressure: 101230.97Pa
5)
Temp: 22.18°C Humidity: 68.12% RH Pressure: 73302.31Pa
Temp: 22.18°C Humidity: 68.12% RH Pressure: 73302.31Pa
Temp: 22.18°C Humidity: 68.12% RH Pressure: 73302.31Pa
Temp: 22.18°C Humidity: 68.12% RH Pressure: 73302.31Pa
Temp: 22.18°C Humidity: 68.12% RH Pressure: 73302.31Pa
Temp: 22.18°C Humidity: 68.12% RH Pressure: 73302.31Pa
Temp: 22.18°C Humidity: 68.12% RH Pressure: 73302.31Pa
Temp: 22.18°C Humidity: 68.12% RH Pressure: 73302.31Pa
6)
Temp: 26.85°C Humidity: 47.34% RH Pressure: 101235.56Pa
Temp: 26.85°C Humidity: 48.57% RH Pressure: 101235.53Pa
To sum it up:
the current i2c example was used
So in your case at least the first value is off, too.
Here are 25 pressure measurements (in hPa) I took right after switching on the sensor:
705.31
705.31
705.31
1027.43
1027.43
1027.43
1027.47
1027.47
1027.47
1027.47
1027.50
1027.50
1027.50
1027.46
1027.46
1027.46
1027.50
1027.50
1027.43
1027.43
1027.43
1027.41
1027.41
1027.41
1027.41
It puzzles me why there are 3 wrong values and then they start to be plausible. Is it possible that in addition to the first value being wrong, I'm also reading the same value multiple times? I'm in forced mode (default), so each bme.read()
should trigger one measurement and wait for its completion, right?
@finitespace I think we need a deep dive into the code and fix rare cases. Maybe some things could be fixed by integrate the pending pull requests.
if we initialize the sensor we must take care of the sensor values. The user should not be bothered with handling the device in the right way, if the user wants a true measurement, they should get it. #59
We need to add at least one measurement (if forced mode is active). But in general we should use the table 6 'filter settings' to force a count of measurements before the user get control.