claws / BH1750

An Arduino library for the digital light sensor breakout boards containing the BH1750FVI IC
MIT License
248 stars 107 forks source link

[BH1750] Set address _after_ constructor #60

Closed bjarnebuchmann closed 4 years ago

bjarnebuchmann commented 4 years ago

Dear Wizards/@claws,

Presently, the device address (0x23/0x5C) have to be known/set with the constructor, ie. before the setup() call. This pretty much means that it must be hard-coded in the program.

If the same software is to be used on (slightly) different hardware configurations, then it might be convenient that the address can be set during the setup() phase - presumably after an i2c-scan or whatever, where the available addresses can be probed.

As it is now, I must create two instances of the object, as per eg:

BH1750 lightMeter1((byte) 0x23);
BH1750 lightMeter2((byte) 0x5C);

void setup() {
 ...
  lightMeter1.begin() || Serial.println("LIGHT1 not configured");
  lightMeter2.begin() || Serial.println("LIGHT2 not configured");
...
}

Thanks for a good library. /Bjarne

coelner commented 4 years ago

50 should solve your problem