Hello i have a custom board of the RP2040 and would like to use the ethernet library. But the ethernet example webClient uses the default SPI pins of whatever board it is being used, but what if im going to use a board (such as the RP20400 with multiple SPI channels or have alternate pins for the spi chanels, How do i set the SPI mosi,miso,cs of the SPI in the ethernet library?

So i have found a way to make it work, i Edited the file under


change the number to the pin you like.

// SPI
#define PIN_SPI_MISO  (0u)
#define PIN_SPI_MOSI  (3u)
#define PIN_SPI_SCK   (2u)
#define PIN_SPI_SS    (1u)

But problem with this now is every RP2040 board will now make it their default SPI pins,

Is there anything i can do to keep the modification to my own sketch only?

  • the Arduino Ethernet library uses the SPI object from the SPI library
    – Juraj
    Oct 19 '21 at 17:36
  • @Juraj I could not find any SPI macros or declerations on ethernet.h which makes it tricky to trace
    – DrakeJest
    Oct 19 '21 at 18:07
  • @Juraj Oh ! so its initialized at the inside the SPI.h and not ethernet.h. So as mentioned in my edit changing pin.arduino.h changes the setting for all the boards, in my sketch can i override that decleration. So maybe redeclare it after the SPI.h include, something like #include <spi.h>; arduino::MbedSPI SPI(0, 3, 2); #include <ethernet.h>. I will try this out right away
    – DrakeJest
    Oct 19 '21 at 18:49

Browse other questions tagged or ask your own question.