From b33fa68c0101c79f3d06b70903c72573a8f03323 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 5 Apr 2020 11:52:02 +0200 Subject: [PATCH] Fix BH1750 MT lux calculation Fix BH1750 MT lux calculation (#8057) --- tasmota/xsns_10_bh1750.ino | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tasmota/xsns_10_bh1750.ino b/tasmota/xsns_10_bh1750.ino index 1ba00b46e..a098166df 100644 --- a/tasmota/xsns_10_bh1750.ino +++ b/tasmota/xsns_10_bh1750.ino @@ -76,11 +76,12 @@ bool Bh1750Read(void) if (Bh1750.valid) { Bh1750.valid--; } if (2 != Wire.requestFrom(Bh1750.address, (uint8_t)2)) { return false; } - Bh1750.illuminance = (Wire.read() << 8) | Wire.read(); - Bh1750.illuminance /= (1.2 * (69 / Bh1750.mtreg)); + float illuminance = (Wire.read() << 8) | Wire.read(); + illuminance /= (1.2 * (69 / (float)Bh1750.mtreg)); if (1 == Settings.SensorBits1.bh1750_resolution) { - Bh1750.illuminance >>= 1; + illuminance /= 2; } + Bh1750.illuminance = illuminance; Bh1750.valid = SENSOR_MAX_MISS; return true;