Modbus wrong data string

Hi , im having very difficult time with modbusmaster so moved to arduinomodbus
modbus master was sending the right string but not able to parse the response
opened an issue but not resolved if can help please visit MODBUS over rs-485 - #18 by Dharani123 . now this arduino modbus is not sending correct query string my code is

#include <ArduinoRS485.h>
#include <ArduinoModbus.h>

int counter = 0;

void setup() {
  while (!Serial);

  if (!ModbusRTUClient.begin(9600)) {
    Serial.println("Failed to start Modbus RTU Client!");
    while (1);

void loop() {



void readInputRegisterValues() {
  Serial.print("Reading input register values ... ");

  if (!ModbusRTUClient.requestFrom(1, INPUT_REGISTERS, 0x05, 4)) {
 Serial.print("failed! ");
  } else {

    while (ModbusRTUClient.available()) {
      Serial.print(' ');


required modbus frame

01 04 00 05 00 04 E1 C8

Modbusframe getting

79 BD F7 FF F5 FF F7 3D 6F FC

Im using pin 1 of arduino for tx that is default serial port 0 pin

2 to control re and de of max485

Don't use ArduinoModbus on the AVR platform! It's designed for the MKR series of Arduinos which have much more memory than the AVRs. As it uses libmodbus (a library designed for the PC platform) it's quite wasteful to memory and therefor a bad choice for AVR Arduinos.

This library uses the first serial port (the one you're using for debugging) on the Mega2560 by default. For DE/RE only pin 2 is used so you might have to change your hardware.

It's not a good idea to change the library if you probably have a hardware problem. There might be problems in a library but don't expect a widely used library to return a timeout error if it's not able to parse the response correctly.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.