Iot: Bmp280 Sensor gives wrong readings

Created on 26 Mar 2020  Â·  14Comments  Â·  Source: dotnet/iot

While testing the Bmp280 sensor, I found that mine was giving very wrong readings (~940hPa when it should be in the order of ~1010hPa). There's definitelly no storm outside now, and it's cold but sunny.

Investigating further, I found a small bug in the calibration calculation for temperatures:

Line 181 of Bmxx80Base.cs should be changed to:

double var1 = ((((double)adcTemperature / 16384.0) - ((double)_calibrationData.DigT1) / 1024.0)) * (double)_calibrationData.DigT2;

There are missing parentheses in that formula.

I'll come up with a patch for this (including an unit test), however, since my sensor still gives the wrong values (also with the python reference implementation), it's hard for me to know that's really all.

See also #1022

CC @djaus2

area-device-bindings bug

Most helpful comment

Ok will do in next 24hrs

David Jones MVP


From: Patrick Grawehr notifications@github.com
Sent: Wednesday, April 1, 2020 4:28:56 PM
To: dotnet/iot iot@noreply.github.com
Cc: David Jones (MVP) davidjones@sportronics.com.au; Mention mention@noreply.github.com
Subject: Re: [dotnet/iot] Bmp280 Sensor gives wrong readings (#1027)

Since my sensor is apparently broken (or is incorrectly calibrated) I would be glad if @djaus2https://github.com/djaus2 could verify the fix. I have ordered a new one, but I'm not sure when this arives.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/dotnet/iot/issues/1027#issuecomment-607040796, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AC7U2EPBTAZEMPBFTVSWZQLRKLGJRANCNFSM4LUADORA.

All 14 comments

Here are my comparisons, without making the changes as above:
BMP180 on RPI-Raspian: 1014
BMP180 on RPI-IoT Core: 1014
BMP180 on Arduino Uno: 1022 (same sensor)
Local Weather Station (2km away approx same elevation): 1026

So for me the .Net Core version is only a little off.

That is a great find @pgrawehr, please feel free to submit a PR to fix this when you can 😄

Since my sensor is apparently broken (or is incorrectly calibrated) I would be glad if @djaus2 could verify the fix. I have ordered a new one, but I'm not sure when this arives.

Ok will do in next 24hrs

David Jones MVP


From: Patrick Grawehr notifications@github.com
Sent: Wednesday, April 1, 2020 4:28:56 PM
To: dotnet/iot iot@noreply.github.com
Cc: David Jones (MVP) davidjones@sportronics.com.au; Mention mention@noreply.github.com
Subject: Re: [dotnet/iot] Bmp280 Sensor gives wrong readings (#1027)

Since my sensor is apparently broken (or is incorrectly calibrated) I would be glad if @djaus2https://github.com/djaus2 could verify the fix. I have ordered a new one, but I'm not sure when this arives.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/dotnet/iot/issues/1027#issuecomment-607040796, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AC7U2EPBTAZEMPBFTVSWZQLRKLGJRANCNFSM4LUADORA.

Haven’t got to this yet…coming.

From: Patrick Grawehr notifications@github.com
Sent: Wednesday, 1 April 2020 4:29 PM
To: dotnet/iot iot@noreply.github.com
Cc: David Jones (MVP) davidjones@sportronics.com.au; Mention mention@noreply.github.com
Subject: Re: [dotnet/iot] Bmp280 Sensor gives wrong readings (#1027)

Since my sensor is apparently broken (or is incorrectly calibrated) I would be glad if @djaus2https://github.com/djaus2 could verify the fix. I have ordered a new one, but I'm not sure when this arives.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/dotnet/iot/issues/1027#issuecomment-607040796, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AC7U2EPBTAZEMPBFTVSWZQLRKLGJRANCNFSM4LUADORA.

I found the culpit (after the second, brand new sensor gave the exact same readings...). The sensor delivers absolute values at the place of measurement, but to get the equivalent barometer reading, one needs to correct this for the altitude at the point of measurement. Since I'm at 650m over sea, the difference is significant already. Applying a correction formula helped. So part of the problem is that #783 still is not merged.

Looking at this now. I now have a BME280

Got my BME280 going. On Arduino, the results were unreliable.
Using repository here unchanged (on IoT-Core) I got:

Temperature: 17.825904010126237 °C | Pressure: 1004.75109375 hPa | Altitude: 71.00071140779953 meters | Humidity: 41.98606668636412 %
-- | -- | -- | --
Temperature: 17.834190471133866 °C | Pressure: 1004.7931640625001 hPa | Altitude: 70.64805622817786 meters | Humidity: 41.96923838546106 %
Thermometer 18 |   |   | ^ NB; These sensor running indoors
  | Local Weather Station:  1009.7  (2km away) | GPSsays: 64m | Local Weather Station: 57%
  | Sea Level 15km away: 1010.3 |   |  

NB: This was redone.

With the Line 181 of Bmxx80Base.c modified as per above:

Temperature: 17.954344242107254 °C | Pressure: 1004.8240625 hPa | Altitude: 70.5845337247005 meters | Humidity: 40.167819101323936 %
-- | -- | -- | --
Temperature: 17.939683561131915 °C | Pressure: 1004.804375 hPa | Altitude: 70.55408235285238 meters | Humidity: 40.15090910070303 %
Thermometer 18 |   |   |  
  | Nb: App gives Sealevel Pressure as : 1013.25 |   |  

Nb; This was redone

So the effect of the fix is marginal, but I'll later push it anyway (together with an unit test for the Bmp280 calibration formula).
My main problem was actually the missing height reduction formula. I've just pushed an updated WeatherHelper PR that gives values more in the range of what I expect.

NB: I'm currently doing a port of DME280 to Azure Sphere based upon Seeed's version.

Got the DME280 working OK on the Az Sphere. Results are consistent with what I got as above.

Nice! I suppose you mean that is with the line that @pgrawehr suggested above. If that's the case can either you or @pgrawehr put up a PR to fix this issue on the binding?

Actually, I'm a bit confused, because I think I didn't really change anything (the parentheses on that line are extra-confusing). But I've done it together with an unit test and an improved calcuation formula (using doubles instead of fixed-point math). I can finish that PR pretty quickly, but I don't want to have to many PRs open at a time.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

matsujirushi picture matsujirushi  Â·  3Comments

krwq picture krwq  Â·  5Comments

Ellerbach picture Ellerbach  Â·  6Comments

pankaj-nikam picture pankaj-nikam  Â·  6Comments

krwq picture krwq  Â·  4Comments