Adafruit Example Code For ADS1115
Moderators: adafruit_support_bill, adafruit

Adafruit Example Code For ADS1115

by bcochran1 on Mon Jan 21, 2013 11:08 pm

I downloaded the Adafruit-Raspberry-Pi-Python-Code library from your github repository with the intention of using it on my newly arrived ADS1115 breakout board. I have the board connected to my Raspberry Pi Model B using the Pi T-Cobbler breakout board. I notice that python module ads1015_example.py defaults to initializing for the ADS1015 breakout board so I copied this to a new module I call ads1115_example.py. I want to initialize the ADS1115 board properly. Is this code:

Code: Select all | TOGGLE FULL SIZE
# Initialise the ADC using the default mode (IC = ADS1115)
adc = ADS1x15(ic=0x01)


the correct way to set up an ADS1115 chip and run the example?

Thanks

Bob

bcochran1
 
Posts: 5
Joined: Mon Jan 21, 2013 10:46 pm

Re: Adafruit Example Code For ADS1115

by ashurbr on Tue Jan 22, 2013 12:42 am

Greetings,

I have some of these modules also. And I started with the Adafruit example Python code. You will need to make several modifications to the example script and the backend script. You will need to read the TI literature on the ADS1115 that Adafruit has linked in the tutorial. Another thing that took me a while to catch is that the conversion from integer to volts is not 3 mV / bit. It is 0.1875 mV / bit when the full scale is 6.144V (16 bit converter vs 12 bit converter). It also clips at negative voltages, although the chip will read correctly small negative voltages. Just wrap the integer by subtracting 0xFFF.

Code: Select all | TOGGLE FULL SIZE
   
 tempval = (result[0] << 8) | (result[1])
    if tempval > 0x7FFF:
      return tempval - 0xFFFF
    else:
      return (result[0] << 8) | (result[1])
ashurbr
 
Posts: 16
Joined: Fri Jun 29, 2012 3:14 pm

Re: Adafruit Example Code For ADS1115

by ktownsend on Tue Jan 22, 2013 1:08 pm

Thanks for the heads up. I just pushed a quick update that should support either the 1015 or 1115 for single-ended readings now.

Kevin
User avatar
ktownsend
 
Posts: 355
Joined: Thu Nov 05, 2009 2:18 am

Re: Adafruit Example Code For ADS1115

by MichelV on Thu Oct 17, 2013 5:15 am

Hey,

Will the erronous multiplier be corrected in the example code for Arduino as well? Cost me a while to find this post (so not *3, but * 0.1875) in the differential example.
MichelV
 
Posts: 7
Joined: Thu Oct 17, 2013 5:13 am

Re: Adafruit Example Code For ADS1115

by ktownsend on Fri Oct 18, 2013 3:25 am

MichelV wrote:Hey,

Will the erronous multiplier be corrected in the example code for Arduino as well? Cost me a while to find this post (so not *3, but * 0.1875) in the differential example.


This should be a bit clearer in the latest code, where a bit more information was added into the example sketches.

You'll always have to set the multiplier yourself, though, since only you know what board you're using and what your gain settings are, but we've added the 16-bit multipliers into the example code as well as a reference.
User avatar
ktownsend
 
Posts: 355
Joined: Thu Nov 05, 2009 2:18 am