Skip to content

Add support for ModBus RTU over TCP#195

Open
jbeckerwsi wants to merge 2 commits into
veista:masterfrom
jbeckerwsi:master
Open

Add support for ModBus RTU over TCP#195
jbeckerwsi wants to merge 2 commits into
veista:masterfrom
jbeckerwsi:master

Conversation

@jbeckerwsi

@jbeckerwsi jbeckerwsi commented Dec 6, 2025

Copy link
Copy Markdown

with relatively minimal changes, I got the integration to work with a simple serial device server.

The most significant difference is that this mode uses FramerType.RTU

AsyncModbusTcpClient(
            address,
            port=port,
            framer=FramerType.RTU,
        )

I have tested the changes with this setup:
Nilan 300 Comfort Top
Moxa NPort5430 device server, configured in TCP Server mode
Home Assistant 2025.12.1

part of the code was authored by Gemini 3 Pro, this text has been written by hand :)

@jbeckerwsi

Copy link
Copy Markdown
Author

@veista please let me know if you are interested in merging this change.
I've been running this branch for a few months now without any issues.

If you feel uneasy because of the LLM contribution, that's also fine. If that's the case I will consider re-writing by hand or closing the PR.
I mainly wanted to be transparent about it. Given that the change is rather minimal I found it easy enough to convince myself that the code looks good.

@veista

veista commented Mar 31, 2026

Copy link
Copy Markdown
Owner

Hi,

Sorry, I have not had any time to review or test this. This is not a feature that is in high demand and I feel it might confuse people.

If you could share more information about your use-case I will try to find some time to review this.

@jbeckerwsi

jbeckerwsi commented Mar 31, 2026

Copy link
Copy Markdown
Author

Thanks!
Good point about confusing users.

In terms of devices, my use-case looks like this:
image
image

Instead of a bridge that supports MODBUS-RTU to MODBUS-TCP, I have bridge (Serial device server; Moxa NPort5430) that simply does a translation from RS485 to TCP. This means that the data will arrive in chunks different from the Modbus frames and cannot readily be parsed.
For the data to be usable, we need to tell pymodbus to re-frame the data. This is done by telling it to use FramerType.RTU.

The serial server is configured like this:
image
image

The Moxa device is commonly used in industrial and lab settings. For the average home user this device is excessively expensive (~800USD), but sometimes one can get a very good deal on the used market. This made it a very good and reliable choice for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants