I am using the ADS1015, which is a 12-bit ADC from adafruit. I have it hooked up to a Logic Level Converter using I2C to communicate to the Pi. I have two sensors hooked up to the I2C device, so I need to change the address of the ADS1015 to read from both sensors because they currently have the same address (0x48). I am using the Adafruit ads1x15 python library right now, and I am wondering if there is an easy way to change the I2C address of the ADS1015 in my code.

Here's my code so far:

from smbus import SMBus
import board
import busio
import time

import adafruit_ads1x15.ads1015 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
from adafruit_ads1x15.ads1015 import Mode

i2cbus_1 = SMBus(1)
i2cbus_2 = busio.I2C(board.SCL, board.SDA)

ads = ADS.ADS1015(i2cbus_2)
chan = AnalogIn(ads, ADS.P0)


An easy way to set the ADS1015/ADS1115 devices is to hardware pull up/down the four Address pins A0, A1, A2, A3.

ads1115 address pins

See the Q&As in the reference list for more details.


(1) Rpi Thonny Python cannot ADS1015/ADS1115 Problem - RpiSE 2019apr16 Viewed 1k times

(2) How can Rpi3/4 interface multiple ADS1015/ADS1115 ADCs? - RpiSE 2019oct12


Appendix A - I2cdetect -y 1 two ADS1115s

ads1115 detect

Appendix B - Demo Python Program to red ADS1115 registers

$ ads1015_test16_2019apr1601 tlfong01 2019apr16hkt1506
$ Rpi3B+ stretch linux 4.14.34-v7+ arm python 3.5.3

import smbus

i2cCh0    = smbus.SMBus(1)

def readRegOneByte(i2cCh, devAddr, regAddr):
    readByte = i2cCh.read_byte_data(devAddr, regAddr)
    return readByte

def testReadRegWhoAmI():
    print('\n*** Begin test \n')
    devAddr = 0x48
    regAddr = 0x71
    readByte = readRegOneByte(i2cCh0, 0x48, 0x71)
    print('      devAddr    =', hex(devAddr))
    print('      regAddr    =', hex(regAddr))
    print('      regContent =', hex(readByte))
    print('\n End   test ')

$ Main


$ End

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.