The ADS1115 is a 16-bit precision analog-to-digital converter (ADC) with an I2C interface. It offers high accuracy and multiple input channels, making it ideal for reading sensors, monitoring voltages, or amplifying signals in Arduino projects. This tutorial will guide you through connecting and using the ADS1115 with Arduino.
What You Will Need
- ADS1115 ADC Module
- Arduino Board (e.g., Uno, Mega, Nano)
- Sensors or analog devices (e.g., potentiometer)
- Breadboard and Jumper Wires
- A computer with the Arduino IDE installed
Step 1: Understanding the ADS1115 Module
The ADS1115 offers:
- 16-bit ADC resolution (15-bit for differential inputs).
- 4 input channels (or 2 differential pairs).
- Programmable Gain Amplifier (PGA) for signal amplification.
ADS1115 Pinout
Pin | Function |
---|---|
VCC | Power Supply (3.3V/5V) |
GND | Ground |
SDA | I2C Data Line |
SCL | I2C Clock Line |
ADDR | I2C Address Configuration |
-
ADDR Pin Configuration:
- GND:
0x48
(default address) - VCC:
0x49
- SDA:
0x4A
- SCL:
0x4B
- GND:
Step 2: Wiring the ADS1115 to Arduino
Connect the ADS1115 to the Arduino as follows:
ADS1115 Pin | Arduino Pin |
---|---|
VCC | 5V |
GND | GND |
SDA | A4 (SDA) |
SCL | A5 (SCL) |
Note: For other Arduino boards, ensure you use the correct I2C pins.
Step 3: Install the Required Library
To simplify communication with the ADS1115, install the Adafruit ADS1X15 library.
Steps to Install:
- Open the Arduino IDE.
- Go to Sketch > Include Library > Manage Libraries.
- Search for "Adafruit ADS1X15" and click Install.
Step 4: Upload the Code
Here’s an example sketch to read analog input from the ADS1115:
#include <Wire.h>
#include <Adafruit_ADS1X15.h>
Adafruit_ADS1115 ads; // Create an ADS1115 object
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("Initializing ADS1115...");
if (!ads.begin()) {
Serial.println("Failed to detect ADS1115. Check connections.");
while (1);
}
Serial.println("ADS1115 initialized.");
}
void loop() {
int16_t adc0 = ads.readADC_SingleEnded(0); // Read channel 0
float voltage = adc0 * 0.1875 / 1000.0; // Convert to voltage (gain = 2/3)
Serial.print("ADC Value: ");
Serial.print(adc0);
Serial.print(" | Voltage: ");
Serial.print(voltage);
Serial.println(" V");
delay(500); // Wait for 500ms before the next reading
}
Step 5: Test the Setup
- Connect the Arduino to your computer via USB.
- Open the Arduino IDE and select the correct Board and Port under the Tools menu.
- Upload the code to the Arduino by clicking Upload.
- Open the Serial Monitor (Tools > Serial Monitor) and set the baud rate to
9600
. - Vary the input voltage (e.g., using a potentiometer) and observe the ADC value and voltage readings.
Optional: Using Differential Mode
The ADS1115 can also measure the difference between two input pins (e.g., A0 and A1):
int16_t diff = ads.readADC_Differential_0_1(); // Measure difference between A0 and A1
float voltage = diff * 0.1875 / 1000.0; // Convert to voltage
Serial.println(voltage);
Applications of the ADS1115
- High-precision sensor readings
- Voltage monitoring and measurement
- Signal amplification for small sensors
- Differential signal measurement
Troubleshooting
- No response from the sensor: Verify the I2C connections and ensure the correct I2C address is used.
- Inconsistent readings: Check for a stable power supply and clean signal inputs.
- Low resolution: Ensure you’re using the correct gain setting for your input range.
Conclusion
You’ve successfully interfaced the ADS1115 ADC with Arduino. With its high precision and flexibility, the ADS1115 is an excellent tool for various projects requiring accurate analog-to-digital conversion. Experiment with its features to build advanced measurement systems and sensor interfaces!