0

ADS1x15 function reference needed
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

ADS1x15 function reference needed

by gamaverick on Tue Dec 18, 2018 8:02 pm

Greetings,

I'm getting started with a project using one or more ADS1015 boards and have one operational with my RPi3. What I can't seem to locate anywhere is a function reference for the library. The samples provided don't reference the full API of the devices (ADS1015 and ADS1115). As a start, I'd like to be able to set the gain to a value other than 1. The samples for the older libraries use a different method for setting the gain.

As an aside, I'm assuming that the older libraries are incompatible with Python 3.5...I never could get it to work...import Adafruit_ADS1x15 always returned an error. I tried CircuitPython install and I've been able to get it working.

TIA,
Tom

gamaverick
 
Posts: 3
Joined: Tue Dec 18, 2018 7:35 pm

Re: ADS1x15 function reference needed

by adafruit_support_carter on Tue Dec 18, 2018 9:55 pm

Here's the API doc:
https://circuitpython-ads1x15.readthedo ... t/api.html

Correct. The older Python libraries are being deprecated in favor of using CircuitPython versions in conjunction with blinka:
https://learn.adafruit.com/circuitpytho ... x/overview
(which is all Python 3 only)

adafruit_support_carter
 
Posts: 9840
Joined: Tue Nov 29, 2016 2:45 pm

Re: ADS1x15 function reference needed

by gamaverick on Wed Dec 19, 2018 4:04 am

Thanks, the API reference is helpful, but it appears that is for the a different library than the one I'm calling from the example program that uses the library reference in the code example below:

Code: Select all | TOGGLE FULL SIZE
import time
import board
import busio
import adafruit_ads1x15.ads1015 as ADS
from adafruit_ads1x15.analog_in import AnalogIn

i2c = busio.I2C(board.SCL, board.SDA)

ads = ADS.ADS1015(i2c)
chan = AnalogIn(ads, ADS.P0)

while True:
    print("{:>5}\t{:>5.3f}".format(chan.value, chan.voltage))
    time.sleep(2)


Since this is working, though I don't know how to change the gain, I have been reluctant to try installing any of the older libraries. I don't want to break what is working, even if minimally.

Cheers!

gamaverick
 
Posts: 3
Joined: Tue Dec 18, 2018 7:35 pm

Re: ADS1x15 function reference needed

by adafruit_support_carter on Wed Dec 19, 2018 12:12 pm

It looks like the auto documentation for that may be behind or not updating for some reason. We'll investigate. But that's where it should be.

Setting gain is pretty simple, just do this:
Code: Select all | TOGGLE FULL SIZE
ads.gain = 8

the acceptable values are: 2/3, 1, 2, 4, 8, or 16.

You can also query the current gain setting using the same property:
Code: Select all | TOGGLE FULL SIZE
print(ads.gain)

adafruit_support_carter
 
Posts: 9840
Joined: Tue Nov 29, 2016 2:45 pm

Re: ADS1x15 function reference needed

by gamaverick on Wed Dec 19, 2018 1:34 pm

Perfect...thanks very much for your prompt reply on this. Until you publish the documentation, would it be safe to assume some of the other function calls/device settings would use a similar syntax? I can look up the legal values in the library sources and give it a shot.

I have no doubt that trying to update and maintain doc's on all your products is a challenge, especially since you're moving to a new way of interfacing.

Cheers!

gamaverick
 
Posts: 3
Joined: Tue Dec 18, 2018 7:35 pm

Re: ADS1x15 function reference needed

by adafruit_support_carter on Wed Dec 19, 2018 1:45 pm

Yep. Until we can get the RTD working, the source code is your best back up documentation:
https://github.com/adafruit/Adafruit_Ci ... it_ads1x15

In general, the functions you see with an @property decorator before them create parameters that can be used with that syntax. For example, data_rate:
https://github.com/adafruit/Adafruit_Ci ... x15.py#L71

Also note that most of these are defined in the ADS1x15 base class. That's why they don't show up in ads1015.py:
https://github.com/adafruit/Adafruit_Ci ... ads1015.py

adafruit_support_carter
 
Posts: 9840
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.