ADS1115 sixteen-bit ADC
Four analog inputs and a sixteen-bit converter on a blue I2C breakout. Aliases: 16-bit ADC, analog to digital converter, ADS1015.
It is what to reach for when the board's own ten-bit analogRead is not fine enough,
when you want the difference between two voltages rather than each against ground, or
when the board has no analog inputs to spare.
Pins
| Pin | What it does |
|---|---|
VDD |
Supply, 2 to 5.5 V. |
GND |
Ground. |
SCL |
I2C clock. The module carries the pull-ups. |
SDA |
I2C data. |
ADDR |
Address select: to GND (or left alone) is 0x48, to VDD is 0x49. |
ALRT |
Comparator or conversion-ready output, open drain: needs a pull-up. |
A0 to A3 |
The four inputs. |
The gain is a full scale, not an amplifier
A result is 32768 × V ÷ FS, where FS is the gain's full scale: ±6.144, ±4.096,
±2.048, ±1.024, ±0.512 or ±0.256 V. The gain decides what range the counts cover; it
does not let an input go past the supply. An input measured against GND can only be
positive, so a single-ended reading uses fifteen of the sixteen bits, and a
differential one between two inputs uses all of them.
The library
Adafruit_ADS1X15.h works as its tutorial uses it:
#include <Adafruit_ADS1X15.h>
Adafruit_ADS1115 ads;
void setup() {
Serial.begin(9600);
ads.setGain(GAIN_ONE); // +/-4.096 V, 125 uV a count
if (!ads.begin()) { Serial.println("No ADS1115"); while (1); }
}
void loop() {
int16_t counts = ads.readADC_SingleEnded(0);
Serial.print(counts);
Serial.print(" ");
Serial.print(ads.computeVolts(counts));
Serial.println(" V");
delay(500);
}
computeVolts() turns counts into volts at the gain in use, and tutorials that
multiply the counts by 0.1875 themselves work as written.
What the model gets right
The four registers (conversion, config, and the two thresholds) and their reset values, the multiplexer's eight settings, the six gains and the eight data rates.
A conversion takes time: one over the data rate, 7.8 ms at the default 128
samples a second and 125 ms at 8. In single-shot mode the OS bit reads 0 until it is
done, and reading the conversion register before then gets the previous result,
which is the commonest ADS1115 bug. Continuous mode refreshes the result every period.
The comparator on ALRT: traditional or window, active low or high, latching or
not, and asserting after one, two or four readings past a threshold. Set the high
threshold's top bit and clear the low one's and ALRT becomes the conversion-ready
signal instead.
What it does not model
Noise: a steady input gives the same count every time. The input impedance and the
anti-aliasing filter. ADDR tied to SDA or SCL for 0x4A and 0x4B: only
0x48 and 0x49 are modeled.
Common mistakes
Reading the conversion register straight after starting a single-shot conversion.
Expecting a higher gain to amplify: GAIN_SIXTEEN makes the full scale 0.256 V, and
a 1 V input just reads as the top of the scale. Leaving ALRT without a pull-up and
seeing nothing on it.