-2

urgently need some inputs,

Connection:

VCC-5v
GND-GND
SCL-SCL(analog pin 5)
SDA-SDA(analog pin 4)
ADD-NC or GND

Code pasted below used library from GIT : https://github.com/claws/BH1750

#include <BH1750.h>
#include <Wire.h>

BH1750 lightMeter;

void setup(){
    Serial.begin(9600);
    lightMeter.begin();
    Serial.println("Running...");
}

void loop() {
    uint16_t lux = lightMeter.readLightLevel();
    Serial.print("Light: ");
    Serial.print(lux);
    Serial.println(" lx");
    delay(1000);
}
1

There may be a regulator and logic shifter on the board you are using but according to the data sheet the device is a 3V device with 1.8V logic and I2C levels. So this is the first thing you need to check.

Have you got 4.7K resistors pulling the SDA and SCL lines to Vcc?

Can you change your code to turn the device off and then take a reading?

There is nothing wrong with your code, your wiring looks OK, so that implies that there is something wrong with the device or the Arduino. Change the device (and code) for another I2C device and see if that works fine. If it does then it looks like there might be a problem with the BH1750.

Hope that helps.

0

Looking at the BH1750.cpp and BH1750.h and I think i've noticed some errors:

  1. Change #include "Wire.h" to #include <Wire.h> in the header file, trivial perhaps but still...
  2. In the method BH1750::readLightLevel in the .cpp, comment out Wire.beginTransmission(BH1750_I2CADDR); and Wire.endTransmission();; they aren't needed for a Read and may be responsible for the wrong value you're getting.
  3. You can also try replacing _delay_ms(10); with delay(10), just in case
  4. You may also try commenting out level = level/1.2; just to see if this division has any adverse effects.

Save the files after making the changes.

0

I had to connect my SCL and SDA pins to dedicated 20th and 21st pins on Arduino MEGA 2560.

  • 1
    Please check that the OP is using an Arduino UNO as tagged on the question. – RSM Mar 18 '16 at 6:24
0

I bought some "GY-302" modules on ebay, it's a breakout board with the BH1750 sensor on it. I tried one of them and it didn't respond at all, like you I saw 54612 (which is just 65535/1.2). I tried another of these modules and it worked. So, on the one that didn't work, the sensor chip was not well aligned and centered, and the soldering looked ugly on one side, so I used my soldering iron to attempt to reflow and re-align/center it. If you attempt to do that too, clean your soldering tip and do not add any solder! Now the soldering looks even uglier (under microscope..), but the sensor is working well! I don't have any pro equipment, not even a small tip for my crappy soldering iron, so I guess I am lucky that it worked.

0

i didnt solder my light sensor and it had the same error, as it was just resting on the pins, try pushing it up so the sensor makes contacts with the male headers or just solder them :D

Not the answer you're looking for? Browse other questions tagged or ask your own question.