PyModbus GUI – Modbus Communication with a User Interface
Overview
PyModbus GUI is a Python-based graphical user interface (GUI) for communicating with Modbus devices (RTU/TCP). It allows users to read/write Modbus registers, visualize real-time data, and interact with Modbus-compatible industrial devices effortlessly.
Features
✅ Connect to Modbus RTU & TCP Devices
✅ Read/Write Holding & Input Registers
✅ Real-Time Data Monitoring
✅ User-Friendly GUI (Tkinter)
✅ Error Handling & Connection Diagnostics
1️⃣ Installation
🔹 Prerequisites
Before running the application, make sure you have Python 3.7+ installed. You can check your Python version using:
python --version
🔹 Clone the Repository
git clone https://github.com/your-username/pymodbus-gui.git
cd pymodbus-gui
🔹 Install Dependencies
Run the following command to install the required packages:
pip install -r requirements.txt
2️⃣ How to Run the Application
🔹 Run the GUI
To start the PyModbus GUI, execute:
python main.py
🔹 Modbus Connection Settings
3️⃣ Usage Guide
🔹 Connect to a Modbus Device
- Select Modbus Type: RTU (Serial) or TCP (Ethernet)
- Enter Connection Parameters (COM Port/IP Address, Baud Rate, etc.)
- Click “Connect”
🔹 Read Registers
- Select Function Code (e.g.,
Read Coil Registers (FC3))
- Enter Slave ID, Register Address, and Number of Registers
- Click “Read” to fetch data
🔹 Write Registers
- Select Function Code (e.g.,
Write Single Register (FC6))
- Enter Slave ID, Register Address, and Value
- Click “Write” to send data
4️⃣ Folder Structure
pymodbus-gui/
│── gui/ # GUI-related files
│── modbus/ # Modbus communication scripts
│── main.py # Main script to run the app
│── config.py # Configuration settings
│── utils.py # Utility functions (e.g., logging, error handling)
│── README.md # Project documentation
│── requirements.txt # Python dependencies
│── .gitignore # Files to ignore in Git
5️⃣ Requirements File (requirements.txt)
Ensure you have all necessary dependencies installed:
pymodbus
tkinter
pyserial
Install them with:
pip install -r requirements.txt
6️⃣ Troubleshooting & Common Issues
🔹 No Response from Modbus Device
- Check if the Modbus device is powered on
- Verify the COM port / IP Address & Port
- Ensure Baud Rate, Parity, and Stop Bits match
🔹 Connection Timeout or Failure
- For Modbus RTU: Ensure the correct USB-to-RS485 converter is used
- For Modbus TCP: Make sure the firewall is not blocking port 502
🔹 “ModuleNotFoundError” for pymodbus or pyserial
7️⃣ Future Enhancements 🚀
📌 Graphical Data Plotting (Live Charts for Modbus Data)
📌 CSV Export of Modbus Readings
📌 Modbus Coil Status Control
📌 Multi-Slave Support
8️⃣ License
This project is licensed under the MIT License – feel free to modify and improve it!
9️⃣ Contribution Guidelines
Contributions are welcome! Follow these steps to contribute:
- Fork the Repository
- Create a Feature Branch
git checkout -b feature-branch
- Make Changes & Commit
git add .
git commit -m "Added new feature"
- Push & Create a Pull Request
git push origin feature-branch
- Open a Pull Request (PR) on GitHub
评论