New: the AI firewall watches the whole platform and explains each incident in plain words. See how it works

Reply To: ModbusMaster on a Mega: first meter answers, second one always times out

Look at your setup(): node2 never gets the pre/post transmission callbacks. So when node2 sends, nobody switches the MAX485 into transmit, the request never leaves the Arduino, and meter 2 never answers. Hence 0xE2.

node2.begin(2, Serial1);
node2.preTransmission(preTx);
node2.postTransmission(postTx);

Calling node.begin(2, Serial1) before each read with one object works too, the callbacks stay set. I’d still keep two objects, it reads better.

Also add a short pause between the two reads, 20 to 50 ms. Some meters need a moment after answering before the bus is quiet again.

When you send to Hermetry, if the Mega (or the ESP next to it) is the gateway, put both meters in one message as two children:

v1/gw/telemetry
{"Meter 1": {"values": {"kw": 3.41, "kwh": 1203.4}},
 "Meter 2": {"values": {"kw": 0.87, "kwh": 455.1}}}
Accepted solution♥ 6