[{Image src='attach/Ads1015AnalogDigitalConverter/ads1015-chip.jpg' caption='ADS1015 Integrated Circuit (enlarged 20x; actual size: 2 x 1.5mm)' align='right' class='imgFloatRight'}]

The Texas Instruments __ADS1015 +/-24V Analog Digital Converter__ is a 2 x 1.5mm integrated circuit implemented by both AdaFruit and Pimoroni as [I2C]-compatible breakout boards (Pimoroni's is a "Breakout Garden" board). It can be used to measure an analog voltage between -24V DC to +24V DC, returning a value with 12 bit precision.

The ADS1015 has four channels (labeled {{{A0}}}, {{{A1}}}, {{{A2}}} and {{{A3}}}) that can read voltages from -24V to  +24V at sampling rates up to 3.3KHz with a 12-bit resolution. The Pimoroni board only provides three of these channels as usable pins.

\\

[{Image src='attach/Ads1015AnalogDigitalConverter/ads1015-thumb.jpg' link='attach/Ads1015AnalogDigitalConverter/ads1015.jpg' caption='ADS1015 Breakout Boards (click to enlarge)' align='right' class='imgFloatRight'}]

The thumbnail image to the right is roughly the size of the Adafruit and Pimoroni boards, which measure 28 x 17mm and 24 x 21mm respectively. 

As of January 2020 the price of the AdaFruit board is US$9 (~NZ$14), the price of the Pimoroni board is £12 (~NZ$24). The Adafruit board is also available from DigiKey NZ at NZ$16.57 (where shipping is free if you order over NZ$66).
      

!!! Features

[{Image src='attach/Ads1015AnalogDigitalConverter/ads1015-diagram.png' caption='ADS1015 Block Diagram' align='right' class='imgFloatRight'}]

* 12-bit precision (Adafruit also sell a 16-bit version, see [ADS1115|https://www.adafruit.com/product/1085])
* +/- 24V (DC) measurement range
* three or four channels (the TI ADS1015 has four: AdaFruit's provides all four, whereas Pimoroni's board only provides connections to three of them)
* programmable gain (please consult the [ADS1015 TI datasheet|http://www.ti.com/lit/ds/symlink/ads1015.pdf] for details; the default is set at ±2.048V)
* pp to 3.3KHz sampling rate
* [I2C] interface (The Pimoroni board uses address 0x48 or 0x49 with a cut trace; the Adafruit board can be programmed for up to 4 different addresses)
* 3.3V or 5V compatible
* reverse polarity protection

Both boards arecompatible with all models of Raspberry Pi and Arduino, depending on which software libraries 
you intend to use.


!! Installation

The Adafruit board has its own installation page (which we won't repeat here, see ''[References|https://service.robots.org.nz/wiki/Edit.jsp?page=Ads1015AnalogDigitalConverter#section-Ads1015AnalogDigitalConverter-References]'' below).

For the Pimoroni board, [Python] and {{{pip}}} (or {{{pip3}}} for Python 3) must be installed.

Then, if you're using Python 2, just run:
{{{
sudo pip install ads1015
}}}
or for Python 3:
{{{
sudo pip3 install ads1015
}}}


!! Example Usage

The board has three input pins, labeled {{{A0}}}, {{{A1}}} and {{{A2}}}. Plugging a signal into {{{A0}}}, 
here's an example of some code to repeatedly read the voltage on the pin until you type {{{Ctrl-C}}}:
{{{
    #!/usr/bin/env python3
    import time      
    from ads1015 import ADS1015
    
    print('''read-all.py - read the A0 input of the ADC.
    
    Press Ctrl+C to exit!
    ''')
     
    CHANNEL = 'in0/ref'
    ads1015 = ADS1015()
    ads1015.set_mode('single')
    ads1015.set_programmable_gain(2.048)
    ads1015.set_sample_rate(1600)
     
    reference = ads1015.get_reference_voltage()
    print("Reference voltage: {:6.3f}v \n".format(reference))
    
    try:
        while True:
            value = ads1015.get_compensated_voltage(channel=CHANNEL, reference_voltage=reference)
            print("A0 value: {:6.3f}v".format(value))
            time.sleep(0.5)
    
    except KeyboardInterrupt:
        pass
}}}


!! References

* [ADS1015 12-Bit ADC - 4 Channel with Programmable Gain Amplifier|https://www.adafruit.com/product/1083] Adafruit product page
** [Adafruit 4-Channel ADC Breakouts: A guide to the ADS1115 and ADS1015 analog converters|https://learn.adafruit.com/adafruit-4-channel-adc-breakouts/]
* [ADS1015 +/-24V ADC breakout|https://shop.pimoroni.com/products/ads1015-adc-breakout] Pimoroni product page
** [ads1015-python library | https://github.com/pimoroni/ads1015-python] on github
* [Adafruit ADS1015|https://www.digikey.co.nz/catalog/en/partgroup/ads1015-12-bit-adc-4-channel-with-programmable-gain-amplifier/49471] product page on DigiKey
* [ADS101x Ultra-Small, Low-Power, I2C-Compatible, 3.3-kSPS, 12-Bit ADCs With Internal Reference, Oscillator, and Programmable Comparator|http://www.ti.com/lit/ds/symlink/ads1015.pdf] datasheet from Texas Instruments


----

[{Tag Sensor}]