kopia lustrzana https://github.com/robert-hh/BME280
bme280*.py: Clamp the humidity results in the range 0-100 %.
The sensor may deliver values slightly out of range. Signed-off-by: robert-hh <robert@hammelrath.com>master
rodzic
f1e555b2cd
commit
6c0b723039
|
@ -201,7 +201,10 @@ class BME280:
|
|||
(self.dig_H2 / 65536.0 * (1.0 + self.dig_H6 / 67108864.0 * h *
|
||||
(1.0 + self.dig_H3 / 67108864.0 * h))))
|
||||
humidity = h * (1.0 - self.dig_H1 * h / 524288.0)
|
||||
# humidity = max(0, min(100, humidity))
|
||||
if (humidity < 0):
|
||||
humidity = 0
|
||||
if (humidity > 100):
|
||||
humidity = 100.0
|
||||
|
||||
if result:
|
||||
result[0] = temp
|
||||
|
|
|
@ -207,6 +207,10 @@ class BME280:
|
|||
h = 0 if h < 0 else h
|
||||
h = 419430400 if h > 419430400 else h
|
||||
humidity = h >> 12
|
||||
if humidity < 0:
|
||||
humidity = 0
|
||||
if humidity > 100 * 1024:
|
||||
humidity = 100 * 1024
|
||||
|
||||
if result:
|
||||
result[0] = temp
|
||||
|
|
Ładowanie…
Reference in New Issue