BH1750 library hangs
-
I have tried with both a GY-302 and a GY-30 and both don't work although they show different problems (mentioned on my OP). Both the sensors work well when connected to the pi.
I don't have a drawing of the circuit but I can show you a picture, if it helps.

The diagram is essential like this one but without the temperature sensor and I am currently using an FTDI board to provide the power, instead of a battery.
The SCL is connected to A5 and the SDA to A4 of the mini pro.
I can also do a drawing, if further info is required but, as I said, it is like the one I linked above.
@joão-gouveia hard to tell. I spent days trying to troubleshoot the connectivity problem and it turned out to be a bad nrf24l01+. Just to make sure - you have no RF issues? Pro Mini is talking to RPi no problem?
Another possible issue is I2C - this is why it is freezing on Wire.begin(); Double check wiring just in case. (SDA and SDL correctly connected?). You can also use an example sketch to scan i2c bus. You may need to update the lib with the correct address.
If both sensors are working with RPi, this eliminates them.
-
@joão-gouveia hard to tell. I spent days trying to troubleshoot the connectivity problem and it turned out to be a bad nrf24l01+. Just to make sure - you have no RF issues? Pro Mini is talking to RPi no problem?
Another possible issue is I2C - this is why it is freezing on Wire.begin(); Double check wiring just in case. (SDA and SDL correctly connected?). You can also use an example sketch to scan i2c bus. You may need to update the lib with the correct address.
If both sensors are working with RPi, this eliminates them.
@alexsh1 There doesn't seem to be no RF issues, no. The freezing occurs on Wire.endTransmition(), not begin. I meant the begin function of the BH1750 library from MySensors, sorry if that wasn't very clear.
SDA and SDL seem to be connected correcly. I've checked that a few times now.
-
@alexsh1 There doesn't seem to be no RF issues, no. The freezing occurs on Wire.endTransmition(), not begin. I meant the begin function of the BH1750 library from MySensors, sorry if that wasn't very clear.
SDA and SDL seem to be connected correcly. I've checked that a few times now.
@joão-gouveia OK, if i2c wiring is fine, load up i2c scanner and see if you can read the sensor address.
-
@joão-gouveia OK, if i2c wiring is fine, load up i2c scanner and see if you can read the sensor address.
@alexsh1 I ran this example: https://playground.arduino.cc/Main/I2cScanner (I'm not sure if this is what you meant).
It seems to hang on Wire.endTransmition() it prints the string "Scanning..." but nothing else.
-
@alexsh1 I ran this example: https://playground.arduino.cc/Main/I2cScanner (I'm not sure if this is what you meant).
It seems to hang on Wire.endTransmition() it prints the string "Scanning..." but nothing else.
@joão-gouveia Yes, that's what I meant. OK, here we go - this is an i2c problem. I am shooting a bit in the dark here - how about trying to change your power source? Maybe a different 3.3V FTDI adapter.
-
@joão-gouveia Yes, that's what I meant. OK, here we go - this is an i2c problem. I am shooting a bit in the dark here - how about trying to change your power source? Maybe a different 3.3V FTDI adapter.
@alexsh1 Hm that seems reasonable. The FTDI board I have seems to be a bit funky it gives a lot of errors when I am trying to upload sometimes. Could that be related? I am not sure if it is the FTDI or the mini pro itself though.
I don't have another type with me though.
-
@alexsh1 Hm that seems reasonable. The FTDI board I have seems to be a bit funky it gives a lot of errors when I am trying to upload sometimes. Could that be related? I am not sure if it is the FTDI or the mini pro itself though.
I don't have another type with me though.
@joão-gouveia A good a reliable power source is a key unless you what to spend hours troubleshooting. Yes, FTDI could be the reason when used as a power source.
Another thing to try is to load an example sketch for BH1750, disconnect the FTDI adapter and use 2xAA batteries to power up your schematic. Then you can check your controller for a log. Unfortunately, you cannot check the log on the node.
-
@joão-gouveia A good a reliable power source is a key unless you what to spend hours troubleshooting. Yes, FTDI could be the reason when used as a power source.
Another thing to try is to load an example sketch for BH1750, disconnect the FTDI adapter and use 2xAA batteries to power up your schematic. Then you can check your controller for a log. Unfortunately, you cannot check the log on the node.
@alexsh1 I think I will try to get a more reliable FTDI since this one seems to give me some troubles. It also isn't properly detected on my PC sometimes. Is there a reliable one I could get from, for example, aliexpress, you recommend? My knowledge on these is close to zero, hahaha. Thanks. :)
-
@alexsh1 I think I will try to get a more reliable FTDI since this one seems to give me some troubles. It also isn't properly detected on my PC sometimes. Is there a reliable one I could get from, for example, aliexpress, you recommend? My knowledge on these is close to zero, hahaha. Thanks. :)
@joão-gouveia I would highly recommend Adafruit FTDI :
https://www.adafruit.com/product/284
Expensive, yes, but I modified with two switches - 3.3V-5V power and 3.3v-5V logic level.
Alternatively, you can try a few cheap Aliexpress ones like this one (make sure it is a genuine FTDI chip):
-
@joão-gouveia I would highly recommend Adafruit FTDI :
https://www.adafruit.com/product/284
Expensive, yes, but I modified with two switches - 3.3V-5V power and 3.3v-5V logic level.
Alternatively, you can try a few cheap Aliexpress ones like this one (make sure it is a genuine FTDI chip):
@alexsh1 Thanks I will check it out and give it a try! :) I'll let you know the results
-
@joão-gouveia I would highly recommend Adafruit FTDI :
https://www.adafruit.com/product/284
Expensive, yes, but I modified with two switches - 3.3V-5V power and 3.3v-5V logic level.
Alternatively, you can try a few cheap Aliexpress ones like this one (make sure it is a genuine FTDI chip):
@alexsh1 I just realized my full blown stupidity. The breadboard I am using has the buses connected half way and I was convinced they were fully connected. So the light sensor was not getting power, obviously. :man-facepalming: :man-facepalming: :man-facepalming: :man-facepalming: :sweat_smile: :sweat_smile: :sweat_smile: :sweat_smile:
It works now.
-
@alexsh1 I just realized my full blown stupidity. The breadboard I am using has the buses connected half way and I was convinced they were fully connected. So the light sensor was not getting power, obviously. :man-facepalming: :man-facepalming: :man-facepalming: :man-facepalming: :sweat_smile: :sweat_smile: :sweat_smile: :sweat_smile:
It works now.
@joão-gouveia The problem is very often much simpler than we think :-)
-
@joão-gouveia The problem is very often much simpler than we think :-)
@alexsh1 Very true :) Anyways, thanks for the tips!