Modbus RS485 Error communication

Hi everybody,

I'm tryng to read the Modbus registers of a N1200 (Novus) through RS485.
I'm using an Arduino Mega and a Max485 adapter.

My code is:

#include <ModbusMaster.h>

#define MAX485_DE      2
#define MAX485_RE_NEG      5

// instantiate ModbusMaster object

ModbusMaster node;

void preTransmission()
{

  digitalWrite(MAX485_DE, 1);
  digitalWrite(MAX485_RE_NEG, 1);
}

void postTransmission()
{
  digitalWrite(MAX485_DE, 0);
  digitalWrite(MAX485_RE_NEG, 0);
}

void setup()
{
  pinMode(MAX485_DE, OUTPUT);
  pinMode(MAX485_RE_NEG, OUTPUT);
  
  // Init in receive mode
  digitalWrite(MAX485_DE, 0);
  digitalWrite(MAX485_RE_NEG, 0);

  // Modbus communication runs at 9600 baud
  Serial.begin(9600);

  // Modbus slave ID 1
    node.begin(1, Serial);
  
  // Callbacks allow us to configure the RS485 transceiver correctly
  node.preTransmission(preTransmission);
  node.postTransmission(postTransmission);
  
}

void loop()
{

int Mdelay = 150;   // microdelay

// node.readHoldingRegisters(Adress, Cantidad de registros);

node.readHoldingRegisters(0x0000, 3);
/* node.writeSingleRegister() */

Serial.println(node.getResponseBuffer(0));
Serial.println(node.getResponseBuffer(1));
Serial.println(node.getResponseBuffer(2));

/*char sp = Serial.read();
Serial.println(sp);*/
delay(Mdelay);
node.clearResponseBuffer();

}

The problem is that the serial print shows me error characters (squares )in the first register before the correct value (See image).
I tried with Arduino Mega and Nodemcu (ESP8266) and both have the same problem.
The problem is always with the first register i read, whichever it is.

I think is a library problem but i don't now how to fix it.

From already thank you very much

If you use Serial as your Modbus interface:

  // Modbus slave ID 1
    node.begin(1, Serial);

you must not use it for anything else, e.g. debugging:

Serial.println(node.getResponseBuffer(0));
Serial.println(node.getResponseBuffer(1));
Serial.println(node.getResponseBuffer(2));

As you're using a Mega I suggest you use Serial1 for Modbus to have Serial available for debugging.