PyRaspBeta

ADS1115 ADC (I²C)

The ADS1115 is a 16-bit, 4-channel analog-to-digital converter that talks over I²C. It costs $6 — twice the MCP3008 — and buys precision: 32768 steps instead of 1024, a programmable gain amplifier that zooms into small signals, and a two-wire connection. It is the ADC to reach for when a potentiometer reading must be precise rather than merely cheap. Like every ADC on a Pi it exists because the GPIO header is digital only; the analog inputs primer has the why.

ADS1115 ADC (I²C)

Pins

PinWhat it isType
VDDSupply 2.0–5.5 Vpower
GNDGroundground
SCLI²C clockio
SDAI²C dataio
ADDRAddress select: GND 0x48, VDD 0x49, SDA 0x4A, SCL 0x4Bio
ALRTAlert / ready output (open drain)io
A0Analog input 0io
A1Analog input 1io
A2Analog input 2io
A3Analog input 3io

A0–A3 are the analog inputs, each measured against ground (or against another input in differential mode). ADDR picks the I²C address: to GND it answers at 0x48, to VDD 0x49, to SDA 0x4A, to SCL 0x4B, so four chips can share one bus. ALRT is an open-drain alert output and can be left unwired. VDD takes 2.0–5.5 V, and SDA/SCL go to the Pi's I²C pins — GPIO2 and GPIO3.

Wiring it in circuit.py

A potentiometer on channel A0, with ADDR strapped to ground for address 0x48:

circuit.py
from wiring import *

pi = Pi()

pot = Potentiometer(10000)
adc = ADS1115()

pi.V3_3 >> pot.pin3
pot.pin1 >> pi.GND
pot.wiper >> adc.a0

pi.V3_3 >> adc.vdd
adc.gnd >> pi.GND
pi.SDA >> adc.sda
pi.SCL >> adc.scl
adc.addr >> pi.GND     # 0x48; VDD gives 0x49, SDA 0x4A, SCL 0x4B

Driving it in main.py

The runtime ships Adafruit's CircuitPython driver, adafruit_ads1x15, and a Blinka-compatible board module, so the same code runs on a real Pi after pip install adafruit-circuitpython-ads1x15:

main.py
import board
from adafruit_ads1x15 import ADS1115, AnalogIn, ads1x15
from time import sleep

ads = ADS1115(board.I2C())
knob = AnalogIn(ads, ads1x15.Pin.A0)

while True:
    print(f"{knob.voltage:.3f} V  raw {knob.value}")
    sleep(0.5)

AnalogIn works much like the MCP3008's properties: .voltage, .value (16-bit) and .convert_to_voltage(). Small signals can be zoomed with ADS1115(board.I2C(), gain=16), which makes the full scale ±0.256 V. The smbus2 library can also drive the registers directly if you prefer raw bytes.

Electrical notes

  • Supply 2.0–5.5 V, 150 µA. The internal reference means there is no VREF pin: the range comes from the gain, one of ±6.144, ±4.096, ±2.048, ±1.024, ±0.512 or ±0.256 V (gains 2/3, 1, 2, 4, 8, 16; gain 1 is the default).
  • 16 bits over the chosen range. At gain 1 one LSB is 125 µV, but noise is about one LSB too: the datasheet quotes 187.5 µV rms at ±6.144 V down to 7.81 µV rms at ±0.256 V at the slowest 8 SPS rate. The model adds a per-chip offset of up to 50 µV; datafeed knobs scale the noise and offset.
  • Data rates are 8, 16, 32, 64, 128, 250, 475 and 860 SPS. A single-shot conversion takes 1/data-rate of simulated time; reading the conversion register while it runs returns the previous result.
  • Whatever the gain says, the inputs must stay between GND − 0.3 V and VDD + 0.3 V: the PGA only scales what the chip can already survive. A 5 V sensor output on a 3V3-powered breakout is out of range.
  • Registers are 16-bit and big-endian; the pointer byte selects the conversion (0), config (1) or a comparator threshold register. The config register resets to 0x8583.

Simulator vs real hardware

  • The register map is implemented at byte level, so the Adafruit driver and raw smbus2 code both work; the SPI pins are irrelevant to this part.
  • Single-shot mode sets the OS bit in the config register, clears it while converting and sets it when the result is ready; continuous mode re-latches the newest conversion on every read.
  • The comparator threshold registers can be written and read, but the ALRT output is not driven — nothing buzzes on a threshold crossing as it would with a real comparator wired in.
  • I²C addresses follow the ADDR wiring exactly, and a floating ADDR answers at 0x48 like a grounded one.
  • Readings include quantisation to 16 bits plus the noise and offset model above, so the lowest bit or two wander the way they do on a bench.

Going deeper

Further reading