I am trying to get a raspberry pi 4 model B working with across IC2 to a PCA9685 servo motor controller board.

I have followed various tutorials e.g: PCA9685 Tutorial Using the libraray : adafruit_CircuitPython_PCA9685

And modified an example script to give more debug information:

# This simple test outputs a 50% duty cycle PWM single on the 0th channel. Connect an LED and
# resistor in series to the pin to visualize duty cycle changes and its impact on brightness.

from board import SCL, SDA
import busio

# Import the PCA9685 module.
from adafruit_pca9685 import PCA9685

print("Expected SCL and SDA from board def: SCL: %s SDA: %s, Should be 3 and 2 " % (SCL, SDA))
i2c_bus = None
    i2c_bus = busio.I2C(SCL, SDA)        
except ValueError:

print("Created busio.IC2 interface to correct SCL and SDA lines without error")

# Create a simple PCA9685 class instance.
pca = PCA9685(i2c_bus)
print("pca PCA9685 interface created")

freq = 60
print("Attempting to set PWM frequency to: %s" % (freq))
# Set the PWM frequency to 60hz.
    pca.frequency = freq
    print("Succesfully set frequency..")
except ValueError:
    print("Frequency set failed, drInitialising ic2 bus interface")

# Set the PWM duty cycle for channel zero to 50%. duty_cycle is 16 bits to match other PWM objects
# but the PCA9685 will only actually give 12 bits of resolution.
pca.channels[0].duty_cycle = 0x7FFF

I have ran various diagnostics, most notably verifying the SDL and SCL connections via the follow image: ic2 diagnostic

On running the script, I error out at 'pca.frequency = freq', The board pca9685 power light turns to 'off' state, and I get the error: Errno 121 Remote I/O error, an image of the stack trace: Error stack trace

After this error, running i2detect -y 1 once more responds with : Post error ic2 stan This issue can only be corrected by reattaching the ground pin to the board - (pin 9 to GND)

I've had read only that the issue could be assumptions in the base libraries in regarding to clock, but I'm unsure what a fix could be. I strongly doubt there is an issue with the hardware considering results.

Any advice welcome , perhaps alternative libraries or known bug fixes?

  • 1
    Ah, "Errno 121 Remote I/O error", is a very common I2C I/O error, usually caused by any one or more of the following errors: (1) Incorrect wiring of wrong pins. Use a multi-meter to check open/short of pins, (2) Wiring too long (try to keep connecting wires shorter than 30cm, .... My answer to the following Stack Overflow question might help.
    – tlfong01
    Nov 14, 2020 at 13:30
  • Sorry, I forgot the link: stackoverflow.com/questions/62757687/….
    – tlfong01
    Nov 14, 2020 at 14:16
  • 1
    The bus speed might be a problem. If the Raspi drives the clock line with, say 200 000 Hz but the control only can handle 100 000 Hz the communcation is impossible. Older Raspis (as far as I know) have an error, that prevents them from setting a higher speed than 100 000 Hz. Version 4 might not have this restriction. Perhaps its default speed is 400 000 Hz. See how to configure the speed raspberrypi-spy.co.uk/2018/02/change-raspberry-pi-i2c-bus-speed Perhaps this might help. Cheers. Nov 14, 2020 at 15:25
  • 1
    @tlfong01 the wires are less than 5 cm in length, And sure the fact that I have 40 and 70 registered proves there isn't a wiring problem? Nov 14, 2020 at 15:55
  • 1
    @PeterPaulKiefer thanks! I'll give it a go, looking into the libraries I have only found max pwm frequency, it would make sense for baud rate error to then send an incorrect signal and see the result I am. Nov 14, 2020 at 15:56

1 Answer 1


After purchasing an Arduino and replicating the same errors and conducted a thorough debug of all connections, only to discover two wires failed continuity tests.

What was mis-lead here is the LED on the PCA9685 draws some current from the bus lanes and therefore appears active, then on communication start it cuts off due to not having enough voltage/Current from the main supply.

Lessons learned: always start with the basics in diagnostics!

Your Answer

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

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