There are two ways we can use the ADS1115 with our Raspberry Pi with Python:
- Read the ADS1115 datasheet and use a lower-level I2C such as SMBus to implement the data protocol used by the device.
- Find a ready-made Python library available through PyPi that we can install using pip.
There are several ready-made Python modules available to use with the ADS1115. We are using the Adafruit Binka ADS11x5 ADC library that we installed through requirement.txt at the start of this chapter:
import board # (1)
import busio
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
Starting at line (1), we see the board and busio imports from Circuit Python (Blinka), while the last two imports starting with adafruit are from the Adafruit ADS11x5 ADC library and are used to configure the ADS1115 module and read its analog input, which we are going to look at next.