Fix BH1750 illuminance formula

Fix BH1750 illuminance formula (#16022)
This commit is contained in:
Theo Arends 2022-07-20 11:11:18 +02:00
parent 722406a461
commit 79161d3c43
2 changed files with 4 additions and 5 deletions

View File

@ -17,13 +17,12 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Example Command: modbussend {"deviceaddress": 1, "functioncode": 3, "startaddress": 1, "type":"uint8", "count":4}
*/
#ifdef USE_MODBUS_BRIDGE
/*********************************************************************************************\
* Modbus Bridge using Modbus library (TasmotaModbus)
*
* Example Command:
* ModbusSend {"deviceaddress": 1, "functioncode": 3, "startaddress": 1, "type":"uint8", "count":4}
\*********************************************************************************************/
#define XDRV_63 63

View File

@ -101,7 +101,7 @@ bool Bh1750Read(uint32_t sensor_index) {
if (2 != Wire.requestFrom(Bh1750_sensors[sensor_index].address, (uint8_t)2)) { return false; }
float illuminance = (Wire.read() << 8) | Wire.read();
illuminance /= (1.2 * (69 / (float)Bh1750_sensors[sensor_index].mtreg));
illuminance *= 57.5 / (float)Bh1750_sensors[sensor_index].mtreg; // Fix #16022
if (1 == Bh1750Resolution(sensor_index)) {
illuminance /= 2;
}