Closed victors21 closed 4 years ago
thanks @caternuson do you have this chip?
@victors21 have you tested this with hardware? if so which?
@victors21 have you tested this with hardware? if so which?
Yep i have the chip and test it already works fine for me. Not sure about data accuracy but i am not need it very accurate. I am just to compare the data to get the way of changes.
kk what hardware did you test with?
Wemos D1 Mini(ESP8266) + SI1145 sensor + bme280 on the same bus sensor link https://ru.aliexpress.com/item/32823709540.html?spm=a2g0s.9042311.0.0.274233edJZOkur
@ladyada Sry, missed this. Yep - I have one of these.
@caternuson low priority! can add to yr list
@victors21 This modification is actually slowly happening to all of the Arduino libs as part of an ongoing effort. The boiler plate set of constructors is:
bool begin();
bool begin(TwoWire *theWire);
bool begin(uint8_t addr);
bool begin(uint8_t addr, TwoWire *theWire);
and you can reference this library as an example: https://github.com/adafruit/Adafruit_MCP9808_Library/blob/master/Adafruit_MCP9808.h#L56
Can you update to that style?
Also, just curious - why was this needed? The current library should work as is with the default wire as provided by the Arduino ESP8266 BSP.
@victors21 This modification is actually slowly happening to all of the Arduino libs as part of an ongoing effort. The boiler plate set of constructors is:
bool begin(); bool begin(TwoWire *theWire); bool begin(uint8_t addr); bool begin(uint8_t addr, TwoWire *theWire);
and you can reference this library as an example: https://github.com/adafruit/Adafruit_MCP9808_Library/blob/master/Adafruit_MCP9808.h#L56
Can you update to that style?
Also, just curious - why was this needed? The current library should work as is with the default wire as provided by the Arduino ESP8266 BSP.
Probably peoples want to use software i2c drivers cos of lack of pins on their devices with hardware i2c or they need 2 devices with the same address on the same project. Also my fix is same like u asked and can be use like begin() or begin(addres) or begin(address,TwoWire* bus). There has declared default parameters on it so all three calls is accaptable in this case.
Can you do this with the default parameter approach?
si1145.begin(some_wire_pointer);
Where you'd use the default address but supply a different I2C bus.
Can you do this with the default parameter approach?
si1145.begin(some_wire_pointer);
Where you'd use the default address but supply a different I2C bus.
Done, added one more call to make possible this way si1145.begin(some_wire_pointer);
@caternuson looks ok if it passes test can merge!
@victors21 what pins are you using for SDA/SCL?
@victors21 what pins are you using for SDA/SCL?
I was used hardware i2c pins on my ESP8266. Generaly when i review the code of Wire library and core code of arduino for Platform IO i was disappointed. Core code of arduino framework did not allow to use few i2c drivers at the same time cos of pin number variables, timer handler and buffer is only one for all calls. So this fix will useless for my case but probably can use at other platforms e.g ESP32.
#include "Adafruit_SI1145.h"
Adafruit_SI1145 uv = Adafruit_SI1145();
void setup() {
Serial.begin(9600);
Serial.println("Adafruit SI1145 test");
Wire.begin(2, 14);
if (!uv.begin(&Wire)) {
Serial.println("Didn't find Si1145");
while (1);
}
Serial.println("OK!");
}
void loop() {
Serial.print("Vis: "); Serial.print(uv.readVisible());
Serial.print(" IR: "); Serial.println(uv.readIR());
delay(1000);
}
thank you!
This fix is allow us to use software i2c or any other compatible instances of the i2c drivers which is derive from TwoWire