gpbus is a lightweight Modbus TCP server that exposes Raspberry Pi (and compatible SBC like Orange Pi) GPIOs as Modbus discrete inputs and coils.
Built in Go, it enables industrial tools and SCADA systems to interact with physical GPIO pins over a standard Ethernet network.
- 🔌 Maps GPIO pins to Modbus registers
- 📡 Supports Modbus TCP on configurable port (default:
1502
) - ⚙️ Clean JSON-style configuration
- ⏱️ Fast and efficient GPIO polling every 5ms
- 📦 Single binary deployment (
gpbus
) - 🧩 Suitable for Raspberry Pi, partial support for Orange Pi
- 🛠 Written in Go with periph.io
Example config file.
{
"inputs": [
{
"name": "GPIO1",
"register": 101
},
{
"name": "GPIO2",
"register": 102
}
],
"outputs": [
{
"name": "GPIO13",
"register": 2013
},
{
"name": "GPIO14",
"register": 2014
}
],
"port": 1502
}
📌 Input pins will be readable via Modbus as discrete inputs, while output pins are mapped as coils.
Start the server on default port 1502
:
./gpbus
Or Start with config file in different location
./gpbus -config=myproject/ioconfig.json
-
GPIO handling powered by periph.io — excellent hardware library for Go
-
Modbus server functionality inspired by and based on github.com/tbrandon/mbserver — a robust Modbus TCP/RTU server implementation in Go