16-Channel 12V Relay Module using a Raspberry Pi over i2c. Using the following i2c interface:
Controlling it with Python
When it comes to scripting languages, python’s really hard to beat. It’s simple, quick, and you can do almost anything with “import some-module”.
In this case, I’ve made a class called “relay16” – it’s a really simple wrapper around the smbus calls needed to run the PCA9671 part on the I2C-RELAY16 board. The example code is in the src/RasPi-Python subdirectory of the I2C-RELAY16’s Github project.
Let’s start with the very minimum amount you need to make this work:
#!/usr/bin/python import smbus import relay16 import time bus = smbus.SMBus(1) address = 0x20 relayBoard = relay16.relay16(bus, address) relayBoard.setRelay(1) time.sleep(1) relayBoard.clearRelay(1)