Using the ADS1115 with the Raspberry Pi

Using the ADS1115 with the Raspberry Pi

The ADS1115 is a 16-bit Analog-to-Digital Converter (ADC) that allows the Raspberry Pi to read analog signals from sensors, potentiometers, and other analog devices. This guide will walk you through setting up the ADS1115 ADC module with the Raspberry Pi to read analog sensor data using Python.


What You Will Need

  1. Raspberry Pi (any model with I2C support, e.g., Pi 3, Pi 4)
  2. ADS1115 ADC Module
  3. Analog Sensor (e.g., potentiometer, temperature sensor, soil moisture sensor, etc.)
  4. Breadboard and Jumper Wires
  5. Python installed on the Raspberry Pi

Step 1: Understanding the ADS1115

The Raspberry Pi lacks analog input pins, so the ADS1115 is used to convert analog signals to digital. The ADS1115 provides:

  • 4 Analog Input Channels (A0, A1, A2, A3)
  • 16-bit Resolution for High Precision
  • I2C Communication Interface
  • Programmable Gain Amplifier (PGA) for adjustable sensitivity

Step 2: Wiring the ADS1115 to the Raspberry Pi

The ADS1115 communicates via I2C, so we connect it to the Raspberry Pi’s I2C pins.

Connections

ADS1115 Pin Raspberry Pi Pin
VCC 3.3V (Pin 1) or 5V (Pin 2)
GND Ground (Pin 6)
SDA SDA (Pin 3, GPIO2)
SCL SCL (Pin 5, GPIO3)
A0-A3 (Analog Inputs) Connect to sensor output

Step 3: Enable I2C on the Raspberry Pi

  1. Open the Raspberry Pi configuration tool:
    sudo raspi-config
    
  2. Navigate to Interface Options > I2C and enable it.
  3. Reboot the Raspberry Pi:
    sudo reboot
    
  4. Verify that the ADS1115 is detected on the I2C bus:
    sudo i2cdetect -y 1
    
    The ADS1115 should appear at address 0x48.

Step 4: Install Required Libraries

  1. Update your Raspberry Pi’s package list:
    sudo apt update && sudo apt upgrade -y
    
  2. Install the required I2C tools and Python libraries:
    sudo apt install -y python3-smbus python3-pip
    pip3 install adafruit-circuitpython-ads1x15
    

Step 5: Reading Analog Data from the ADS1115

Python Code to Read Sensor Data from ADS1115

import time
import board
import busio
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn

# Initialize I2C and ADS1115 ADC
i2c = busio.I2C(board.SCL, board.SDA)
ads = ADS.ADS1115(i2c)

# Select Analog Input Channel (A0)
channel = AnalogIn(ads, ADS.P0)

try:
    while True:
        print(f"Raw Value: {channel.value}, Voltage: {channel.voltage:.2f}V")
        time.sleep(1)
except KeyboardInterrupt:
    print("Exiting...")

Step 6: Applications of ADS1115 with Raspberry Pi

  1. Reading Analog Sensors – Temperature, light, humidity, or gas sensors.
  2. Battery Voltage Monitoring – Measure voltages safely with high resolution.
  3. Soil Moisture Monitoring – Use for smart irrigation systems.
  4. Potentiometer Readings – Use as a user input controller for projects.

Troubleshooting

  1. ADS1115 Not Detected (i2cdetect does not show 0x48)

    • Ensure the SDA/SCL pins are correctly wired.
    • Verify that I2C is enabled using sudo raspi-config.
  2. Inaccurate Readings

    • Use PGA settings in the Python code to adjust voltage range.
    • Ensure a stable power supply to the ADS1115 module.
  3. Multiple ADS1115 Modules

    • Modify the I2C address using the ADDR pin to avoid conflicts.

Conclusion

The ADS1115 ADC module enables the Raspberry Pi to read analog sensor data with high precision. Whether you're building environmental monitoring, battery sensing, or IoT applications, this guide provides a simple way to integrate analog inputs into your projects! 🚀

Leave a comment

Notice an Issue? Have a Suggestion?
If you encounter a problem or have an idea for a new feature, let us know! Report a problem or request a feature here.