IoT Protocol, Modbus

IoT Protocol, Modbus

2021-02-20. Category & Tags: IoT, Modbus, RS232, RS485, Serial, COM, CAN1939, MQTT, Emulator, Simulator

Modbus Protocol #


Serial Port/Line/Connection Simulator/Emulator #

  • Note: Setup / Use (Write & Read) Linux serial ports require root permission

com0com / Null-modem emulator (windows, free) [suggested for win] #

  • serial line/connections

a kernel-mode virtual serial port driver for Windows.

download from sourceforge

free virtual serial ports (windows, free & commercial) #

  • serial line/connections
  • free version limit: port not permanent
  • commercial version: support remote virtual paired ports (based on samba?)

free virtual serial ports

tty0tty (linux, free) [suggested for nix] #

  • serial line/connections (pair of searial ports)
  • need to compile (a bug is fixed by sunny)
The modem status lines are properly emulated, but the “termios” (行规程) settings are not.

virtual serial port driver /vspd (windows, commercial) #

  • serial line/connections (pair of searial ports)

Suports 3 modes: null-modem / loopback, standard, customed wire connections.
14 天试用。汉化版: 虚拟串口驱动

vtty (linux, free) #

  • serial line/connections (pair of searial ports) (not tested)

virtual serial port driver for linux / vspdl (linux, free) #

(having problems to install)

socat (linux, free, build-in) #

actually, not exactlly a good choice for my need.

Modbus Master & Slave Device Debug/Simulation/Emulation Tools #

mthings (windows, free) [suggested for win] #

  • in-app serial line/connections (TCP/UDP only, NO RTU, inside the software only).
  • master & slave devices.

5 分钟入门 MThings 视频;
官方 B 站;
官方博客 CSDN;
基于 MThings 搭建模拟主机调试 MODBUS 从机设备.

  • 主窗口如图,左上角的菜单是控制右边显示的。
  • COM 口是从系统自动识别的,不需要“添加”,MODBUS-RTU 一般配置为无校验(无奇偶校验,因为已有 CRC)。
  • 设置完“设备起始地址”和“设备结束地址”后,点击“添加”,然后选择“模拟主机”还是“模拟从机”,点击确定会自动添加两个地址(含)中间范围内所有的地址 所对应的“主机/上位机”或“从机”到左侧边栏。
  • 中间左边,[M]表示 master/主机/上位机/client,[S]表示 slave/从机/server。



Ref: 面包板 eet-china, (bak)

modbus poll & modebus slave (windows, commercial) #

  • master (Modbus Poll) & slave (Modbus Slave) devices.

中文介绍很多,例如 cnblogs知乎

developed by Witte Software (

modbus mechanic (java jar, thus cross-platform) [suggested for nix] #

  • master & slave
  • GUI & headless
  • RTU scanner

web & java JDK, github

Requires: OpenJDK (both jdk and modbusMechanic are pre-compiled)

Simple guide:

sudo java -jar ./ModbusMechanic.jar

Complete guide:

Add a slave/server with registers: select type (TCP vs RTU) & port & baud rate; Tools > Start Slave Simulator (can start many slave devices); setup a register & value type & a value and “Add” (can add many to one slave).

Option 1. use ModbusMechanic: select type (TCP vs RTU) & port & baud rate (canNOT be the port occupied by slave simulator); set Slave-Node (station address) and Register; set value type; “Transmit Packet”.
Option 2. use other tools, such as modpoll from


modbus-utils / libmodbus-dev #

  • master & slave
cd ~
# download src & dev lib
sudo apt install libmodbus-dev
git clone

# install option 1
$ cd modbus-utils
$ git submodule update --init
$ mkdir build
$ cd build
$ cmake ..
$ make

# OR:
# install option 2
cd modbus-utils/modbus_client
gcc -o modbus_client modbus_client.c -lmodbus -I/usr/include/modbus -I$HOME/modbus-utils/common
cd ../modbus_server
gcc -o modbus_server modbus_server.c -lmodbus -I/usr/include/modbus -I$HOME/modbus-utils/common

ref: CSDN, bak

mbpoll (linux, free) #

  • master only (not tested)
  • totally free but need to compile from source with some careness. (cross-platform library, free & commercial) #

  • master (modpoll) & slave (diagslave) demo & library
  • commercial, 30-day free trial

Pro (free demo): for windows & linux; compile for multi-platforms.
Note: Slave (diagslave) provides fixed all-zero values.
Commercial lib with free master & slave demo:

More Modebus Tools #

  • masters:
    • free: QModMaster, Modbus Tester, Modpoll from proconX, RMMS (Radzio! Modbus Master Simulator).
    • commercial: Simply Modbus Master (RTU and ASCII ), Modbus Poll from modbus tools, ModScan32 from WinTECH.
  • salves:
    • free: ModRSsim2 was forked from MOD_RSSIM (Windows-based Modbus PLC Simulator), pyModSlave based on Qt (video tutorial).
    • commercial: WinModbus (, UnSlave Modbus Slave Simulator.
  • libraries
    • FreeMODBUS: free with separated ASCII/RTU and TCP.
    • libmodbus: BSD 3-clause, for Linux, Mac OS X, FreeBSD, QNX and Win32.
  • another list of useful tools


RS 232 vs. 422 vs. 485 (电气规定的区别) #


数据中心运维管理 in sohu, (bak)