I'm trying to read registers from electricity meters. The meters are either Schneider A9MEM2055 or PM3255. I'm using a Waveshare RS232/485/422 to POE ETH gateway.
I'm getting modbus timeouts, which I find hard to troubleshoot.
It used to work, and now I can't get it to work anymore, although I don't see any reason why.
My code:
with ModbusTcpClient("192.168.1.200", port=4196, timeout=1) as client:
# P3255
result = client.read_holding_registers(0, 16, slave=5)
I double-checked the settings. The IP and port are correct, otherwise I get a network error rather than a modbus timeout.
In the meter config, I checked the slave address (5). The baudrate (9600) and the parity (even) are the ones set in the Waveshare gateway config.
I'm reproducing the setup on my office desk. One gateway, one meter. The bus is about 15cm long. I connected TA to D0/- and TB to D1/+. I even tried switching them just to rule that out.
I'm pretty sure it used to work without either termination or ground, but just in case, I added a 120ohm resistor between the D0/- and D1/+ pins, and a cable between the Waveshare ground and the meter (not sure whether it should be on the 0V or the other one with the strange symbol but I tested both). I'd be curious to know if those are actually needed in this small setup.
The LED on the meter does blink upon modbus request, but the doc says it also blinks in case of line error, so this doesn't tell me much. It doesn't blink if I unplug a RX/TX cable but it does if I switch the cables.
I've been searching for troubleshooting tutos on the web and I'm still stuck there, clueless.
Hopefully I won't have to get my hands on a signal analyzer to dive into the electrical part of it. Not sure how much that would help anyway. I don't think the devices are broken.
From what I described, is there anything wrong with the wiring?
What could be wrong and what else can I check to further investigate this?