0

I would like to ask some opinions regarding i2c communications with pca9685. My i2c1(SDA=GPIO2, SCL=GPIO3) of my rpi 4b is used by my mpu6050, which I had to enable one more i2c channel of my raspberry pi. So, I enabled it through the figure below:enter image description here

I rebooted my rpi 4b after, then successfully detected the address through i2cdetect. enter image description here

I went through to test the device writing some codes, and the giving me some errors which said "ValueError: No I2C device at address: 0x40"

The strange thing is that when I connect pca9685 through the i2c1(SDA=GPIO2, SCL=GPIO3), it works.

My code was:

 import time
 import board
 import busio
 from adafruit_pca9685 import PCA9685
 from adafruit_motor import servo
 i2c = busio.I2C(board.SCL, board.SDA)
 pca = PCA9685(i2c, address = 0x40) 
 pca.frequency = 50
 servo_m = servo.ContinuousServo(pca.channels[0])
 
 servo_m.throttle = -1
 time.sleep(1)
 servo_m.throttle = 0
 time.sleep(1)
 servo_m.throttle = 1
 time.sleep(1)
 servo_m.throttle = 0
 time.sleep(1)

I will post the specific error for a better visualization. Moreover, I will post the picture regarding the configurations of the pins (Black - GND, Orange = SCL, Green = SDA, Red = Vcc, White = V+). Thanks!

Black - GND, Orange = SCL, Green = SDA, Red = Vcc, White = V+ The followings are the error I got:

 Traceback (most recent call last):
 Eile "/usr/local/lib/python3.9/dist-packages/adafruit bus 
 device/i2c device.py", line 176, in _ probe for device
 Self.i2c.writeto(self.device address, b"")
 File "/usr/local/lib/python3.9/dist-packages/busio.py", line 
 175, in writeto
 return self. _i2c.writeto(address, buffer, stop=stop)
 File "/usr/local/lib/python3.9/dist-packages/adafruit 
 blinka/microcontroller/generic linux/i2c.py", line 52, in 
 writeto
 self. _i2c_bus.write_bytes(address, buffer[start:end])
 File "/usr/local/lib/python3.9/dist-packages/Adafruit 
 PureI0/smbus.py", ling 320, in write bytes
 self. _device.write(buf)
 OSError: [Errno 121] Remote I/O error
 During handling of the above exception, another exception 
 occurred:
 Traceback (most recent call last):
 File "/usr/local/lib/python3.9/dist-packages/adafruit bus 
 device/i2c_device.py", line 182, in _ probe for device
 self.i2c.readfrom_into(self.device address, result)
 Eile "/usr/local/lib/python3.9/dist-packages/busio.py", line 
 165, in readfrom_into
 return self. _i2c.readfrom_into(address, buffer, stop=stop)
 File "/usr/local/lib/python3.9/dist-packages/adafruit 
 blinka/microcontroller/generic linux/i2c.py", line 59, in 
 readfrom into
 readin = self. _i2c_bus.read_bytes(address, end - start)
 File "/usr/local/lib/python3.9/dist-packages/Adafruit 
 PureIO/smbus.py", line 187, in read bytes
 return self._device.read (number)
 OSError: [Errno 121] Remote I/O error
 During handling of the above exception, another exception 
 occurred:
 Traceback (most recent call last):
 Eile "/home/bob/FYP/Servo/test110.py", line 13, in <module>
 pca = PCA9685(i2c, address=0x40)
 Eile "/usr/local/lib/python3.9/dist-packages/adafruit 
 pca9685.py", line 141, in _ init
 self.i2c_device = i2c_device.I2CDevice(i2c_bus, address)
 Eile "/usr/local/lib/python3.9/dist-packages/adafruit bus 
 device/i2c_device.py", line 63, in _ init
 self.__probe_for_device()
 Eile "/usr/local/lib/python3.9/dist-packages/adafruit bus 
 device/i2c_device.py", line 185, in __ probe for device
 raise ValueError("No I2C device at address: Ox%x" % 
 self.device_address)
 ValueError: No I2C device at address: 0x40
asked Mar 21, 2023 at 10:03
10
  • 1
    DO NOT post pictures of text post TEXT Commented Mar 21, 2023 at 10:15
  • 3
    I’m voting to close this question because it is in effect a duplicate of raspberrypi.stackexchange.com/questions/142543/… Commented Mar 21, 2023 at 10:19
  • @joan dude its the same person, I have written that question without user info which it was hard to edit the question for me. So, I've chose to rewrite my question with pictures. Commented Mar 21, 2023 at 10:32
  • 1
    I understand that. However this is the same question. You should have supplied the information already requested rather than writing another variation on the question. Commented Mar 21, 2023 at 10:36
  • I see. I will do so, it will be very much appreciated if you can help! Thanks Commented Mar 21, 2023 at 10:39

1 Answer 1

0

The I2C bus requires pull-ups to 3V3 on the SDA and SCL pins.

GPIO 2 (SDA) and GPIO 3 (SCL) have hard-wired 1k8 ohm resistors fitted on the Pi board.

If you use different GPIO for the I2C bus you will need to add external resistors for the required pull-ups.

answered Mar 21, 2023 at 17:40

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.