ADS1115 analog-to-digital converter and Raspberry Pi example

In this example we connect an ADS1115 analog-to-digital converters to a Raspberry Pi. Lets look at the ADS1115.

The ADS1115 is a precision, low-power, 16-bit, I2C-compatible, analog-to-digital converters (ADCs) offered in an ultra-small, leadless, X2QFN-10 package, and a VSSOP-10 package. The ADS1115 incorporates a low-drift voltage reference and an oscillator.

The ADS1115 also incorporate a programmable gain amplifier (PGA) and a digital comparator. These features, along with a wide operating supply range, make the ADS1115 well suited for power- and space-constrained, sensor measurement applications.

The ADS1115 performs conversions at data rates up to 860 samples per second (SPS). The PGA offers input ranges from ±256 mV to ±6.144 V, allowing precise large- and small-signal measurements. The ADS1115 features an input multiplexer (MUX) that allows two differential or four single-ended input measurements. Use the digital comparator in the ADS1115 for under- and overvoltage detection.

The ADS1115 operates in either continuous-conversion mode or single-shot mode. The devices are automatically powered down after one conversion in single-shot mode; therefore, power consumption is significantly reduced during idle periods.

 

Connection

In this example I had connected the sensor to a Pi Zero, a Raspberry Pi 2 or 3 would work just as well. I also used a cable which I would use to connect and disconnect to Channel 0 to check the readings changed.

Raspberry PI and ADS1115
Raspberry PI and ADS1115

 

 

Parts List

 

PartLink
Raspberry PI2018 new original Raspberry Pi 3 Model B+ (plug) Built-in Broadcom 1.4GHz quad-core 64 bit processor Wifi Bluetooth and USB Port
ADS1115 breakout16 Bit I2C ADS1115 Module ADC 4 channel with Pro Gain Amplifier for Arduino or RPi
Connecting cablesFree shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

Code

Save the following as ADS1115_Single.py

# Distributed with a free-will license.
# Use it any way you want, profit or free, provided it fits in the licenses of its associated works.
# ADS1115
# This code is designed to work with the ADS1115_I2CADC I2C Mini Module available from ControlEverything.com.
# https://www.controleverything.com/content/Analog-Digital-Converters?sku=ADS1115_I2CADC#tabs-0-product_tabset-2
import time
from ADS1115 import ADS1115
ads1115 = ADS1115()
while True :
ads1115.set_channel()
ads1115.config_single_ended()
time.sleep(0.1)
adc = ads1115.read_adc()
print "Digital Value of Analog Input : %d "%(adc['r'])
print " ********************************************* "
time.sleep(0.8)

Output

Run the above example by opening a terminal and typing in

sudo python ADS1115_Single.py

In the example you input the channel number, in the output below you can see I have 2 values displayed. This is when I connected a Gnd to Channel 0 – thats the low value and then disconnected this – the high value

ads1115 output
ads1115 output

Links