Background info:
I am trying to read data from my energy meter. I have connected a gprs modem to the meter(via rs485) port. This modem sends data via tcp-ip protocol to a specified server and port. On the server(aws ec2 instance) I can see a connection from the device.
Question:
When i try to connect to this device using PyModbus, i am unable to open connection.
from pymodbus.client.sync import ModbusTcpClient as Modbusclient
client= Modbusclient(host=<internal ip of the connection>, port=5025)
if client.connect():
print("Connected")
else:
print("Not Connected")
The response is always "Not Connected".
I have ensured that a) the port is open. b) ip address is whitelisted on the server
Why can't i connect? What am i missing here?
In my particular case, the gprs modem was acting as a serial-over-tcp gateway.So i had to create a serial port and then connect to it. What i ended up doing was: