This repository contains a control class and other example code for the RLY-8 8 channel PoE ethernet (and USB) relay controller by DFRobot. See this link to their wiki-page for more information about the device.
The code on this repository was originally written by Geréb Róbert in Python 2 (see this repository). I've ported it to Python 3 and added slightly more functionality and documentation.
RLY8Class.py
: Control class for the relaymain.py
: A basic Python-file which uses theRLY8Class.py
file to control the relayrly-8.py
: Stand-alone example to control the relayrly-8_simple.py
: Stand-alone file to turn on/off relays by arguments (ex.:python rly-8_simple.py 1=on 2=off
)
from RLY8Class import RLY8
# Define the IP and port to connect to
# (DHCP is enabled by default, unfortunately the device doesn't have a hostname)
ADDR = ("192.168.0.202", 2000)
# Instantiate the RLY-8 object
rly8 = RLY8(ADDR)
# Print some information
print(rly8.name)
print(rly8.netconf)
print(rly8.version)
print(rly8.baudrate)
# Change some basic settings
rly8.setName("DFRobot2") # Default: "DFRobot"
rly8.setBaudrate(9600) # Default: 115200
# Enable a relay (relays are numbered 1 to 8, states are "on" or "off")
rly8.setRelayStatus(1, "on")
# Print the status of a relay
print(rly8.relay1)