Open Zontex opened 3 years ago
Thanks for the feedback, I'll look into it when I get some time.
@claws I don't see anything special here. we could test in the configure() method whether the chip respond to 0x5C address or not. But this does not have an ID register to identify this chip. Edit: I see maybe the issue
https://github.com/claws/BH1750/blob/38e9f378e07f0740f80a9a7700377ecdddcc7836/src/BH1750.cpp#L49
this is maybe the fault: we overwrite it:
https://github.com/claws/BH1750/blob/38e9f378e07f0740f80a9a7700377ecdddcc7836/src/BH1750.h#L63
bool begin(Mode mode = CONTINUOUS_HIGH_RES_MODE, byte addr = BH1750_I2CADDR,
But do we need the address as a parameter for the begin() method?
If the sensor accepts a changed address we can keep it in the begin()
, if it doesn't we should use the address only at declaration time.
But in general I assume that a sensor is fixed to a specific address through the pcb. I see no benefit from changing the address via gpio, because in most cases this sensor is attached to a specific I2C bus. There shouldn't be a problem with a sudden address conflict, should it? @claws
The sensor allows an address change while running.
something like this, but use the addr from the constructor as default parameter:
begin(Mode mode = CONTINUOUS_HIGH_RES_MODE, byte addr = BH1750_I2CADDR, TwoWire* i2c = nullptr);
https://www.fluentcpp.com/2018/08/17/dependent-default-parameters/
Hi All, So I've seen people having this issue "device not configured" for me, I know it's not hardware issue because I've been running MicroPython without a problem and the BH1750 sensor is soldered to a custom PCB I've made.
The address in my case is 0x5C I've tried to change it "softly" it didn't work, changed the source files didn't work till I found a fix by looking into one of the advanced examples.
After changing lightMeter.begin() with the following:
lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE, 0x5C, &Wire);
It fixed my problem, the sensor is working perfectly fine now. I have no idea why as I'm a Python not C or C++ Programmer but would love the author @claws to take a look over it and see if can find the issue.
I've spent about 25 minutes trying to re-solve the problem till I came with this solution, hope it can save some time for others as well that having the same issue as me.
Complete code: