You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
iio: dht11: Improve detection of sensor type
The old code was based on a DHT11 datasheet which specifies a measurement range of 20%-90% RH. Turns out the sensor actually reports values outside this range, so we should support it as far as possible. Reported-by: Edward Attfield <edward@attfield.ca> Signed-off-by: Harald Geyer <harald@ccbib.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
committed by
Jonathan Cameron
parent
7fe2241c0e
commit
a6bffb6920
@@ -159,7 +159,7 @@ static int dht11_decode(struct dht11 *dht11, int offset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
dht11->timestamp = ktime_get_boot_ns();
|
dht11->timestamp = ktime_get_boot_ns();
|
||||||
if (hum_int < 20) { /* DHT22 */
|
if (hum_int < 4) { /* DHT22: 100000 = (3*256+232)*100 */
|
||||||
dht11->temperature = (((temp_int & 0x7f) << 8) + temp_dec) *
|
dht11->temperature = (((temp_int & 0x7f) << 8) + temp_dec) *
|
||||||
((temp_int & 0x80) ? -100 : 100);
|
((temp_int & 0x80) ? -100 : 100);
|
||||||
dht11->humidity = ((hum_int << 8) + hum_dec) * 100;
|
dht11->humidity = ((hum_int << 8) + hum_dec) * 100;
|
||||||
|
|||||||
Reference in New Issue
Block a user