Microcontrollers like Arduino usually have a built-in A/D converter (ADC = analog-to-digital converter)
with a resolution of 10 bits, meaning they can distinguish a maximum of 1024 values.
The ADC module discussed below is based on the ADC IC ADS1115, an A/D converter with a resolution of 16
bits and 4 channels, which can be easily used with microcontrollers. Thanks to its resolution, it can
distinguish up to 65,536 values.
Furthermore, it features an internal amplifier (PGA = Programmable Gain Amplifier), allowing it to measure
very small voltages. It also includes an alarm function that can be used for voltage monitoring.
This means the microcontroller can enter a power-saving mode during inactive periods while the ADS1115
continues to operate.
Parameter | Value |
---|---|
Resolution: | 16-bit |
Input channels: | 4 single-ended or 2 differential |
Data rate: | 8 to 860 SPS (programmable) |
Interface: | I²C |
Supply voltage: | 2.0V to 5.5V |
Input voltage range: | -0.3V to VDD + 0.3V |
Reference voltage: | Internal 2.048V or external |
Power consumption: | ~150 µA |
Operating temperature: | -40°C to +125°C |
Pin | Description/Function | Arduino Uno | ESP32 | Raspberry Pi | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
VDD | Power supply from 2V to 5.5V | 5V | 5V | 3.3V | ||||||||||
GND | Ground / 0V | GND | GND | GND | ||||||||||
SCL | "Serial clock" (I²C connection) | A5 | SCL, Pin 21 | SCL (GPIO 3) | ||||||||||
SDA | "Serial data" (I²C connection) | A4 | SDA, Pin 22 | SDA (GPIO 2) | ||||||||||
ADDR |
Selector for I²C address depending on wiring:
Usually, the ADDR pin of the ADS1115 module is connected to GND via a pull-down resistor, so that an I²C address of 0x48 is set.
|
- | ||||||||||||
ALRT | Digital comparator output or ready indicator of the A/D conversion. | - | ||||||||||||
A0, A1, A2, A3 |
Analog inputs for measuring voltages against GND (single-ended inputs) or for detecting
differential voltages (differential inputs) with the following configurations:
|
- |
The ADS1115 can operate in 3 different modes, though only the following 2 modes can be directly selected:
Single-shot mode or Continuous conversion mode.
If single-shot mode is selected and no A/D conversion is currently taking place, the ADS1115 enters the third possible mode,
the Power-down mode, until a new single-shot measurement is started.
If high power savings are required, the ADS1115 can be operated with the following settings:
At a data rate of 860 SPS, the A/D conversion time is approximately ~1.2 ms. So if, for example, 5 measurements per second are sufficient, the chip remains in power-down mode for 994 ms, during which the current consumption, according to the datasheet, is only ~1.5 µA.
The gain of the Programmable Gain Amplifier (PGA) can be set to values of 2/3, 1, 2, 4, 8, or 16. The resulting measurement range FS (Full-Scale Range) and the voltage resolution are shown in the following table:
Gain | Measurement Range | Resolution |
---|---|---|
2/3 | ±6.144 V | 0.1875 mV/Bit |
1 | ±4.096 V | 0.1250 mV/Bit |
2 | ±2.048 V | 0.0625 mV/Bit |
4 | ±1.024 V | 31.2500 µV/Bit |
8 | ±0.512 V | 15.5250 µV/Bit |
16 | ±0.256 V | 7.8125 µV/Bit |
The voltages to be measured must always be positive; negative results are only possible in differential voltage measurements. The voltage present at an analog input must always be between 0V and VDD (±0.3V); otherwise, the ADC may be damaged.
The following code uses the library MyADS1115 by Retian.
#include "MyADS1115.h"
MyADS1115 ADS;
void setup() {
Serial.begin(9600);
if (!ADS.isReady()) {
Serial.println("ADS1115 not ready!");
while (true);
}
ADS.init();
ADS.setMux(ADS1115_MUX_AIN0_GND); // Voltage A0 -> GND
ADS.setGain(ADS1115_PGA_6P144); // Gain to 6,144 V (Full Scale)
ADS.setRate(ADS1115_RATE_8); // Sample rate: 8 SPS
ADS.setMode(ADS1115_MODE_CONTINUOUS); // Continuous reading
}
void loop() {
static int value = 0;
static float voltage = 0.0;
value = ADS.readConversion();
voltage = ADS.readVoltage();
Serial.println("Value=" + String(value) + " (" + String(voltage) + " mV)");
delay(200);
}