Adafruit is open, safely ... and shipping all orders at this time! Read more!

Mods for ADS1015 library
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Mods for ADS1015 library

by ebeowulf17 on Fri May 17, 2019 2:31 pm

I'm not sure if this is the right place for this, but I've made some changes to the ADS1015 library and I thought I should share them in case anyone else would find them useful, or if you guys wanted to incorporate some of the changes into future updates. Basically the changes are:
    1) Modified readADC_SingleEnded function so that instead of having a fixed delay while waiting for the AD conversion to complete, it actively monitors the OS bit in the Config register and accepts the new reading as soon as it's available.
    2) Fixed a "bug" in the readRegister function so that it can actually read whatever register you pass an address to (instead of being hard-coded to only read from the conversion result register.)
    3) Added a new function, along with requisite #define and typedef statements, allowing the data rate to changed.
These updates make it possible to easily set a new data rate from within your Arduino sketch with a command like:
Code: Select all | TOGGLE FULL SIZE
  //  Available data rate options:
  //  Documentation isn't totally clear, but it sounds like lower rates yield better noise performance.
  //    DR_1115_8SPS
  //    DR_1115_16SPS
  //    DR_1115_32SPS
  //    DR_1115_64SPS
  //    DR_1115_128SPS (default)
  //    DR_1115_250SPS
  //    DR_1115_475SPS
  //    DR_1115_860SPS

For the ADS1115 (16 bit option) the data rates range from 8-860 samples per second, or 125ms all the way down to 1.2ms conversion time. There's a little bit of time spent doing I2C communication as well, but the end result is that switching from the default 128 to the max 860 changed my total ADC read time from ~8.1ms down to ~1.7ms.
Zip file includes modified .cpp and .h files, but I haven't updated examples or other documentation.
(5.11 KiB) Downloaded 80 times

Posts: 26
Joined: Tue Feb 26, 2013 12:57 am

Re: Mods for ADS1015 library

by rcanha on Thu May 23, 2019 3:16 pm

I'm trying to read two differential signals by making a small change in the differential.ino file provided by your library.
Basically I include a new variable int16_t and assign it differential reading through the ads.readADC_Differential_2_3 () command.

The problem that the displayed result is is the same reading as that obtained with ads.readADC_Differential_0_1 () - the actual signals are different.

Is there a problem with the library because when I use ads.readADC_Differential_2_3 () without using ads.readADC_Differential_0_1 () do I get the correct reading but using both I have repeated differential readings?


Posts: 2
Joined: Thu May 23, 2019 3:09 pm

Re: Mods for ADS1015 library

by adafruit_support_bill on Thu May 23, 2019 5:12 pm

@ebeowulf17 - to submit changes to the lib, please submit a pull request to the github repo.

@rcanha - Please start a new thread for your question. Be sure to include photos or a diagram of your connections - as well as the code you are using.

Posts: 77342
Joined: Sat Feb 07, 2009 10:11 am

Re: Mods for ADS1015 library

by ebeowulf17 on Sat May 25, 2019 10:55 pm

Thanks for pointing me in the right direction. I should've known that would be the answer. I've just started learning about git and github in the last month or so, but haven't had a real application for it yet, so this will be good practice.


Posts: 26
Joined: Tue Feb 26, 2013 12:57 am

Please be positive and constructive with your questions and comments.