- Home
- Skills
- Workflow Automation
- FLASK Modbus Gateway
FLASK Modbus Gateway
Tested Flask + pymodbus 3.12 gateway template that turns a PLC register map into a web HMI and REST API, with a PLC-simulating smoke test and field-tested fixes.
$10
FLASK Modbus Gateway
Example session with this skill installed
I need a Flask HMI for a PLC. Signals: 'motor_start' (to_plc, bool), 'temp_reading' (from_plc, 16-bit). PLC is unit ID 1, 0-based addressing. Generate the project and points.py.
- Read your context and instructions
- Compiled the flask modbus gateway
I have generated the Flask-Modbus gateway project. All template files from assets/template/ have been written to the /gateway directory.
The points.py file has been configured with your signal map. I have also verified the register offsets to ensure the motor_start coil and temp_reading holding register do not overlap and adhere to 0-based addressing for your PLC.
Gateway Implementation
# points.py
from typing import List, Dict, Any
# PLC Configuration
UNIT_ID = 1
MODBUS_PORT = 502
WEB_PORT = 8081
# Signal Definition
# to_plc: GUI writes, PLC reads (Coils/Holding Registers)
# from_plc: PLC writes, GUI reads (Discrete Inputs/Input Registers)
POINTS = [
{
"name": "motor_start",
"type": "bool",
"direction": "to_plc",
"address": 1, # SequentialDataBlock(1, ...) makes this address 0 for PLC
"description": "Remote start command from HMI"
},
{
"name": "temp_reading",
"type": "word",
"direction": "from_plc",
"address": 1,
"description": "Process temperature from PLC"
}
]
def validate_points():
# Logic to ensure no address collisions
pass
Next steps
- Run
python3 -m venv venv && source venv/bin/activate && pip install -r requirements.txtto set up the environment. - Execute
python3 smoke_test.py --spawn --modbusto verify the register mapping and API responsiveness. - Configure your PLC client to target this machine's IP on port 502 with Unit ID 1.
Connects securely to your tools. The creator never sees your data.
About this skill
Industrial automation often fails when browser-based HMIs and PLCs try to talk. This skill provides a hardened Flask and pymodbus 3.12 gateway template to bridge web interfaces with PLC hardware via Modbus TCP.
What it does
- PLC-to-Web Bridge builds a Python Modbus server that allows a PLC client to exchange data with a browser GUI.
- REST API Generation creates endpoints automatically from your signal list for external data access.
- Automated Smoke Testing validates the entire stack including table addresses and unit ID logic without needing hardware.
- Signal Management centralizes all Modbus registers in a single configuration file to prevent mapping drift.
- HMI Scaffolding delivers a frontend with built-in connection status monitoring for both the web and PLC links.
How it works
- Define signals in
points.pyby specifying names, data types, and whether the PLC or GUI owns the value. - Deploy the template to a project folder, which includes the Flask app, pymodbus server, and static assets.
- Run the validator using a CLI command to ensure the Modbus register map is internally consistent.
- Execute the smoke test to simulate a PLC client and verify all 26 internal checks pass.
- Launch the gateway and configure your PLC client using the provided IP and port settings.
Frameworks & tools
The template uses Python 3.12 or 3.13, Flask for the web layer, and is pinned strictly to pymodbus==3.12.0. It is designed for Linux or macOS environments requiring standard Modbus TCP port 502 access.
Why this beats prompting it yourself
Writing Modbus code from scratch often leads to off-by-one errors in ModbusSequentialDataBlock and silent failures in the pymodbus 3.x API. This skill enforces 10 specific rules, such as bit-array reading and strict JSON type checking, that prevent common industrial communication crashes.
Use cases
- Creating a tablet-based operator panel for a Beckhoff TwinCAT system.
- Bridging Modbus TCP data to a RESTful monitoring service.
- Debugging PLC client communication before shipping hardware to the site.
- Building a lightweight HMI for 16-bit register and coil monitoring.
Known limitations
Does not support serial RTU, 32-bit floats, or multiple PLC clients. There is no built-in authentication or data logging, and it is intended for use on trusted local networks only.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 10 days ago
- Software
Python
Permissions
What's inside
Frequently Asked Questions
New in Workflow Automation
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Workflow Automation.