ServoKit errors

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
formlessform
 
Posts: 5
Joined: Tue Nov 22, 2022 7:57 pm

ServoKit errors

Post by formlessform »

Hey there, I am trying to run servo motors on the adafruit servo HAT connected to a raspberry pi 4. I have got them running on the HAT on a raspberry pi zero using the following code:

Code: Select all

import time
from adafruit_servokit import ServoKit
kit = ServoKit(channels=16)

kit.servo[0].angle = 180
kit.servo[4].angle = 20
time.sleep(0.5)
kit.servo[4].angle = 0
time.sleep(0.5)
kit.servo[0].angle = 0

I have now got access to a raspberry pi 4 and am wanting to use that as its faster. When I connect the HAT to the raspberry pi 4 and run the exact same code on it as the zero, I get these error:

>>> %Run quad_02.py
Traceback (most recent call last):
  File "/home/jeroth/.local/lib/python3.9/site-packages/adafruit_bus_device/i2c_device.py", line 176, in __probe_for_device
    self.i2c.writeto(self.device_address, b"")
  File "/home/jeroth/.local/lib/python3.9/site-packages/busio.py", line 175, in writeto
    return self._i2c.writeto(address, buffer, stop=stop)
  File "/home/jeroth/.local/lib/python3.9/site-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_PureIO/smbus.py", line 314, 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 "/home/jeroth/.local/lib/python3.9/site-packages/adafruit_bus_device/i2c_device.py", line 182, in __probe_for_device
    self.i2c.readfrom_into(self.device_address, result)
  File "/home/jeroth/.local/lib/python3.9/site-packages/busio.py", line 165, in readfrom_into
    return self._i2c.readfrom_into(address, buffer, stop=stop)
  File "/home/jeroth/.local/lib/python3.9/site-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 181, 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):
  File "/home/jeroth/Robotics/Quad/quad_02.py", line 3, in <module>
    kit = ServoKit(channels=16)
  File "/home/jeroth/.local/lib/python3.9/site-packages/adafruit_servokit.py", line 89, in __init__
    self._pca = PCA9685(
  File "/home/jeroth/.local/lib/python3.9/site-packages/adafruit_pca9685.py", line 141, in __init__
    self.i2c_device = i2c_device.I2CDevice(i2c_bus, address)
  File "/home/jeroth/.local/lib/python3.9/site-packages/adafruit_bus_device/i2c_device.py", line 63, in __init__
    self.__probe_for_device()
  File "/home/jeroth/.local/lib/python3.9/site-packages/adafruit_bus_device/i2c_device.py", line 185, in __probe_for_device
    raise ValueError("No I2C device at address: 0x%x" % self.device_address)
ValueError: No I2C device at address: 0x40
>>> 
Any idea what the problem may be? I have a feeling the pi 4 OS hasnt been setup like the zero with the adafruit modules, but im new and have no idea whats happening. Ive installed all the adafruit modules via the guide on how to setup the HAT. When I do sudo i2cdetect -y 1 I get a blank table, not detecting the HAT.

Any help appreciated.

Thanks.

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: ServoKit errors

Post by adafruit_support_carter »

The address should show up with

Code: Select all

i2cdetect -y 1
Please post a photo of both sides of the HAT removed from the Pi so we can look for any obvious hardware issues.

User avatar
formlessform
 
Posts: 5
Joined: Tue Nov 22, 2022 7:57 pm

Re: ServoKit errors

Post by formlessform »

adafruit_support_carter wrote: Wed Nov 23, 2022 12:26 pm The address should show up with

Code: Select all

i2cdetect -y 1
Please post a photo of both sides of the HAT removed from the Pi so we can look for any obvious hardware issues.
Surely if it was a hardware issue it wouldnt work on the pi zero either?

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: ServoKit errors

Post by adafruit_support_carter »

Maybe. Currently unknown what it could be. It could be hardware related. And posting photos of the HAT will help with determining that.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”