Sensor.begin(byte addr) get stuck with hp_BH1750.h lib

Dear community,

I'm trying to read a light sensor (Adafruit BH1750) with a MKR ZERO board.
At this point the code is very straight forward and just willing to init the sensor.

I notice that sensor.begin() never returns a Boolean value and get stuck there.

#include <hp_BH1750.h>

hp_BH1750 sensor;

void setup()
{
  Serial.begin(9600);
  while (!Serial) {;}

  Serial.println("Start");
  
  bool avail = sensor.begin(BH1750_TO_GROUND); // set addr = 0x23 with Pin ADDR to ground
  Serial.println(avail);
  
  //sensor.start();
  
  Serial.println("End");
}

void loop()
{
}

Thanks in advance for whatever information.

Regards,

Gabriel

can you share how you wired and powered this up (circuit) ?

Unfortunately, is very straight forward.

Powered by USB and not the battery, though.

Thanks,

Gabriel

have you tried with 4.7KΩ pull-up resistors on SCL and SDA?

I tried with some 3k3 Ω, and without pull-ups too.
Do you think it will do to much of a difference?

the pull-up would do a difference for sure if you don't have any on your Arduino, not sure if 3K3 would be much different than 4K7.
do you have a Uno or another Arduino to check if the sensor does work fine ?

I just tried with a Arduino Nano 33 IoT but the behavior is exactly the same. :thinking:

Those are « modern » arduino
I wonder if there is an I2C challenge and so having an old (uno or mega ) test would help

Good call,

I don't have other arduinos to try, but I might have a way to test the I2C protocol itself.

It might take me a few days though.

Hey @J-M-L,

I manage to get my hands on an Arduino Uno SMD, but the same result.

Maybe the sensor board is broken? :thinking:

that's indeed a possibility !

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.