Arduino Modbus Library usage

I Have downloaded a third party library for performing modbus operations.
The library is called arduino-Tools40-master

but When i am trying to run this code i am getting a undefined reference.
May be the IDE is not able to detect the files in SRC folder.

This is the code

Copyright (c) 2018 Boot&Work Corp., S.L. All rights reserved

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see

#include <Ethernet.h>
#include <ModbusTCPMaster.h>

// Ethernet configuration values
uint8_t mac = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(10, 10, 10, 89);
IPAddress slaveIp(10, 10, 10, 88);
uint16_t slavePort = 502;

// Define the ModbusTCPMaster object
ModbusTCPMaster modbus;

// Ethernet client object used to connect to the slave
EthernetClient slave;

uint32_t lastSentTime = 0UL;

void setup() {

// Begin Ethernet
Ethernet.begin(mac, ip);

// NOTE: it is not necessary to start the modbus master object

void loop() {
// Connect to slave if not connected
// The ethernet connection is managed by the application, not by the library
// In this case the connection is opened once
if (!slave.connected()) {

slave.connect(slaveIp, slavePort);
if (slave.connected()) {

// Send a request every 1000ms if connected to slave
if (slave.connected()) {
if (millis() - lastSentTime > 1000) {
// Send a Read Discrete Inputs request to the slave with address 31
// It requests for 7 discrete inputs starting at address 0
// IMPORTANT: all read and write functions start a Modbus transmission, but they are not
// blocking, so you can continue the program while the Modbus functions work. To check for
// available responses, call modbus.available() function often.
if (!modbus.readDiscreteInputs(slave, 0, 0, 7)) {
// Failure treatment
Serial.println(“Request fail”);

lastSentTime = millis();

// Check available responses often
if (modbus.isWaitingResponse()) {
ModbusResponse response = modbus.available();
if (response) {
if (response.hasError()) {
// Response failure treatment. You can use response.getErrorCode()
// to get the error code.
Serial.print("Error ");
} else {
// Get the discrete inputs values from the response
Serial.print("Discrete inputs values: ");
for (int i = 0; i < 7; ++i) {

And this is the error message

In file included from /root/Downloads/arduino-1.8.10/libraries/Ethernet/src/Dns.cpp:8:0:
/root/Downloads/arduino-1.8.10/libraries/Ethernet/src/Dns.cpp: In member function ‘uint16_t DNSClient::BuildRequest(const char*)’:
/root/Downloads/arduino-1.8.10/libraries/Ethernet/src/utility/w5100.h:457:25: warning: result of ‘(256 << 8)’ requires 18 bits to represent, but ‘int’ only has 16 bits [-Wshift-overflow=]
#define htons(x) ( (((x)<<8)&0xFF00) | (((x)>>8)&0xFF) )

/root/Downloads/arduino-1.8.10/libraries/Ethernet/src/Dns.cpp:164:18: note: in expansion of macro 'htons'
/tmp/ccGFTU72.ltrans0.ltrans.o: In function `global constructors keyed to 65535_0_ModbusTCPMasterReadDiscreteInputs.ino.cpp.o.3423':
Multiple libraries were found for "Ethernet.h"
<artificial>:(.text.startup+0x132): undefined reference to `ModbusTCPMaster::ModbusTCPMaster()'
Used: /root/Downloads/arduino-1.8.10/libraries/Ethernet
/tmp/ccGFTU72.ltrans0.ltrans.o: In function `loop':
Multiple libraries were found for "ModbusTCPMaster.h"
Used: /root/Arduino/libraries/arduino-Tools40-master
Not used: /root/Downloads/arduino-1.8.10/hardware/arduino/avr/libraries/arduino-Tools40-master
Multiple libraries were found for "SPI.h"
Used: /root/Downloads/arduino-1.8.10/hardware/arduino/avr/libraries/SPI
/root/Arduino/ModbusTCPMasterReadDiscreteInputs/ModbusTCPMasterReadDiscreteInputs.ino:68: undefined reference to `ModbusTCPMaster::readDiscreteInputs(EthernetClient&, unsigned char, unsigned int, unsigned int)'
/root/Arduino/ModbusTCPMasterReadDiscreteInputs/ModbusTCPMasterReadDiscreteInputs.ino:78: undefined reference to `ModbusTCPMaster::available()'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Uno.

Any help is appreciated.!!

Lots of smileys in what you posted.... read the forum rules on how to post code

Where did you install those libraries ?

The library which i downloaded came as a zip file.

I installed it by this method.

sketch > include Library > Add .zip Library.

Sorry about the smileys. it came unknowingly when I pasted the error messages.