adafruit / Adafruit_ADS1X15

Driver for TI's ADS1015: 12-bit Differential or Single-Ended ADC with PGA and Comparator
Other
289 stars 301 forks source link

Added support for 400 kHz I2C #78

Closed matthewlai closed 2 years ago

matthewlai commented 2 years ago

Added support for 400 kHz (fast mode) I2C since 100 kHz I2C is the bottleneck for fast conversions.

caternuson commented 2 years ago

Should be able to do this by calling setClock on the Wire instance used. Ex:

#include <Adafruit_ADS1X15.h>

Adafruit_ADS1115 ads;

void setup() {
  Wire.setClock(400000);
  ads.begin();
}

void loop() {
}
matthewlai commented 2 years ago

Wouldn't the speed be overwritten when Adafruit_I2CDevice::begin() calls Wire::begin()? https://github.com/adafruit/Adafruit_BusIO/blob/512fde07b58fc99cef7a90c1b3e682a13738eee7/Adafruit_I2CDevice.cpp#L29

I'm not too familiar with Arduino. If it doesn't and you feel that's a better way, feel free to close this :).

ladyada commented 2 years ago

ads.begin(); Wire.setClock(400000);

would work jsut fine - its probably a better way

matthewlai commented 2 years ago

That does seem like a cleaner way, given the speed is a property of the bus not the device. I'll close this.