Repository navigation
Plugin modbus stations
Controls OSPy station outputs through Modbus RTU serial relay boards.
| Item | Value |
|---|---|
| Version | 1.0.0 |
| Category | Hardware, displays and outputs |
| Author | Martin Pihrt |
| License | GPL-3.0 |
| OSPy |
3.0.211 or newer |
| Python |
3.8 or newer |
| Permissions |
files, system
|
| Hardware | platforms: raspberry_pi, beaglebone, linux; interfaces: serial
|
| Dependencies | None |
| Python/OS packages |
serial / pyserial (required), blinker (required) |
| Interfaces | No provider or mobile API declared |
| Source | Open the plug-in directory |
Controls OSPy station outputs through Modbus RTU serial relay boards.
Tested in Python 3
This plugin can be used to control devices via modbus protocol (8ch relay boards). Requires to be installed in to the Linux system. Use: sudo apt install python3-serial and restart ospy!
The plug-in includes an OSPy plugin.json manifest and implements the common lifecycle and health() interfaces. Its former one-shot thread was replaced by explicit registration and removal of the three station signal receivers, which prevents duplicate Modbus commands after a plug-in restart. Diagnostics reports pyserial availability, non-secret serial settings, receiver count, and the latest successful command or communication error. Serial handles are closed after every station command.
-
Check Use Control: If checked enabled plugin is enabled.
-
Check Enable logging: If checked enabled logging is enabled.
-
Number of relay boards: Enter how many relay boards are used (each board has 8 relay outputs). Ex: 2 means 16 outputs and 2 boards.
-
Serial port: Specify which port will be used for communication. Use the "system information" plugin to find the port. Example: /dev/ttyUSB0
-
Communication speed: Enter the speed at which the connected modules communicate. Example: 4800, 9600, 19200, 38400, 57600, 115200, 128000, 256000 (in Baud).
-
Status: Status window from the plugin.
The following notes are generated from the help page shipped with this plug-in. Field names are also explained directly in the OSPy settings page.
Modbus RTU Relay
The industrial module controlled via the RS485 bus uses the Modbus RTU protocol.
Buy example on
The durable case made of high-quality ABS plastic enables easy mounting on the DIN bar.
Thanks to the configurable device address (1~255) on the RS485 bus, multiple devices can be cascaded. If many devices are cascaded or the communication distance is too long, RS485 repeaters should be used.
Relay connection diagram. Rated current of the built-in relay contacts: up to 10A 250V AC nebo 30 V DC. Direct control of household appliances: 230 V AC or devices below 30 V DC.
Built-in Optocoupler isolation prevents interference from an external high-voltage circuit connected to the relay.
Anti-reverse circuit prevents accidental damage to the circuit by incorrect connection.
High quality relay, contact rating: ≤10A 250V AC/30V DC.
ABS plastic cover for rail mounting, easy to install, safe to use.
3 LEDs for indicating MCU status and signal transmission status.
Supply voltage: 5 V.
Communication interface: RS485.
Baud rate: 4800, 9600, 19200, 38400, 57600, 115200, 128000, 256000.
Default communication format: 9600, N, 8, 1.
Form of contacts: 1NO 1NC.
Communication protocol: Standard Modbus RTU protocol.
RS485 address: 1-255.
Number of relay channels: 8.
RS485 terminal protection: 600 W lightning arrester and surge protection, 15 KV ESD protection (dedicated solder pads with 120 R compensation resistor).
LED indicators
- STA
MCU indicator, flashes when the MCU is working normally.
- TXD
TX indicator, lights up when sending data.
- RXD
RX indicator, lights up when receiving data.
Command format
The command contains 8 bytes.
Byte 1:Device Address
Byte 2:Function code
Byte 3 4:Address of register (big-endian)
Byte 5 6:data of register (big-endian)
Byte 7 8:CRC16 cheksum (little-endian)
Function code
01 Read state of Relay
03 Read address, revision
05 Write single Relay
06 Configure baudrate, address
0F Write all Relays
Examples: [Device with address 01]: Open Relay 0: 01 05 00 00 FF 00 8C 3A
Close Relay 0: 01 05 00 00 00 00 CD CA
Open Relay 1: 01 05 00 01 FF 00 DD FA
Close Relay 1: 01 05 00 01 00 00 9C 0A
Open Relay 2: 01 05 00 02 FF 00 2D FA
Close Relay 2: 01 05 00 02 00 00 6C 0A
Open Relay 3: 01 05 00 03 FF 00 7C 3A
Close Relay 3: 01 05 00 03 00 00 3D CA
Flip Relay 0: 01 05 00 00 55 00 F2 9A
Flip Relay 1: 01 05 00 01 55 00 A3 5A
Flip Relay 2: 01 05 00 02 55 00 53 5A
Flip Relay 3: 01 05 00 03 55 00 02 9A
Waveshare.com/wiki
USB TO RS485
This is an industrial USB to RS485 converter with original FT232RL inside.
Check OSPy → Diagnostics first and remove passwords, tokens, private addresses and other secrets before sharing logs. Report reproducible plug-in problems in the OSPy-plugins issue tracker.
Start
Reference
Catalog sections









