Raspberry pie 4B uses adafruit_ Pca9685 report error ioerror: [errno 121] remote I / O error solution

First, make sure that python2 or python3’s Adafruit_PCA9685 library has been downloaded. Then understand that the reason for this error is that Adafruit_PCA9685 could not find the external hardware, so think that you did not open I2C permissions (of course, make sure to open I2C permissions first), and then the error is usually in the following format

File "simpletest.py", line 17, in <module>
    pwm = Adafruit_PCA9685.PCA9685()
  File "/usr/local/lib/python3.7/dist-packages/Adafruit_PCA9685/PCA9685.py", line 81, in __init__
    self._device.write8(MODE1, mode1)
  File "/usr/local/lib/python3.7/dist-packages/Adafruit_GPIO/I2C.py", line 114, in write8
    self._bus.write_byte_data(self._address, register, value)
  File "/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO/smbus.py", line 256, in write_byte_data
IOError: [Errno 121] Remote I/O error

At this time we only need to click on the File "/ usr/local/lib/python3.7/dist - packages/Adafruit_PCA9685/PCA9685 py", line 81, in __init__ self. _device. Write8 (MODE1, MODE1) to enter to PCA9685. Py files, the need to look at the red circle place address, use the command line.
Open the command line for raspberry PI Type B input

sudo i2cdetect -y 1

Type A is A change to 0
the 70 is gm's address, 41 is our module address some people is 20, or 40, and 0 d, and 3 c is my another equipment (raspberries pie intelligent housekeeper), if only to connect A device is good, look good, let's modify. Just open the PCA9685 py files address 0 x41 or 0 x40, etc., as the case may be, and then save the changes, then you will find
no permissions, so you can open A command line input


Enter the password, go to root, copy the address of pCA9685.py just now (mine is 0x41), type CD and address, paste it to the command line, press enter, and go to that directory.
if you are a python3.7 user you can use this one directly

cd /usr/local/lib/python3.7/dist-packages/Adafruit_PCA9685/

Py sudo chmod 777 pca9685.py
modify permission
then edit the pca9685.py file just now, modify the PCA9685_ADDRESS in it to the address you found by using sudo i2cdetect -y 1.
then run it and try it!

Read More: