Driver for the Arduino+W5500 network-controlled 4-channel relay board
Project description
rf-bench-drivers-arduino-relay-board
Python driver for the Arduino+W5500 network-controlled 4-channel relay
board. See hardware/arduino-relay-board/
for the firmware.
Status: ✅ tested on hardware 2026-06-25 against the board running at
10.1.1.36. Full acceptance test inhardware/arduino-relay-board/test_relays.pypasses against the shipped firmware.
Install
pip install -e ~/Dropbox/build/rf-bench/drivers/arduino-relay-board
Once published to PyPI:
pip install rf-bench-drivers-arduino-relay-board
Quick start
from rf_bench.arduino_relay_board import ArduinoRelayBoard
with ArduinoRelayBoard("10.1.1.36") as r:
print(r.idn()) # N0GQ,ArduinoRelayBoard,1.0,2026,id=1
r.on(1) # energize relay 1
r.on(3) # energize relay 3
print(f"{r.status():04b}") # → "0101" (relays 1 and 3 on)
r.pulse_high(2, 250) # energize relay 2 for 250 ms, then off
print(r.get_state(1)) # → True
print(r.status_all()) # → (True, False, True, False)
r.off(1)
r.reset() # all off
API
class ArduinoRelayBoard:
NUM_RELAYS = 4
def __init__(self, host, port=5025, timeout=2.0, auto_connect=True): ...
def connect(self) -> None
def close(self) -> None
def idn(self) -> str
def help(self) -> str
def on(self, relay: int) -> None # relay = 1..4
def off(self, relay: int) -> None
def pulse_high(self, relay: int, duration_ms: int) -> None
def pulse_low(self, relay: int, duration_ms: int) -> None
def get_state(self, relay: int) -> bool
def status(self) -> int # bitmask, bit 0 = relay 1
def status_all(self) -> tuple[bool, ...] # length 4
def reset(self) -> None
def all_off(self) -> None # alias for reset()
All methods are thread-safe — internal threading.Lock serializes
access to the TCP socket.
Errors
ArduinoRelayBoardError— board returnedERR: …, or the socket was closed unexpectedly.ArduinoRelayBoardTimeoutError— no response withintimeoutseconds. Subclass ofArduinoRelayBoardError.ValueError— bad relay index (not 1..4) or non-positive duration.
Pulse semantics
pulse_high(n, ms) and pulse_low(n, ms) return immediately. The
board schedules the revert internally using millis(), so the timed
behaviour is independent of network latency or Python-side scheduling.
pulse_high(1, 30000)— relay 1 energized now, de-energized 30 s later. The driver returns in milliseconds; the board handles the delay.pulse_low(1, 250)— relay 1 de-energized now, re-energized 250 ms later. Useful when a relay was previously commandedON.
A subsequent on(), off(), or pulse_*() on the same relay cancels
any pulse in flight.
Related
hardware/arduino-relay-board/— board firmware.drivers/relay/— XL9535 I²C 16-channel relay expander (different hardware: local I²C via Bus Pirate, not Ethernet).projects/esp32/scpi-relay/— ESP32+WiFi equivalent.
License
GPL-3.0-or-later, same as the rest of rf-bench.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rf_bench_drivers_arduino_relay_board-0.1.0.tar.gz.
File metadata
- Download URL: rf_bench_drivers_arduino_relay_board-0.1.0.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28500cd0e7cf16d9f1e5ef3bb49594964f8df5e2d062fd9ca95acbaed838a354
|
|
| MD5 |
8ac27ad0ec5f6c388d4ac3533b4bd403
|
|
| BLAKE2b-256 |
236226b6c71639c4f417f1fb2409e19f6b6e41d3a662798fac0826c362bf8338
|
File details
Details for the file rf_bench_drivers_arduino_relay_board-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rf_bench_drivers_arduino_relay_board-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8ca55d6e9949fb928234328092b6e82e6348f76586d724202dbe7d643d29603
|
|
| MD5 |
eb1de56d8d6c5416ad1094d697dd5eae
|
|
| BLAKE2b-256 |
7a5d848623458fdf00918b0d10171c66e0370d810fc878e02265f368c7421f2e
|