A high-performance, web-based Modbus slave device simulator that allows you to create and manage multiple Modbus slave devices simultaneously, supporting both Modbus TCP and Modbus RTU over TCP protocols. Similar to Modbus Slave, but with a modern web interface and enhanced features.
- Introduction
- Key Features
- Use Cases
- System Requirements
- Quick Start
- Configuration
- Web Interface Usage
- Technical Advantages
- License
- Support
Modbus Slave Simulator is a powerful, easy-to-use web-based application that simulates Modbus slave devices. It allows you to quickly create, configure, and manage multiple Modbus slave devices with predefined register values, all accessible through a modern web interface. Whether you're developing Modbus master applications, testing industrial control systems, or learning Modbus protocol, this simulator provides a convenient and flexible solution.
- Dual Protocol Support: Simultaneously support Modbus TCP and Modbus RTU over TCP protocols
- Multiple Device Management: Run and manage multiple Modbus slave devices on the same port, differentiated by slaveId
- Predefined Register Values: Configure initial values for coils, discrete inputs, input registers, and holding registers
- Real-time Event Subscription: Get instant notifications when register values change
- Web-based Interface: Access and control the simulator from any modern web browser
- High Performance: Built with Go for excellent performance and low resource usage
- Easy Configuration: Simple JSON configuration file for device setup
- No Database Required: In-memory data storage, no external dependencies
- Cross-platform: Runs on Windows, Linux, and macOS
- RESTful API: Full RESTful API for programmatic access to all simulator functions
When developing Modbus master applications, you need reliable slave devices to test against. Modbus Slave Simulator provides a convenient way to create and configure multiple slave devices with predefined register values, allowing you to thoroughly test your master application's functionality.
Before deploying Modbus-based industrial control systems, it's essential to test them in a controlled environment. The simulator allows you to simulate various scenarios by configuring different register values and monitoring how your control system responds.
If you're learning Modbus protocol, the simulator provides a safe and easy way to experiment with Modbus communication. You can create slave devices, set register values, and use Modbus master tools to read and write to them, helping you understand how the protocol works.
When integrating multiple Modbus devices into a larger system, you can use the simulator to mock devices that are not yet available, allowing you to test the integration early in the development process.
The simulator is an excellent tool for training sessions and demonstrations. It provides a visual way to show how Modbus communication works, making it easier for trainees to understand the protocol.
- Operating System: Windows 10+, Linux, macOS
- Go: 1.25 or higher (for building from source)
- Web Browser: Chrome, Firefox, Safari, Edge (latest versions)
- Network: Access to the network where Modbus master devices are located
The easiest way to get started is to download the pre-built binary from the Release page:
- Go to the Release page
- Download the appropriate binary for your operating system
- Run the binary file
- Open your web browser and navigate to http://localhost:8080
If you prefer to run from source, follow these steps:
git clone https://github.com/veryinf/modbus-emulator.git
cd modbus-emulator# Build the application
go build -o modbus-slave-simulator ./cmd/main.go
# Run the application with default settings
./modbus-slave-simulator
# Run the application with custom settings
./modbus-slave-simulator --http-addr :9000 --modbus-addr :5020 --config custom-config.json# Run with default settings
go run ./cmd/main.go
# Run with custom settings
go run ./cmd/main.go --http-addr :9000 --modbus-addr :5020 --config custom-config.jsonOpen your web browser and navigate to the HTTP address you specified (default: http://localhost:4000).
You will see the main interface of the Modbus Slave Simulator, where you can start using the simulator immediately.
The simulator supports the following command line options:
| Option | Default | Description |
|---|---|---|
--http-addr |
:4000 |
Specify the HTTP server address |
--modbus-addr |
:502 |
Specify the Modbus TCP server address |
--config |
devices-config.json |
Specify the device configuration file path |
--help, -h |
- | Show help information |
--version, -v |
- | Print the version information |
# Run with custom HTTP port
./modbus-slave-simulator --http-addr :9000
# Run with custom Modbus TCP port
./modbus-slave-simulator --modbus-addr :5020
# Run with custom configuration file
./modbus-slave-simulator --config my-devices.json
# Run with all custom settings
./modbus-slave-simulator --http-addr :9000 --modbus-addr :5020 --config my-devices.jsonThe simulator uses a JSON configuration file (devices-config.json) to define slave devices. Here's an example configuration:
{
"devices": [
{
"slaveId": 1,
"protocol": "tcp",
"title": "PLC Simulator",
"description": "Main PLC simulator",
"points": {
"coils": {
"0": true,
"1": false,
"2": true
},
"holdingRegisters": {
"0": 1234,
"1": 5678,
"2": 9012
}
}
},
{
"slaveId": 2,
"protocol": "rtu-over-tcp",
"title": "RTU Device",
"description": "RTU over TCP device",
"points": {
"discreteInputs": {
"0": true,
"1": false
},
"inputRegisters": {
"0": 3333,
"1": 4444
}
}
}
]
}- slaveId: Modbus slave ID (1-247) - Used to differentiate devices on the same port
- protocol: Protocol type ("tcp" or "rtu-over-tcp")
- title: Human-readable name of the device
- description: Optional description of the device
- points: Predefined values for registers:
- coils: Coil values (true/false)
- discreteInputs: Discrete input values (true/false)
- inputRegisters: Input register values (16-bit integers)
- holdingRegisters: Holding register values (16-bit integers)
The main dashboard displays all configured slave devices, including their status, protocol, port, and slave ID. From here, you can:
- View all slave devices
- Access device details
- Subscribe to real-time events
Clicking on a device in the dashboard takes you to the device details page, where you can:
- View device information
- Set register values
- Monitor register changes
To set a register value:
- Select the device from the dashboard
- Enter the register type (coil or holding register)
- Enter the register address
- Enter the new value
- Click "Set Point"
The simulator supports real-time event subscription, which notifies you when register values change. To subscribe to events:
- Select the device from the dashboard
- Click "Subscribe to Events"
- You will start receiving real-time notifications whenever register values change
Built with Go, the simulator offers excellent performance and low resource usage, allowing you to run multiple devices simultaneously without significant impact on system resources.
The simulator uses a modern architecture with a clear separation between the Modbus protocol handling and the web interface, making it easy to maintain and extend.
The simulator is designed to be reliable and stable, with proper error handling and recovery mechanisms.
With no external dependencies, the simulator is easy to deploy and run on any system with Go installed.
This project is licensed under the MIT License - see the LICENSE file for details.
For issues, questions, or suggestions, please open an issue on GitHub.