w5500-evb-pico arduino IDE, direct ethernet connection not working

If i connect the w5500-evb-pico to a switch, and then another device with TCP server on the same switch.
I can send messages.

However, if I plug in the ethernet cable from the w5500-evb-pico straight into the TCP server device (PC, printer,…) it does not send any messages.

It looks as if the cable is not connected.

As a matter of test, I made a standalone easy testable sketch.

#include <SPI.h>
#include <EthernetClient.h>
#include <Ethernet.h>
#include <Wire.h>

byte mac[] = { 0x00, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 201, 239);
IPAddress subnet(255, 255, 255, 0);
IPAddress gateway(192, 168, 201, 150);
IPAddress dns(192, 168, 201, 150);

IPAddress server(192, 168, 201, 150);  // TCP server

// Initialize the Ethernet client library (port 80 is default for HTTP):
EthernetClient client;

// Declare IO
const uint LED_PIN = LED_BUILTIN;  // the number of the LED pin 25 on wiznet evb

// State IO
int ledState = LOW;  // ledState used to set the LED

// Timers
unsigned long previousMillis1 = 0;  // task 1, will store last time task was run
const long interval1 = 1000;        // task 1, interval at which to run task (milliseconds)
unsigned long previousMillis2 = 0;  // task 2, will store last time task was run
const long interval2 = 1000;        // task 2, interval at which to run task (milliseconds)

void setup() {
  pinMode(LED_PIN, OUTPUT);
  Serial.begin(9600);
  while (!Serial) {
    ;  // wait for serial port to connect. Needed for native USB port only
  }
  Serial.println("Test");

  // Ethernet and TCP init code
  Ethernet.init(17);  // For w5500-evb-pico
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // Check for Ethernet hardware present
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
      Serial.println("Ethernet shield was not found");
    }
    if (Ethernet.linkStatus() == LinkOFF) {
      Serial.println("Ethernet cable is not connected");
    }
    // try to configure using IP address instead of DHCP:
    // Ethernet.begin(mac, ip, myDns);
    Serial.println("Now setting static");
    Ethernet.begin(mac, ip, dns, gateway, subnet);

  } else {
    Serial.print("  DHCP assigned IP ");
    Serial.println(Ethernet.localIP());
  }
}

void loop() {
  // See if we need to run a task on core 1
  first_core_task_filter();
}

// Here we manage the tasks
void first_core_task_filter() {
  // Task 1, blink LED
  unsigned long currentMillis1 = millis();
  if (currentMillis1 - previousMillis1 >= interval1) {
    // save the last time we ran the task
    previousMillis1 = currentMillis1;
    // Now we are sure we are not over calling the task
    task1_blink();
  }

  // Task 2, send a TCP message
  unsigned long currentMillis2 = millis();
  if (currentMillis2 - previousMillis2 >= interval2) {
    previousMillis2 = currentMillis2;
    task2_send_tcp();
  }
}

// Task's
void task1_blink() {
  // if the LED is off turn it on and vice-versa:
  if (ledState == LOW) {
    ledState = HIGH;
  } else {
    ledState = LOW;
  }
  digitalWrite(LED_PIN, ledState);
}

void task2_send_tcp() {
  if (client.connected()) {
    // Send message
    Serial.println("Already connected, sending message");
    client.println("Test TCP message");
  } else {
    if (client.connect(server, 9100)) {
      // Send message
      Serial.println("New connection, sending message");
      client.println("Test TCP message");
    } else {
      Serial.println("Error, setting up TCP connection");
    }
  }
}

The above sketch will simply try to get an IP through DHCP; if not available after a while, it will get the static IP settings. Then in a loop, the TCP connection is made and a simple message is sent.
So with a switch, it works, with or without DHCP if the TCP server also has static IP settings in that case. But as soon as you plug in directly to another device, it’s not getting past the link up.

In order to even more easily see the issue, you can use the build in example from the ethernet library from arduino.
In this example, only the link status is displayed, I can clearly see it’s never going up when direct connect to the TCP server.

/*
  Link Status

  This sketch prints the Ethernet link status. When the
  Ethernet cable is connected the link status should go to "ON".
  NOTE: Only WIZnet W5200 and W5500 are capable of reporting
  the link status. W5100 will report "Unknown".
  Hardware:
   - Ethernet shield or equivalent board/shield with WIZnet W5200/W5500
  Written by Cristian Maglie
  This example is public domain.
*/
#include <SPI.h>
#include <Ethernet.h>

void setup() {
  Ethernet.init(17);  // For w5500-evb-pico
  Serial.begin(9600);
}

void loop() {
  auto link = Ethernet.linkStatus();
  Serial.print("Link status: ");
  switch (link) {
    case Unknown:
      Serial.println("Unknown");
      break;
    case LinkON:
      Serial.println("ON");
      break;
    case LinkOFF:
      Serial.println("OFF");
      break;
  }
  delay(1000);
}

The arduino ide is 2.0.3, the additional boards manager link is: https://github.com/WIZnet-ArduinoEthernet/arduino-pico/releases/download/global/package_rp2040-ethernet_index.json

I then select the w5500-evb-pico from the boards list under Raspberry Pi Pico /RP2040 Ethernet.

Does anybody have tried to connect the w5500 or w5500-evb-pico directly to a PC and try to communicate with it?

If link LED does not turn on then you have MDIX issue. Refer to chanper 5.5.6 of the W5500 datasheet.

Well, thanks for the super fast response and answer.

That seems very likely the problem, I thought the w5100s had auto MDIX.
And so the newer w5500 would have it as well.

For completeness:

5.5.6 MDIX
W5500 does not support auto-MDIX feature.
Thus, user should use straight-through cables to connect to other switches or routers and
crossover cables to connect to devices such as servers, workstations or another W5500.
However, user can use either type of cable to connect to other devices with auto-MDIX
enabled, and the interface automatically corrects for any incorrect cabling.

Confirmed the proposed solution. Crossover cable between the w5500 and device solved it.
image

1 Like