https://github.com/fescron/dfrobot-rly8-python3
DFRobot RLY-8 8 channel PoE ethernet controller Python 3 Control Class and Example Code
https://github.com/fescron/dfrobot-rly8-python3
controller dfrobot ethernet json poe python python3 relay rly-8 rly8 usb
Last synced: 6 months ago
JSON representation
DFRobot RLY-8 8 channel PoE ethernet controller Python 3 Control Class and Example Code
- Host: GitHub
- URL: https://github.com/fescron/dfrobot-rly8-python3
- Owner: Fescron
- License: mit
- Created: 2024-04-07T07:10:59.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-20T09:16:46.000Z (about 1 year ago)
- Last Synced: 2024-07-20T10:32:08.586Z (about 1 year ago)
- Topics: controller, dfrobot, ethernet, json, poe, python, python3, relay, rly-8, rly8, usb
- Language: Python
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DFRobot RLY-8 Python 3 Control Class and Example Code
This repository contains a control class and other example code for the [RLY-8](https://www.dfrobot.com/product-1218.html) 8 channel PoE ethernet (and USB) relay controller by [DFRobot](https://www.dfrobot.com). See [this](https://wiki.dfrobot.com/RLY-8-POE_Relay_Controller_DFR0289) 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](https://github.com/uponai/dfrobot-RLY-8-python) repository). I've ported it to Python 3 and added slightly more functionality and documentation.
## Repository Files
- `RLY8Class.py`: Control class for the relay
- `main.py`: A basic Python-file which uses the `RLY8Class.py` file to control the relay
- `rly-8.py`: Stand-alone example to control the relay
- `rly-8_simple.py`: Stand-alone file to turn on/off relays by arguments (ex.: `python rly-8_simple.py 1=on 2=off`)
## `RLY8Class.py` usage
```python
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)
```