A very sensible question.
Executive summary: you don’t need any hardware, just the IP address and port number of the heating system/controller, which should be connected to your local network along with your Raspberry Pi.
Detail:
To work with a Modbus device we need to talk to it and either ask what is in a register or try and write a value to a register. Devices are mostly slaves, where they sit there and wait to be spoken to. As it is a ‘bus’ one device (and one only) can be a master and initiate the conversation. Many slave devices can sit on the bus, each with an ID address, and wait to be spoken to. Speaking therefore needs an address (ID) a register and type of register, and if writing, the data to write.
All this is designed to run over some physical communication, and for industrial controllers that is usually a serial coms link. The basic one is RS232, but these days most devices are designed to use RS485. This is two wires (plus a ground if you insist) where the wires can be +/- or -/+, and the switching between the two states provides the basic binary communication. RS485 is a standard that operates over long distances for, mostly, industrial use. Devices are all connected to two wires in a long daisy chain.
Modbus started out by being over RS485, and most devices still use this standard. Since ethernet networks have become common, Modbus can also operate over TCP (the communication protocol used in computer networks). Modbus therefore now comes in two flavours - Modbus over serial (dedicated pair of wires) and Modbus over TCP (network/internet).
The good news is that, as long as you have the right hardware, the software usually looks after the rest.
So - for serial communication a device will have a serial port to which we need to connect our computer via a similar serial port. If both serial ports use RS485, and we get the baud rate, parity, stop bits and the wires round the right way, it will all work. Software (say HA) on my computer can format the correct things to say in Modbus to ask what is in register 1001 on device 1, push this to my computer serial port driver so that the serial port waggles the lines up and down correctly, the device I am talking to can read the waggles, reformat this into Modbus, and the software running on the device recognises this as ‘please tell me what is in register 1001’ and it response in reverse.
All well and good, but what about Modbus over TCP I hear you ask.
Well, most home computers these days don’t have old type RS232 serial ports. Bit of a waste as no one uses them. So most of us buy little USB dongles. USB ports are actually serial ports, but almost everything uses them now and all we have to do is plug them in. Purchase a USB to RS485 dongle/device/thingy adaptor and your computer can be set up with a serial port that talks RS485. Wire that to the Modbus device RS485 port, and bingo, Bob’s your uncle!
All computers though do have TCP ports - the network port. This is either hard wired or WiFi, but this can be used to carry Modbus commands, just over TCP rather than RS485 serial.
How does this work? Well you need no adaptor on the computer provided you have a network connection. Your computer can talk over TCP to any IP address on the network. The practical bit now sits with the device you are trying to talk to, since that has to expose Modbus to the world either via a serial port, or via a TCP network port eg over WiFi. There has to be an address, both IP and port, where Modbus commands can be received.
I have a solar inverter that is a Modbus device. It has a RS485 port, into which usually sits a data logging stick. The stick talks Modbus over RS485, and then talks over the network to the internet.
To connect to my solar inverter device I can use a USB to RS485 dongle on my HA and a pair of wires from the dongle to the RS485 port
OK but the inverter is in the garage, so I bought an RS485 to ethernet adaptor instead. The adaptor RS485 port is wired to the inverter RS485 port, the adaptor ethernet port is plugged into my router/network, and my HA talks over TCP.
The data logging stick I have is effectively also a RS485/TCP dongle. Inside the stick is a server port that can communicate Modbus TCP. To use that all I need to know is the IP address of the stick (set up as static) and the port of the inbuilt server.
To make life easier I do all my Modbus work on Node-Red. With Node-Red I don’t need to keep rebooting HA every the I change the config etc. Getting these things to work can be fiddly. Node red is, I think, also a great deal simpler to use.
I have HA running on an odroid with Node-Red as an add-on, but I also have a Raspberry Pi running Node-Red for development. Here is the (incredibly complex) code I need to connect Modbus to my inverter data logging stick, over TCP.
No hardware, no wires.
Modbus getter node (from the node-red-contrib-modbus set) - nothing else required.
Unit ID is the ‘address’ of the slave unit. Most likely to be 1 but do check your documentation. Even though this is virtual over a TCP network, the rules for uniquely individually addressed slaves still apply.
FC type, register address, quantity are defined by your heating device controller.
The working bit is the server. This is used to create a config node.
Set the Type up as TCP
Set the host as IP address of your controller, and the port as given in documentation
TCP type default works for me
Everything else was as default and generally only change things if they don’t work.
When enabled correctly the Modbus node will show ‘active’ if connected and working.
Should take all of 5 minutes to setup.