adafruit / Adafruit_BME280_Library

Arduino Library for BME280 sensors
Other
328 stars 301 forks source link

Addional I2C overloads to begin #62

Closed specialcircumstances closed 4 years ago

specialcircumstances commented 4 years ago

A couple of additional overloads to the bme.begin function to allow specification of SDA and SCL pins. I needed this for the library to work on my Digistump Oaks (ESP8266) with a Pimoroni BME280

ladyada commented 4 years ago

hiya - thanks for the PR. we wont merge as is, we only permit passing in an i2c Wire object - that's the standard procedure :) your board support package will have to allow creating Wire and then passing in the reference

specialcircumstances commented 4 years ago

hiya - thanks for the PR. we wont merge as is, we only permit passing in an i2c Wire object - that's the standard procedure :) your board support package will have to allow creating Wire and then passing in the reference

Ah - that's what I tried first - BUT - because your library calls the "begin" on the wire again, it overrides any SCL and SDA set on the original wire reverting to the compiler defaults. e.g. if I create a wire and Wire.begin(SCL, SDA) then pass that &Wire to your lib, init calls Wire.begin() which loses the SDA and SCL and reverts to default. I tested this Wire behaviour.

e.g. in Wire

void TwoWire::begin(void){ begin(default_sda_pin, default_scl_pin); }

ladyada commented 4 years ago

please tell the BSP supporters to add a function called, like, setPins() to Wire, because the official arduino Wire lirbary does not allow what they have added