Single-ended and differential
There is one converter in there, with a switch in front of it. Four channels is that switch sending the negative side to ground four times; two channels is it comparing two of your pins instead, which doubles the range and cancels the noise that arrived on both wires.
One converter and a switch
Step through the seven settings. Each one is the same converter with different things on its two inputs — and "four analog inputs" turns out to be four of the seven, all of them measuring against ground.
Why measuring against ground is the weak option
Ground sounds like a fixed thing. It is a copper track with current in it, and the voltage along it is not the same at both ends.
When you measure A0 against ground, you are measuring the difference between your signal and this board's ground pin. Anything that shifts one relative to the other lands in the reading: current from a motor on a shared return wire, a long cable picking up mains hum, a switching regulator dumping spikes into the supply. None of that is noise on your signal; it is noise on your reference.
A differential pair removes it. The converter subtracts A1 from A0, so whatever arrived on both wires — which is most interference, since the wires run together — subtracts itself out. TI quotes about 105 dB of rejection at 50 and 60 Hz, which is mains hum reduced to about a two-hundred-thousandth of its size.
When to use which
| Measuring | Wiring |
|---|---|
| A battery, through a divider on the same board | Single-ended is fine |
| A potentiometer sharing the same ground | Single-ended is fine |
| A load cell, a strain gauge, a shunt resistor | Differential, always |
| A thermocouple | Differential, ±0.256 V |
| Anything on the end of a cable longer than your arm | Differential if you can spare the pins |
The rule of thumb: if your sensor has its own ground return wire, use it as the negative input rather than joining it to ground and hoping.
A3 as a common point
The setting most people never find. A0, A1 and A2 can each be measured against A3 instead of against ground, which gives three channels with a differential pair's noise rejection and one shared reference.
It also lets a reading go negative without a negative supply. Put A3 on a half-supply reference — two equal resistors across VCC — and a signal below that midpoint comes back as a negative number, which is a genuinely useful trick for anything that swings both ways around a rest position.
The constraint is the usual one: A3 must sit between ground and the supply, like every other input.
The code
The same reading taken twice: A0 against ground, then A0 against A1. Put the same signal on both channels with A1 on the sensor's own ground return, and watch which of the two numbers is steadier.
// Wiring for this sketch.
//
// ESP32 3V3 -> VCC
// ESP32 GND -> GND
// ESP32 SDA -> SDA
// ESP32 SCL -> SCL
// sensor output -> A0
// sensor ground return -> A1, and also -> GND
//
// Both A0 and A1 must stay between 0 V and VCC.
//
// Arduino IDE: any board. Library: "ADS1X15" by Rob Tillaart.
#include <Wire.h>
#include <ADS1X15.h>
ADS1115 ADS(0x48);
void setup() {
Serial.begin(115200);
delay(500);
Wire.begin();
if (!ADS.begin()) {
Serial.println("no ADS1115 at 0x48");
while (true) delay(1000);
}
ADS.setGain(1); // +/-4.096 V
ADS.setDataRate(0); // 8 SPS - the quietest setting
}
void loop() {
int16_t se = ADS.readADC(0); // A0 against GND
int16_t diff = ADS.readADC_Differential_0_1(); // A0 minus A1
Serial.printf("single-ended %6d (%.4f V) differential %6d (%.4f V)\n",
se, ADS.toVoltage(se), diff, ADS.toVoltage(diff));
delay(500);
}readADC_Differential_0_1 returns a signed value that can go either way, so store it in an int16_t. The difference in steadiness is easiest to see with a long cable or a switching supply somewhere nearby — that is exactly the noise the differential pair is subtracting out.
When it does not work
Then the voltage on the negative pin is the higher of the two — the sensor is wired the other way round. Swap the two wires, or take the absolute value if the direction does not matter. A small negative number wobbling around zero is just the offset error, which is a few counts, and is normal.
Check what A3 is actually sitting at. The chip needs it between ground and the supply like any other input, and if it is left floating the three readings against it are the difference between your signal and an aerial. Tie it to a real reference — a divider from the supply, or the midpoint of whatever you are measuring.
There are only two, and it is not a limitation of the board. The multiplexer offers A0−A1 and A2−A3, and that is the whole list. If you need three, the A3-as-common setting gives you A0−A3, A1−A3 and A2−A3, which is three measurements sharing one reference — not the same thing, but often what people actually wanted.
The opposite. One count is the same size either way, and differential uses the whole signed range instead of half of it — so the same step covers twice the span. It is the single-ended wiring that gives away a bit, by making the negative half unreachable.
Why 860 samples a second is not sixteen bits, and 8 is.
Data rate, and the bits that are noise →Edit this page — content/books/ads1115/single-ended-and-differential.mdx
Questions about this product
See what other owners have asked, and read their solutions.
This page covers several products. Choose yours to see the right discussions.
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.