Source: https://mokxi.com/libraries/adafruit-ads1x15
Updated: 2026-11-02

Libraries / Sensors
Arduino library · Sensors

# Adafruit ADS1X15: 16-bit analog inputs over I2C

The ADS1115 is a 16-bit analog to digital converter with four inputs, a programmable gain amplifier and an I2C interface, used when the board’s own 10 or 12-bit ADC is not fine enough or when a board, like the ESP8266, has only one analog pin. The Adafruit ADS1X15 library drives it and its 12-bit cousin, the ADS1015.

Open the example in the editor See the calls

Built in on Mokxi: #include <Adafruit_ADS1X15.h> and it builds, with nothing to install. Free, and no account needed.

## What Adafruit ADS1X15 does

The gain sets the input range, and that range is the most important choice in the sketch. GAIN_TWOTHIRDS, the default, covers plus or minus 6.144 V at 187.5 microvolts a count; GAIN_ONE covers 4.096 V, GAIN_TWO 2.048 V, down to GAIN_SIXTEEN at 0.256 V. The range is a measuring scale, not a permission: an input must never go below ground or above the supply.

Inputs can be read single-ended, each against ground, or as differential pairs (0 and 1, 2 and 3), which subtract out noise common to both wires and suit a bridge sensor or a shunt.

Library Manager name | Adafruit ADS1X15

Author | Adafruit

Include | #include <Adafruit_ADS1X15.h>

Boards | every board Mokxi compiles for but ATtiny85

In the simulator | Simulated: it runs against the part the way it does on the bench.

Parts it drives | Sixteen-bit ADC, ADS1115

## Install it

It builds on every board Mokxi compiles for but ATtiny85.

In Mokxi it is built in: #include <Adafruit_ADS1X15.h> and the sketch compiles, with no download, no zip and no Library Manager.

On a real board, install "Adafruit ADS1X15" by Adafruit from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add Adafruit ADS1X15 to lib_deps in PlatformIO. Mokxi follows the calls of release 2.5.0, so a sketch written here builds there too.

ESP32-C3 · Arduino Uno · Arduino Nano · Arduino Mega 2560 · Arduino Leonardo · SparkFun Pro Micro · Arduino Micro · ESP32-C6 · Raspberry Pi Pico · Raspberry Pi Pico W · Seeed XIAO SAMD21 · STM32 · STM32 Nucleo-F411RE · STM32 Blue Pill · micro:bit V2 · Arduino Uno R4 · ESP32 DevKit · ESP32-S3-DevKitC-1 · ESP8266 NodeMCU · Arduino Pro Mini 3.3 V · Seeed XIAO ESP32-C3 · ESP32-C3 SuperMini · Seeed XIAO ESP32-C6 · ESP32-DevKitC V4 · LOLIN32 Lite · Wemos D1 R32 · Cheap Yellow Display · TTGO T-Display · Seeed XIAO ESP32-S3 · Arduino Nano ESP32 · Arduino Nano RP2040 Connect · Seeed XIAO RP2040 · Waveshare RP2040-Zero · Arduino Uno R4 WiFi

## The calls you will use

In the order a sketch meets them.

### Adafruit_ADS1115 ads

Creates the 16-bit converter. Adafruit_ADS1015 is the 12-bit one.

### ads.setGain(GAIN_ONE)

Sets the range to plus or minus 4.096 V, 125 microvolts a count.

### ads.begin()

Starts I2C at 0x48. begin(0x49) and so on for the other ADDR settings. Returns false when nothing answers.

### int16_t adc0 = ads.readADC_SingleEnded(0)

Reads input A0 against ground, from 0 to 32767.

### ads.computeVolts(adc0)

Converts a reading to volts using the current gain.

### ads.readADC_Differential_0_1()

The difference between A0 and A1, which can be negative.

### ads.startADCReading(ADS1X15_REG_CONFIG_MUX_SINGLE_0, true)

Starts continuous conversions on A0. Read each result with getLastConversionResults(), or wait for conversionComplete().

### ads.setDataRate(RATE_ADS1115_860SPS)

Samples faster than the default 128 a second, with a little more noise.

## Example: Current and voltage

On the ESP32-C3-DevKitM-1. It runs in the browser exactly as printed.

sketch.ino · ESP32-C3-DevKitM-1

Open it in the editor, wired and ready to run · Current and voltage: the project page

## Common errors and how to fix them

### Failed to initialize ADS.

begin() got no answer. Check SDA and SCL and the address: ADDR to GND is 0x48, to VDD 0x49, to SDA 0x4A, to SCL 0x4B.

### The reading is stuck at 32767

The input is above the gain’s range, so the converter is at full scale. Choose a lower gain (GAIN_TWOTHIRDS is the widest) or divide the input voltage down.

### computeVolts() gives the wrong voltage

setGain() was called after the reading, or a hand-written conversion assumes another gain. Set the gain once in setup() and let computeVolts() do the arithmetic.

## Keep going

### Learn

- Analog vs Digital Pins, and ADC Resolution
- I2C Explained: Addresses, Acknowledges and Pull-Ups

### Parts

- Sixteen-bit ADC, ADS1115

### More sensors libraries

- DHT sensor library
- DHT20
- VL53L0X
- Adafruit_VL53L0X
- HX711 Arduino Library
- MPU6050
- Adafruit MPU6050
- BME280

Every built-in library · Open the editor

## Try Adafruit ADS1X15 without installing anything

Open the example, change the sketch, and keep your version in a free account.

Start building free

Open the editor
