Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. BH1750 library hangs

BH1750 library hangs

Scheduled Pinned Locked Moved Troubleshooting
20 Posts 2 Posters 3.3k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J João Gouveia

    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.

    0_1522680160710_IMG_20180402_163933.jpg

    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.

    alexsh1A Offline
    alexsh1A Offline
    alexsh1
    wrote on last edited by alexsh1
    #8

    @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.

    J 1 Reply Last reply
    0
    • alexsh1A alexsh1

      @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.

      J Offline
      J Offline
      João Gouveia
      wrote on last edited by
      #9

      @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.

      alexsh1A 1 Reply Last reply
      0
      • J João Gouveia

        @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.

        alexsh1A Offline
        alexsh1A Offline
        alexsh1
        wrote on last edited by alexsh1
        #10

        @joão-gouveia OK, if i2c wiring is fine, load up i2c scanner and see if you can read the sensor address.

        J 1 Reply Last reply
        0
        • alexsh1A alexsh1

          @joão-gouveia OK, if i2c wiring is fine, load up i2c scanner and see if you can read the sensor address.

          J Offline
          J Offline
          João Gouveia
          wrote on last edited by
          #11

          @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.

          alexsh1A 1 Reply Last reply
          0
          • J João Gouveia

            @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.

            alexsh1A Offline
            alexsh1A Offline
            alexsh1
            wrote on last edited by alexsh1
            #12

            @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.

            J 1 Reply Last reply
            0
            • alexsh1A alexsh1

              @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.

              J Offline
              J Offline
              João Gouveia
              wrote on last edited by
              #13

              @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.

              alexsh1A 1 Reply Last reply
              0
              • J João Gouveia

                @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.

                alexsh1A Offline
                alexsh1A Offline
                alexsh1
                wrote on last edited by
                #14

                @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.

                J 1 Reply Last reply
                1
                • alexsh1A alexsh1

                  @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.

                  J Offline
                  J Offline
                  João Gouveia
                  wrote on last edited by
                  #15

                  @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. :)

                  alexsh1A 1 Reply Last reply
                  0
                  • J João Gouveia

                    @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. :)

                    alexsh1A Offline
                    alexsh1A Offline
                    alexsh1
                    wrote on last edited by
                    #16

                    @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):

                    https://www.aliexpress.com/item/1PCS-FT232RL-Serial-adapter-Module-USB-to-TTL-3-3V-5V-Mini-USB-TTL/32326225256.html?ws_ab_test=searchweb0_0,searchweb201602_1_10152_10151_10065_10344_10130_10068_10324_10342_10547_10325_10343_10340_10548_10341_10697_10696_10192_10190_10084_10083_10618_10307_10301_10303_10059_10184_10534_100031_10103_441_10624_10623_10622_10621_10620,searchweb201603_25,ppcSwitch_5&algo_expid=1d05e7ee-d1d0-4628-b1ab-56fd947c7eb0-2&algo_pvid=1d05e7ee-d1d0-4628-b1ab-56fd947c7eb0&transAbTest=ae803_2&priceBeautifyAB=0

                    J 2 Replies Last reply
                    0
                    • alexsh1A alexsh1

                      @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):

                      https://www.aliexpress.com/item/1PCS-FT232RL-Serial-adapter-Module-USB-to-TTL-3-3V-5V-Mini-USB-TTL/32326225256.html?ws_ab_test=searchweb0_0,searchweb201602_1_10152_10151_10065_10344_10130_10068_10324_10342_10547_10325_10343_10340_10548_10341_10697_10696_10192_10190_10084_10083_10618_10307_10301_10303_10059_10184_10534_100031_10103_441_10624_10623_10622_10621_10620,searchweb201603_25,ppcSwitch_5&algo_expid=1d05e7ee-d1d0-4628-b1ab-56fd947c7eb0-2&algo_pvid=1d05e7ee-d1d0-4628-b1ab-56fd947c7eb0&transAbTest=ae803_2&priceBeautifyAB=0

                      J Offline
                      J Offline
                      João Gouveia
                      wrote on last edited by
                      #17

                      @alexsh1 Thanks I will check it out and give it a try! :) I'll let you know the results

                      1 Reply Last reply
                      0
                      • alexsh1A alexsh1

                        @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):

                        https://www.aliexpress.com/item/1PCS-FT232RL-Serial-adapter-Module-USB-to-TTL-3-3V-5V-Mini-USB-TTL/32326225256.html?ws_ab_test=searchweb0_0,searchweb201602_1_10152_10151_10065_10344_10130_10068_10324_10342_10547_10325_10343_10340_10548_10341_10697_10696_10192_10190_10084_10083_10618_10307_10301_10303_10059_10184_10534_100031_10103_441_10624_10623_10622_10621_10620,searchweb201603_25,ppcSwitch_5&algo_expid=1d05e7ee-d1d0-4628-b1ab-56fd947c7eb0-2&algo_pvid=1d05e7ee-d1d0-4628-b1ab-56fd947c7eb0&transAbTest=ae803_2&priceBeautifyAB=0

                        J Offline
                        J Offline
                        João Gouveia
                        wrote on last edited by
                        #18

                        @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.

                        alexsh1A 1 Reply Last reply
                        0
                        • J João Gouveia

                          @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.

                          alexsh1A Offline
                          alexsh1A Offline
                          alexsh1
                          wrote on last edited by
                          #19

                          @joão-gouveia The problem is very often much simpler than we think :-)

                          J 1 Reply Last reply
                          0
                          • alexsh1A alexsh1

                            @joão-gouveia The problem is very often much simpler than we think :-)

                            J Offline
                            J Offline
                            João Gouveia
                            wrote on last edited by
                            #20

                            @alexsh1 Very true :) Anyways, thanks for the tips!

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            30

                            Online

                            11.7k

                            Users

                            11.2k

                            Topics

                            113.1k

                            Posts


                            Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • MySensors
                            • OpenHardware.io
                            • Categories
                            • Recent
                            • Tags
                            • Popular