-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BH1750] Device is not configured! #36
Comments
That error gets reported from The typical usage of this library is: #include <BH1750.h>
BH1750 lightMeter;
void setup(){
lightMeter.begin();
}
void loop() {
uint16_t lux = lightMeter.readLightLevel();
} My best guess would be that perhaps you are not calling The serial output you pasted does not look like any of the examples. Was this output from an example? |
@claws I am having the exact same problem... Here is my code: #include <Wire.h> BH1750 lightMeter(0x23); void setup(){ Serial.begin(9600); Wire.begin(); lightMeter.begin(); } void loop() { uint16_t lux = lightMeter.readLightLevel(); } |
I just found that the 12C scanner cannot find the device |
It looks like you have wired it up correctly from the pictures. The BH1750 library returns a boolean value from
When I run the i2c_scanner you mentioned I see the following output:
I'm going to guess that perhaps your sensor device is faulty. Do you have access to another to test this out? I have just run all three of the examples on 2 separate sensor devices and they work as I expect.
You could remove the wire connect ADD to GND. It is not required. The library uses the i2c address of 0x23 by default. I see you were explicitly defining the device address as 0x23 and wiring the ADD line to ground. That is fine and explicit. The same configuration would be achieved by not wiring the ADD line at all and not explicitly passing 0x23 when instantiating the lightMeter - such as in the simple example. |
I modified my setup function to initialise the lightmeter as you have stated and it returns: Yeah, the light sensor is probably faulty. I have ordered another one which should arrive Friday. Meanwhile I will have to hope that the code i have written, to include the device in my project, is correct as I have no way of testing it until the sensor arrives :-/ Thanks for your help and the speedy reply! Would you be willing to look over my project code to see if it makes sense? It would be really helpful as I am very new to using arduino. Although I understand if you don't want to or do not have time to. |
@EdrickeAPM I have the exact same issue .. have you fixed it yet? :) |
@priema @EdrickeAPM Do you tried another I2C device? Maybe the cable are not in a good shape. |
I have the exact same issue .. have you a better fix? thx |
@dvbahder No. Has your sensor worked in the past? |
no, I bought the sensor three weeks ago. OneWire DS18B20 works, wire DHT22 works, Display I2C works, as a single sensor BH1750 does not work, I read from a scanner for I2C and want to try it tomorrow. I'll let you know. thx to coelner |
what is the purpose for adding readLightLevel (true)? |
Line 63 in 68afd58
It activates a different delay value for the measurement. This value is maximum wait value and the sensor will have a new measurement ready to deliver. |
The code works: Wemos D1 mini Then I uploaded the ESPeasy firmware and sensor works fine, print lux info in serial console. Sorry for my poor english! |
|
|
|
|
Some new test logs: Wemos D1 Pro (ESPEasy) Wemos D1 Pro (BH1750test.ino example sketch from this library) |
There is a problem with i2c in a generic way. wrong settings in the ide, wrong parameter in the toolchain, It is not a problem of this library. You could use a logic analyzer to research this issue. |
I somewhat managed to fix this by wire.begin(D1, D2) |
@quintendewilde Some more infos about the board, wiring and sketch? |
hi, I have the similar issue and try above method but not work for me.
I only connect a GY-302 (BH1750) sensor. and this is the result |
Which version of this library do you use? Did you verify the wiring with another library or atl east a i2c scan? |
Thanks for your answer!
I'm Sorry with so many question and very thanks for your help again. Thanks. |
My esp32 works fine with this library. Make very SURE that the pins are soldered properly. |
|
@coelner @IoTThinks Thanks for your answers!!!!! I learn a lot from you guys, thank you. |
In my case it was very weird. I had the same issue but connecting ir to 5v instead of 3.3v do the trick. |
[Solved] After changing new wires the example worked fine. Thanks for your code. It took me hours to figure out |
|
Yep, you usually need the same VCC. The VCC defines the level thresholds of thr i2c bus and if you do not use a level shifter you are limited to a common VCC. (Voltage at the common collector ) |
[Solved] I see BH1750advanced.ino that code: Full mode list: BH1750_CONTINUOUS_LOW_RES_MODE BH1750_ONE_TIME_LOW_RES_MODE // begin returns a boolean that can be used to detect setup problems. I think we have to use MODE in lightMeter.begin() . And, in case WEMOS D1 R1 board (Arduino type) I use but, I use GPIO pins numbers in the sketch. So: Wire.begin(4, 5); Because at the WEMOS D1 R1 board (Arduino type) |
i am getting this in serial monitor
t: 0 lx
BH1750 Test
[BH1750] Device is not configured!
The text was updated successfully, but these errors were encountered: