claws / BH1750

An Arduino library for the digital light sensor breakout boards containing the BH1750FVI IC
MIT License
249 stars 108 forks source link

Keep Returning 0 Value #37

Closed briantstev closed 6 years ago

briantstev commented 6 years ago

Dear Friend,

I have an issue with your library.

screen shot 2018-01-10 at 17 04 30

It keep returning 0 from sensor value. I copy and paste your code. Also already put your library file in place.

Any advice will be so helpful.

Thank you

claws commented 6 years ago

I have installed the library freshly into Arduino 1.8.5 then I cut and pasted the example from the README as you say you did. I am unable to replicate the problem you are seeing. I see:

BH1750 Test
Light: 23 lx
Light: 23 lx
Light: 23 lx

Today I updated the library to report more error information to the serial interface. This might help diagnose the problem you are having. Could you update to the latest version (i.e. remove the existing BH1750 library from {Arduino Path}/libraries, re-download it and re-install it) and then re-test?

Can you also provide any more information such as what platform (e.g. Win, OSX, Linux) you are running on, and exactly what code you are running?

briantstev commented 6 years ago

It is very kind of you sir, please give me a moment to try it first, and let us see.

briantstev commented 6 years ago

Hi mr. Claws.

Very sorry for late response. After further read on previous issues, I might think this is simply bad sensors.

So, I end up (1) buying some new other light sensors like you use GY30, (2) update my Arduino IDE to 1.8.5, previously 1.8.4. (3) test several boards. (4) Copy and paste your example README. (5) I use OSX environment

Here are some photo that might help you to help me out :)

p.s different photo, different light sensor. 316 317 318 319

screen shot 2018-01-13 at 13 38 02 screen shot 2018-01-13 at 13 38 10 screen shot 2018-01-13 at 13 41 19 screen shot 2018-01-13 at 13 45 39
briantstev commented 6 years ago

Mr. Claws,

Please give me more time to check on several boards and other type of light sensors like GY302

I'll update soon

briantstev commented 6 years ago

Mr. Claws,

Your update works like a charm!

It works, and I can't be more happier tonight :)

Thank you, you are The Light Sensor Library Legend! hehehe

380 381

screen shot 2018-01-14 at 00 18 42 screen shot 2018-01-14 at 00 19 36
claws commented 6 years ago

Glad to hear it is working for you.

Guihgo commented 2 years ago

Try begin module at mode ONE_TIME_HIGH_RES_MODE

if (!lightMeter.begin(BH1750::ONE_TIME_HIGH_RES_MODE))
    {
        Serial.println(F("Could not find a valid BH1750 sensor, check wiring!"));
        has_lightSensor = false;
    }