November 10, 2024

MODBUS RTU gateway, WiFi, Ethernet, WEB server

In my project to get data from the Swegon Casa HRV, FTX, i needed a new solution to distribute the MODBUS data from the CASA.

The thing is that I have a Raspberry Pi(RPi) that is the central HUB for everything going on in our house, but away from the CASA, and the data is there vizualized in a NodeRed dashboard.

Since the CASA RTU is serial, using Waveshare USB to RS 485, and I didn't want to install a new long cabel to the central RPi I used another RPi which is near the CASA.

Intro
I did alot of Googling for how to reach a serial port over a network but ended up with another solution inspired from this NodeRed node. In the text they are refering to the Modbus Flex server. So with a little tweak to their solution it now works.

Flow explaination



As said in the former post, about CASA, the base for the MODBUS communication is the NodeRed node node-red-contrib-modbus.

The MODBUS client, my central RPi, are doing a HTTP request with an URL

http://test.local:1880/modbus/flex/read?fc=4&address=6200&quantity=12

The URL contains
    MODBUS function code  => 4
    CASA Register address => 6200
    Registers to read     => 12

The MODBUS server, "http in" node, receives the request and forwards the parameters to "Modbus Flex Getter" node which output is sent on.

To make the "http response" node to work it must have the .req & .res objects from the msg object leaving the "http in" node. This is done via the "join" node and the 2 change nodes. This addition has to be made due to that the "Modbus Flex Getter" don't preserves these objects correctly.

Flow
The above flow is found here but please note that its done for the CASA so see it just as a guidance for your solution.

No comments:

Post a Comment

Feel free to leave a comment ! ... but due to a lot of spam comments I have to moderate them. Will reply ASAP !