MODBUS RTU USING arduino Modbus libarray

Hii there,

  1. i have a question regarding the compatibility of this library, is thhis library compaitible with arduino UNo ?
  2. I was exploring the rs485 library on which this library is dependent for RTU,
#ifndef RS485_DEFAULT_TX_PIN
#ifdef PIN_SERIAL1_TX
#define RS485_DEFAULT_TX_PIN PIN_SERIAL1_TX
#else
#define RS485_DEFAULT_TX_PIN 1
#endif
#endif

#ifdef **AVR**
#define RS485_DEFAULT_DE_PIN 2
#define RS485_DEFAULT_RE_PIN -1
#elif ARDUINO_NANO_RP2040_CONNECT
#define RS485_DEFAULT_DE_PIN A1
#define RS485_DEFAULT_RE_PIN A0
#elif ARDUINO_SAMD_ZERO
#define RS485_DEFAULT_DE_PIN A4
#define RS485_DEFAULT_RE_PIN A5
#else
#ifndef RS485_DEFAULT_DE_PIN
#define RS485_DEFAULT_DE_PIN A6
#define RS485_DEFAULT_RE_PIN A5
#endif
#endif

here i copuldnt find the pin number on which tx, rx pin is cxonnected, however de/re pin is mentiond there

  1. Also does this library needs HARDWARE SERIAL ONMLY, can we run it using software serial ?
  2. Can u please help me finding where is the exact implementation of transmitting and receiving data as i couldnt find it either in modbus / rs485 blibrary.

As a note for the forum helpers, I'll explain that by "this library", @sunilkumar55 is referring to "ArduinoModbus" (I happen to have the missing context since I triaged @sunilkumar55's issue in that repository):

Which Uno are you referring to specifically? Arduino has manufactured multiple boards that contain "Uno" in their name, each of which have significant relevant technical differences:

Since it is the most common, I'll proceed to answer on the assumption you mean Uno R3 (or any of the other ATmega328P-based boards):

Arduino does not provide official support for using this library on the Uno R3. The reason was explained by a developer when the decision was made to do so:

https://github.com/arduino-libraries/ArduinoModbus/pull/106

Drop official support for AVR for this library.

This is imho necessary since even one of our own examples does not link anymore, due to the required memory exceeding the available ressources of the ATMEGA328P based Arduino Nano.

So the reason is not that there is some known technical incompatibility between the library and the Uno R3, but instead that Modbus applications tend to require a significant amount of memory and the AVR boards like the Uno R3 have limited amounts of memory.

So the answer to your question is: "it is probably compatible, but there are no guarantees".

Or in other words: 1 and 0

At this time, it is hardcoded to use the primary hardware serial object. The request for addition of the capability for an arbitrary Stream object to the library is tracked by the developers here:

I'm not able to provide assistance with that. Hopefully one of the other forum members will be able to help.

I believe that the general approach to Modbus RTU using an Arduino UNO is to use a software serial port and the ModbusMaster library which you should be able to install via the library manager.

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