Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5335

Automation, sensing and robotics • RPi 4 ADS1115 No Hardware I2C on (scl,sda)=(3, 2)

$
0
0
Hello everyone. I'm trying to do voltage measurements with RPi 4 Model B, ADS1115 and a voltage sensor. RPi is running the default Raspbian system. Python 3.11 is installed on the system. I've created virtual python environment with python -m venv ~/.env(because otherwise adafruit-circuitpython-ads1x15 doesn't get installed), activated it with source ~/.env/bin/activate and then installed adafruit-circuitpython-ads1x15 package with pip install adafruit-circuitpython-ads1x15. when I try to run this program(the real program is bigger but this is the smallest program to get the error):

Code:

from numpy import interpimport boardimport timeimport busioimport adafruit_ads1x15.ads1115 as ADSfrom adafruit_ads1x15.analog_in import AnalogIn# Initialize the I2C interfacei2c = busio.I2C(board.SCL, board.SDA)
I get an error:

Code:

(.env) prototype@raspberrypi:~ $ python "/home/prototype/Downloads/RaspberryPiVoltageReporter/TestADS1115Main.py"Traceback (most recent call last):  File "/home/prototype/Downloads/RaspberryPiVoltageReporter/TestADS1115Main.py", line 9, in <module>    i2c = busio.I2C(board.SCL, board.SDA)          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/home/prototype/.env/lib/python3.11/site-packages/busio.py", line 38, in __init__    self.init(scl, sda, frequency)  File "/home/prototype/.env/lib/python3.11/site-packages/busio.py", line 168, in init    raise ValueError(ValueError: No Hardware I2C on (scl,sda)=(3, 2)Valid I2C ports: ((1, 3, 2), (0, 1, 0), (10, 45, 44))(.env) prototype@raspberrypi:~ $ 
The wiring for RPi and ADS1115 is as following:
Image
Image

The 3.3V pin is connected to VDD, ground to ground, SCL to SCL and SDA to SDA. All the wires are tested on continuity and all the wires are fine. There's voltage between VDD and GND pins on ADS1115. The voltage is 2.4V. We're using a 1.5A USB-C charger as power supply, so that's why we have only 2.4V on the 3.3V pin, as I understand. The system also gives us low voltage warnings and sometimes RPi just restarts. Could this be the issue? Tomorrow we'll get a powerful enough power supply and we'll see if that's the issue but I feel like it's not. We also tested it using a battery with the same result. Everything seems to be correct as per guides online. Like this one, for example: https://how2electronics.com/how-to-use- ... pberry-pi/

Also, I noticed that in the error it says: No Hardware I2C on (scl,sda)=(3, 2), but the SCL and SDA pins are 5 and 3 respectively:
Image

But I guess it's for GPIO 3 and GPIO 2. What is wrong here? Is it a broken ADS1115 or something? What can I try to troubleshoot this further? Thank you.

Statistics: Posted by KulaGGin — Tue May 07, 2024 2:39 pm — Replies 0 — Views 29



Viewing all articles
Browse latest Browse all 5335