Python and Qwiic and Raspberry Pi Zero

I am due to receive a single relay switch (COM-15093) soon and put togethera simple test program to check access as shown here:

“”"

Test case: Qwiic connected single-relay switch (COM-15093)

“”"

import qwiic

get the list of attached I2C devices

devs = qwiic.list_devices()

print(devs)

if len(devs) > 0:

locate relay switch

relays = [x for x in devs if x[1].upper().find(‘RELAY’) >= 0]

if len(relays) > 0:

recognize relay switch

RelaySwitch = qwiic.create_device(relays[0][0])

if RelaySwich is not None:

print(RelaySwich)

else:

print(“****** RELAY SWITCH CANNOT BE RECOGNIZED ******”)

else:

print(“****** NO RELAYS FOUND ******”)

else:

print(“****** NO DEVICES ATTACHED ******”)

However, past qwiic.create_device, I do not see any clear documentation to, say, turn the relay on and off. Any example code on relay switch activation will be useful.

I am no fan of the Zero movement. It might take a bit of thinking but try pigpio , it has easy to use calls to work with not only digital I / O but I2C, SPI, UART, and servos with a few other tricks thrown in. A feature I like most is that it works on the local gpio as well as the gpio on remote RPi. I posted an example of reading Qwiic joysticks on 2 remote RPi. That might work as an example for you.

Dale