Change CS pin for ethernet library OR include local library

Hi ,

i have been trying to define the chip select pin for ethernet library for hours and didnt manage to find a way.

Is there any simple way ?

by modifing the definition in w5100.cpp IT WORKS , but i dont want to modify the CS pin for every project of course.

So i tried to include the whole ethernet library folder in my sketch folder

/testsketch/
---- testsketch.ino
------ /src/Ethernet/src/Ethernet.h
------ /src/Ethernet/src/Ethernet.cpp
------ /src/Ethernet/src/Ethernet... and so on

then include

#include "src/Ethernet/src/Ethernet.h"

but at compile the IDE tell me

Using library Ethernet at version 2.0.2 in folder: C:\Users\tfoutfou\Documents\Arduino\libraries\Ethernet

and dont use the one i included manually

How to force IDE to use my copy inside sketch folder ?

Thanks

https://www.arduino.cc/reference/en/libraries/ethernet/ethernet.init/

very simple indeed ...... sometime you put yourself in a rabit hole for no reason :wink:

but how would i can include a tweaked version of any library and having the IDE picking the version that i want.

because i would also like to change this line for exemple

#define SPI_ETHERNET_SETTINGS SPISettings(14000000, MSBFIRST, SPI_MODE0)

wich is located at /Ethernet/src/utility/w5100.h

but IDE is picking the version in the main library folder instead of the one included in sketch folder

Thanks

make a copy with a new name

pretty annoying and long , because there is many "define" in almost every file of the ethernet library
with call to each other many time

That second src should not be there.

that's the default structure of the original library folder , moving the files and adjusting the path accordingly dont change anything

in fact , on 20+ installed library , half of them have *.h and *.cpp in a "src" subfolder

OK, maybe the IDE is more intelligent than I suspected.

I understand that a number of libraries have a 'src' subdirectory. But with normal use of the Ethernet library like #include <Ethernet.h> you do not specify that 'src' directory like #include <Ethernet/src/Ethernet.h>. I might be mistaken though.

1 Like

just rename the folder name, Ethernet.h and change the include value in library.properties

1 Like

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