Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Adafruit_ADS1X15 dependency to Adafruit's v2 #456

Open
aufdenkampe opened this issue Nov 22, 2023 · 5 comments
Open

Change Adafruit_ADS1X15 dependency to Adafruit's v2 #456

aufdenkampe opened this issue Nov 22, 2023 · 5 comments

Comments

@aufdenkampe
Copy link
Member

aufdenkampe commented Nov 22, 2023

This is a key library for TI's popular Analog to Digital Converter (ADC) used in the Mayfly and many other boards.

Back in 2019 (or earlier), @SRGDamia1 decided to use this fork of Adafruit's library because it fixed some key bugs, and Adafruit wasn't accepting a pull requests to fix it (see #235 (comment)):

However, since then, Adafruit has renewed active development and issued a series of v2.x releases (with breaking changes).

Adafruit's v2.4.2 is now 61 commits ahead of soligen2010, and is being actively pushed to PlatformIO's Library Registry:

The major issue is that code developed for https://github.com/adafruit/Adafruit_ADS1X15 will often not work with ModularSensors because of the new and useful functions added Adafruit's v2 version.

@SRGDamia1, what would it take to switch back? Did any of the 22 commits made to soligen2010 add new features that we depend on?

@aufdenkampe aufdenkampe self-assigned this Nov 22, 2023
@aufdenkampe
Copy link
Member Author

aufdenkampe commented Nov 22, 2023

@SRGDamia1, here are some of the new capabilities of Adafruit's v2.4.2 that would be handy (and are now being used by others):

  • Add function to compute volts from ADC reading
  • Add ability to set data rate
  • Added a bool return type for begin() to allow checking initialization success.
  • Adds ability to other differential channel configurations
  • Support added for continuous reading. (see new continuous example)

Here are the breaking changes introduced with v2.0.1:

  • The library files name has been changed from Adafruit_ADS1015 to Adafruit_ADS1X15. You will need to update #includes
  • The I2C address is now passed in via begin() and not the c-tor. If you were using a non-default address, then you will need to make that change.
  • The library now uses the Adafruit_BusIO library, which is a new dependency.

aufdenkampe added a commit that referenced this issue Nov 22, 2023
Addresses #456, including changing all uses of ADS1X15 to be compatible with breaking changes introduced with Adafruit's v2.x releases. Everything compiles!
@SRGDamia1
Copy link
Contributor

It's been a while. I know there was a reason I picked the fork, but I don't remember it now.

@aufdenkampe
Copy link
Member Author

With commit e2a9410 I just updated the entire repo to compile using Adafruit's version, so I think it should all work.

The comments that I could find (in #235 (comment)) was that there was a bug in Adafruit's version, which they didn't address for years. But that was 2016ish, and they really picked up development again starting in 2020. It's been quite active since, so I'm going to presume that bug was fixed.

Some of the features added by soligen2010, such as continuous mode (a0b81d5c4e0da0367d293e8610c825e5aee7f9c7) seem to have been added by Adafruit.

After a bit of research and work, I'm now strongly leaning toward making the switch, but it might make sense if you or someone at Stroud could test my branch a couple of your analog sensors.

@aufdenkampe aufdenkampe changed the title Consider changing Adafruit_ADS1X15 dependency Change Adafruit_ADS1X15 dependency to Adafruit's v2 Nov 27, 2023
@aufdenkampe
Copy link
Member Author

@SRGDamia1 & @s-hicks2, could you test that my AlphasenseCO2 branch works with other sensors that use the ADS1X15 ADC?

Thanks!

@aufdenkampe
Copy link
Member Author

@SRGDamia1 & @s-hicks2, can either of you test that my AlphasenseCO2 branch works with other sensors that use the ADS1X15 ADC?

I really think this is an important and valuable update and that we should move forward with this Pull Request to the develop branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants