Modbus Library for Arduino Zero?

Hi,

Can anybody recommend a Modbus/TCP library compatible with Arduino Zero?

Thanks

ArduinoModbus, written for the MKR series but that's almost the same hardware. Available in the Library Manager.

Thanks... I ve already tried that but examples wont compile for zero
Probably need to make changes to the libraries but i was trying to avoid that..

In file included from D:\Dropbox\MCU\Controller_Firmware\libraries\ArduinoRS485\src\RS485.cpp:20:0:
D:\Dropbox\MCU\Controller_Firmware\libraries\ArduinoRS485\src\RS485.h:35:30: error: 'A6' was not declared in this scope
 #define RS485_DEFAULT_DE_PIN A6
                              ^
D:\Dropbox\MCU\Controller_Firmware\libraries\ArduinoRS485\src\RS485.cpp:189:62: note: in expansion of macro 'RS485_DEFAULT_DE_PIN'
 RS485Class RS485(SERIAL_PORT_HARDWARE, RS485_DEFAULT_TX_PIN, RS485_DEFAULT_DE_PIN, RS485_DEFAULT_RE_PIN);
                                                              ^~~~~~~~~~~~~~~~~~~~
D:\Dropbox\MCU\Controller_Firmware\libraries\ArduinoRS485\src\RS485.h:35:30: note: suggested alternative: 'A5'
 #define RS485_DEFAULT_DE_PIN A6
                              ^
D:\Dropbox\MCU\Controller_Firmware\libraries\ArduinoRS485\src\RS485.cpp:189:62: note: in expansion of macro 'RS485_DEFAULT_DE_PIN'
 RS485Class RS485(SERIAL_PORT_HARDWARE, RS485_DEFAULT_TX_PIN, RS485_DEFAULT_DE_PIN, RS485_DEFAULT_RE_PIN);
                                                              ^~~~~~~~~~~~~~~~~~~~
Multiple libraries were found for "Ethernet.h"
 Used: D:\Dropbox\MCU\Controller_Firmware\libraries\Ethernet
 Not used: C:\Program Files (x86)\Arduino\libraries\Ethernet
Using library SPI at version 1.0 in folder: C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.12\libraries\SPI 
Using library Ethernet at version 2.0.0 in folder: D:\Dropbox\MCU\Controller_Firmware\libraries\Ethernet 
Using library ArduinoRS485 at version 1.0.2 in folder: D:\Dropbox\MCU\Controller_Firmware\libraries\ArduinoRS485 
Using library ArduinoModbus at version 1.0.6 in folder: D:\Dropbox\MCU\Controller_Firmware\libraries\ArduinoModbus 
exit status 1
Error compiling for board Arduino Zero (Native USB Port).

Unfortunately the library isn't written with portability in mind, so you have to modify one line in ArduinoRS485.h:

#define RS485_DEFAULT_DE_PIN A6

should become

#define RS485_DEFAULT_DE_PIN A5

After that change the example should compile.

Another part of the output is probably more dangerous:

You should ensure that the Arduino version of Ethernet.h is used.

Thanks very much!

I had developed my own modbus interrogation code but it periodically crushed so I decided to try a ready made library.

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