Can't get my Arduino UNO to work with <ModbusMaster.h> library.

Hello guys, I have an issue trying to use Arduino UNO for Modbus communication with a certain device I’m trying to get readings from.


  1. ARDUINO UNO Board.
  2. MAXmax485 (DE-RE connected together).
  3. CEM M-RS485 (this is the link:, properly connected to A+ and B-.

The code is as follows:

#include <Arduino.h>
#include <ModbusMaster.h>

#define MODBUS_RX 7
#define MODBUS_TX 8
#define MODBUS_DE 6

ModbusMaster modbusNode;

void preTransmission()
  digitalWrite(MODBUS_DE, HIGH);

void postTransmission()
  digitalWrite(MODBUS_DE, LOW);

void setup() {
  modbusNode.begin(1, Serial);
  // put your setup code here, to run once:

void loop() {
  // put your main code here, to run repeatedly:
  uint8_t resultMain;
    // Read 1 register from address 
  resultMain = modbusNode.readInputRegisters(2710,1);

According to the guide section Configuration variables for the CEM M-RS485 everything is set up. The registry I’m trying to read is 2710, which should return the following (see image attached to the message please).

In the table of section there are also commands that should be readable, but no luck whatsoever.

Some strange values are included in the response (like “SOH”, “EOT” and another one but I think is garbage, I’m not sure).
There’s one value that is relevant though, 0xE2, which corresponds to ku8MBResponseTimedOut (he entire response was not received within the timeout period, ModbusMaster::ku8MBResponseTimeout).

Can someone help find out what the issue might be? Perhaps there’s something I’m not properly setting inside my code, as the physical setup seems to be correct.

Thanks in advance!

  modbusNode.begin(1, Serial);

You cannot use the hardware serial interface for both, the communication with the Modbus device and for your debugging.
I strongly suggest to change the board. Use one with at least one unused hardware serial interface available (Leonardo, Mega2560, etc.).
If you don't need a reliable application you can try to use SoftwareSerial for the tests but I seriously discourage you to use such a solution productively.