Modbus Serial on Raspberry Pi

Dear Expert,
I am currently trying to Deploying Projects on Raspberry Pi , and I am facing an issue. The serial ports on Raspberry Pi are in the format: /dev/ttyS0, … However, on the platform, there is only an option for COM1, COM2, … So, how can the platform recognize the serial ports on Raspberry Pi?

Hello Xuan,

Just for clarification, are you attempting to deploy a project on a Raspberry Pi or establish communication between a Raspberry Pi project and a Modbus Serial device?

Best regards,
Team Tatsoft.

I have successfully deployed the project on Raspberry Pi, but I am currently facing issues when connecting the platform on the Pi to the Modbus Serial device as mentioned above

Hello Xuan,

Modbus driver has only COM options to connect.

But there is a procedure you can try. The option is to create a symbolic link between /dev/ttyS0 and a virtual COM port so that the software can select it.

Create a virtual COM port using the tty0tty package as follows:

git clone
cd tty0tty
sudo mknod /dev/tnt0 c 36 0
apt-get install socat
sudo socat -d -d pty,raw,echo=0,link=/dev/tnt0 pty,raw,echo=0,link=/dev/ttyS0

Now you have a virtual COM port at /dev/tnt0 which is redirected to ttyS0.

Open a new terminal and create a symbolic link between /dev/tnt0 and /dev/ttyS0. This will make the system treat the virtual COM port as if it were COM1. Execute the following command (move the std file of ttyS0 to a backup folder before do this):

sudo ln -s /dev/tnt0 /dev/ttyS0

Now, in Modbus settings of FS, select the COM1 port (which is actually the symbolic link to ttyS0).

If you wish to map COM2 port to ttyS1 on the Raspberry Pi, some specific changes need to be made, as shown below:

git clone
cd tty0tty
sudo mknod /dev/tnt1 c 36 1
apt-get install socat
sudo socat -d -d pty,raw,echo=0,link=/dev/tnt1 pty,raw,echo=0,link=/dev/ttyS1
sudo ln -s /dev/tnt1 /dev/ttyS1

If you have any problems, you can search more about tty0tty and see what configuration applies better to your case or find another way to create a symbolic link between /dev/ttyS0 and a virtual COM port.

Please, let us know if it works for you.

Tatsoft Team.