From: Tomasz Duszynski <tomasz.duszynski@octakon.com>
To: Hendrik Hoeth <hendrik.hoeth@air-avionics.com>
Cc: Jonathan Cameron <jic23@kernel.org>, <linux-iio@vger.kernel.org>
Subject: Re: BME-280 humidity over-/underflow
Date: Wed, 10 Jun 2020 17:26:50 +0200 [thread overview]
Message-ID: <20200610152650.GA8925@arch> (raw)
In-Reply-To: <20200610134507.GT2681@linta.de>
Hello Hendrik,
On Wed, Jun 10, 2020 at 03:45:07PM +0200, Hendrik Hoeth wrote:
> Hi,
>
> I've discovered an over-/underflow problem for relative humidity
> measurements in drivers/iio/pressure/bmp280-core.c. At very low
> humidities the value measured by the sensor can fluctuate into the
> negative humidity range. The kernel driver then reports this as
> extremely large value (e.g. 4193085, corresponding to 4193% RH). The
> same probably happens at high humidity values, but with our climate
> chamber I was only able to look at the low end.
>
> To avoid this, the reference code in the BME-280 datasheet catches
> values < 0% RH and > 100% RH. These two lines are currently missing in
> the kernel driver.
>
> Attached you find a patch that fixed the problem for us. You can find
> the sensor datasheet at
> https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BME280-DS002.pdf
> The code I'm talking about is in section 4.2.3 on page 25/26.
>
> Thanks a lot,
>
> Hendrik
Seems this particular issue has been already fixed here:
dee2dabc0e4115b80945fe2c91603e634f4b4686 iio: bmp280: fix compensation of humidity
>
> --
> Garrecht Avionik GmbH | Wieslocher Str. 38 | 69190 Walldorf
> https://www.air-avionics.com/
> Tel.: +49 6224 98 96 999
> Fix underflow / overflow for humidity measurements
>
> diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
> index 29c209cc1108..d1f36b044f05 100644
> --- a/drivers/iio/pressure/bmp280-core.c
> +++ b/drivers/iio/pressure/bmp280-core.c
> @@ -270,6 +270,8 @@ static u32 bmp280_compensate_humidity(struct bmp280_data *data,
> * (((var * (s32)calib->H3) >> 11) + (s32)32768)) >> 10)
> + (s32)2097152) * calib->H2 + 8192) >> 14);
> var -= ((((var >> 15) * (var >> 15)) >> 7) * (s32)calib->H1) >> 4;
> + var = ((var < 0) ? 0 : var);
> + var = ((var > 419430400) ? 419430400 : var);
>
> return var >> 12;
> };
next prev parent reply other threads:[~2020-06-10 15:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-10 13:45 BME-280 humidity over-/underflow Hendrik Hoeth
2020-06-10 15:26 ` Tomasz Duszynski [this message]
2020-06-10 15:54 ` Hendrik Hoeth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200610152650.GA8925@arch \
--to=tomasz.duszynski@octakon.com \
--cc=hendrik.hoeth@air-avionics.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.