I need to communicate with several modules and devices using the ModBus Protocol and the Raspberry Pi. I am using PyModBus on Raspberry Pi to read/write Modbus function codes. (https://pymodbus.readthedocs.io/en/latest/readme.html)
I was able to communicate Modbus RTU over RS485 with the device but now that I am trying to communicate ModbusTCP over a Ethernet cable and keep running into the following error:
import pymodbus
from pymodbus.client.sync import ModbusTcpClient
client = ModbusTcpClient('127.0.0.1')
connection = client.connect()
Output: ERROR.pymodbus.client.sync: Conection to (127.0.0.1, 502) failed: [Errno 111] connection refused
Any tips or explanation for the error?