1

I'm having a hard time setting up a i2c device on a pi4. enter image description here

I did i2cdetect -y 1

enter image description here

But when I run the python code

import board
import busio

import adafruit_ads1x15.ads1115 as ADS

i2c = busio.I2C(board.SCL, board.SDA)
from adafruit_ads1x15.analog_in import AnalogIn

ads = ADS.ADS1115(i2c)

chan = AnalogIn(ads, ADS.P0)

print(chan.value, chan.voltage)

I get ValueError: No I2C device at address: 0x48

and printing out the value for board.SCL and board.SDA its 3 and 2 respectively. Am I calling the i2c incorrectly?

2
  • Could you print the values of board.SCL and board.SDA and add it to your question.
    – joan
    Oct 2, 2022 at 20:45
  • @joan yea, its board.SCL is 3, and board.SDA is 2
    – Jith
    Oct 2, 2022 at 21:46

1 Answer 1

0

I don't use Python for these things, but on my side of the tracks I have to make an entry in /boot/config.txt to enable the appropriate device tree overlay before the driver is able to connect to the device.

Assuming your device is the ADS1115, you can add the following entry to /boot/config.txt & reboot. Running i2cdetect -y 1 should show the symbol UU at address 48, indicating the driver has connected.

dtoverlay=ads1115 <options as required>
# Read  the file '/boot/overlays/README' to see the additional options that my need to be configured. 

Alternatively, you can use the dtoverlay command to invoke the dynamic device tree. AIUI, this is not a permanent change, but may be useful for testing when it's not convenient to reboot. Also FWIW, last I tried the dynamic device tree, it seemed a rough and unfinished project - it may or may not have improved since.

1
  • ty, this did the trick!
    – Jith
    Oct 2, 2022 at 22:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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