From 974d738212145f451bdf9b8a7ac6474ee0f8225c Mon Sep 17 00:00:00 2001 From: 1technophile Date: Sat, 11 Nov 2017 13:36:24 +0100 Subject: [PATCH] remove wire.begintransmission and end as there is no writing #89 --- ZsensorBH1750.ino | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/ZsensorBH1750.ino b/ZsensorBH1750.ino index 57288d9..3ae7890 100644 --- a/ZsensorBH1750.ino +++ b/ZsensorBH1750.ino @@ -64,16 +64,13 @@ void MeasureLightIntensity() float Wattsm2; // Check if reads failed and exit early (to try again). - Wire.beginTransmission(BH1750_i2c_addr); Wire.requestFrom(BH1750_i2c_addr, 2); - while(Wire.available()) // - { - i <<=8; - i|= Wire.read(); - } - if (Wire.endTransmission() != 0 ) { + if(Wire.available() != 2) { trc(F("Failed to read from LightSensor BH1750!")); }else{ + i = Wire.read(); + i <<=8; + i |= Wire.read(); // Calculate the Values Lux = i/1.2; // Convert to Lux