1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

driver/bmx280: increase accuracy of SAUL pressure readings

The SAUL implementation of the BMx280 currently returns the pressure in hPa.
The sensor, however, actually reads the pressure in Pa, leading to a
significant loss of precision.

Because the operation range of the BME280 and BMP280 is 300 hPa to 1100 hPa,
we can safely increase the precision by a factor of 10 without risk of overflow.
The only downside is that readings are now presented as `e1 Pa` (eg 10206e1 Pa).
This commit is contained in:
Silke Hofstra 2021-03-03 16:18:27 +01:00
parent bf93d85d4e
commit 3ca1162a6a

View File

@ -35,9 +35,11 @@ static int read_temperature(const void *dev, phydat_t *res)
static int read_pressure(const void *dev, phydat_t *res)
{
res->val[0] = bmx280_read_pressure((bmx280_t *)dev) / 100;
res->unit = UNIT_PA;
res->scale = 2;
res->scale = 0;
int32_t val = bmx280_read_pressure((bmx280_t *)dev);
phydat_fit(res, &val, 1);
return 1;
}