adafruit / Adafruit_ADS1X15

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

Overloaded begin() method with a new version allowing to set custom I… #28

Closed jsolla closed 3 years ago

jsolla commented 6 years ago

…2C sda/scl pins

Updated Adafruit_ADS1015.cpp and Adafruit_ADS1015.h in order to include a new overloaded begin() method.

The new method allows to use custom GPIO pins instead of enforcing the default ones on the TWI library.

Now you can use custom pins like this:

int sdaPin=2; int sclPin=4; ads.begin(sdaPin, sclPin);

Tested on a ESP8266 board, but as it uses standard Wire library method, it shouldn't be an issue for other boards.

soligen2010 commented 6 years ago

I just wanted to chime in here to let you know few things.

I have a fork of this library where I have collected and applied good updates from other contributors as well as my own enhancements to the library. This version more fully supports the chip and works more reliably with clone chips. This change you have done I have already done to my fork.

Sorry you made this change which was already done. You can check out my fork at https://github.com/soligen2010/Adafruit_ADS1X15. Search the code for ESP8266 to see how I added support for it.

If you have any other enhancements, fee free to submit them to my fork.

jsolla commented 6 years ago

Good to know. I will just use your fork instead. Thanks for the info!

caternuson commented 3 years ago

Should be able to do something like this with #58. Instead of passing in pins, you pass in an I2C bus instance. That bus instance would have been created using whatever pins.