Qwiic, Servos, and CircuitPython

Hi! I purchased a Zio 16 Servo Controller for Qwiic from SparkFun, but it’s not entirely clear how to get this to work with CircuitPython over Qwiic. The board’s docs mention it’s based on the Adafruit PWM Servo Library and operates like their Feather Bonnets, but with Qwiic.

I’ve added a Qwiic Cable to an Arduino Nano RP2040 Connect & other Qwiic / STEMMA QT products work great. But I’m not sure how to get things working with a Zio. I’ve connected a Tower SG92R to Channel 0 on the Zio & have tried running sample CircuitPython servo code:

“”“CircuitPython Essentials Servo standard servo example”“”

import time

import board

import pwmio

from adafruit_motor import servo

create a PWMOut object on Pin A2.

pwm = pwmio.PWMOut(board.A2, duty_cycle=2 ** 15, frequency=50)

Create a servo object, my_servo.

my_servo = servo.Servo(pwm)

while True:

for angle in range(0, 180, 5): # 0 - 180 degrees, 5 degrees at a time.

my_servo.angle = angle

time.sleep(0.05)

for angle in range(180, 0, -5): # 180 - 0 degrees, 5 degrees at a time.

my_servo.angle = angle

time.sleep(0.05)

Since the Nano RP2040 has I2C on pins A4 and A5, I tried subbing out A4 first, then A5 in the code above. Code runs, but nothing happens. Any ideas on how to get this to work with CircuitPython? Thanks!

I could be totally wrong here I think you just need to tell it which channel to use; try adding [0] in the “while True” section…

my_servo[0].angle = angle

Try that and see how it goes - it also might help if you can take a photo of your current wiring setup :smiley:

I tried a new board.

I no longer get the error I got previously.

Now trying this modified Adafruit code:

import time

from adafruit_servokit import ServoKit

Set channels to the number of servo channels on your kit.

8 for FeatherWing, 16 for Shield/HAT/Bonnet.

kit = ServoKit(channels=16)

print(“I’m totally runnin’, bro!”)

while True:

kit.servo[0].angle = 170

time.sleep(1.0)

kit.servo[0].angle = 5

time.sleep(1.0)

Nothing happens - no motor movement. Have tried using the servo via breadboard & servo works. Have also tried another servo on kit.servo[4], still nothing. Here’s a photo:

Have you tried this library?

https://github.com/ZIOCC/Qwiic_Servo_Driver_PCA9685