Olimex Support Forum

Microcontrollers => ESP32 => Topic started by: SSEV on April 20, 2023, 08:25:32 PM

Title: ESP32-EVB- Ethernet not working
Post by: SSEV on April 20, 2023, 08:25:32 PM
IDE- Arduino
ESP32-EVB-EA-IND

Trying to get DHCP working.  Using the examples for the Ethernet sketch and others.

Return Error for serial monitor:
E (181) lan87xx: lan87xx_init(499): wrong chip ID
E (181) esp_eth: esp_eth_driver_install(215): init phy failed

Not entirely sure about which libraries need to be used but I have tried to include a bunch with trial and error with no success.

Much appreciated for any help.
Title: Re: ESP32-EVB- Ethernet not working
Post by: LubOlimex on April 21, 2023, 11:49:07 AM
No need to add any libraries. Just first test with the default demo. It works with for DHCP by default.

1. Install the Arduino package as per these instructions:

https://espressif-docs.readthedocs-hosted.com/projects/arduino-esp32/en/latest/installing.html

2. From board selector find "OLIMEX ESP32-EVB" and select it.

3. Load the Ethernet example from File -> Examples -> Ethernet -> ETH_LAN8720 compile, upload and test.
Title: Re: ESP32-EVB- Ethernet not working
Post by: SSEV on April 27, 2023, 05:57:03 PM
I have tried two boards on two different networks and still get the same serial monitor output.  I can get wifi working no problem. 

E (171) lan87xx: lan87xx_init(499): wrong chip ID
E (171) esp_eth: esp_eth_driver_install(215): init phy failed

 Under the Board Manager: esp32: The Board OLIMEX ESP32-EVB is chosen and connected with the proper COM port. I have done multiple uninstalls and fresh installs for the Arduino IDE.

Code:
/*
    This sketch shows the Ethernet event usage

*/

#include <ETH.h>

static bool eth_connected = false;

void WiFiEvent(WiFiEvent_t event)
{
  switch (event) {
    case ARDUINO_EVENT_ETH_START:
      Serial.println("ETH Started");
      //set eth hostname here
      ETH.setHostname("esp32-ethernet");
      break;
    case ARDUINO_EVENT_ETH_CONNECTED:
      Serial.println("ETH Connected");
      break;
    case ARDUINO_EVENT_ETH_GOT_IP:
      Serial.print("ETH MAC: ");
      Serial.print(ETH.macAddress());
      Serial.print(", IPv4: ");
      Serial.print(ETH.localIP());
      if (ETH.fullDuplex()) {
        Serial.print(", FULL_DUPLEX");
      }
      Serial.print(", ");
      Serial.print(ETH.linkSpeed());
      Serial.println("Mbps");
      eth_connected = true;
      break;
    case ARDUINO_EVENT_ETH_DISCONNECTED:
      Serial.println("ETH Disconnected");
      eth_connected = false;
      break;
    case ARDUINO_EVENT_ETH_STOP:
      Serial.println("ETH Stopped");
      eth_connected = false;
      break;
    default:
      break;
  }
}

void testClient(const char * host, uint16_t port)
{
  Serial.print("\nconnecting to ");
  Serial.println(host);

  WiFiClient client;
  if (!client.connect(host, port)) {
    Serial.println("connection failed");
    return;
  }
  client.printf("GET / HTTP/1.1\r\nHost: %s\r\n\r\n", host);
  while (client.connected() && !client.available());
  while (client.available()) {
    Serial.write(client.read());
  }

  Serial.println("closing connection\n");
  client.stop();
}

void setup()
{
  Serial.begin(115200);
  WiFi.onEvent(WiFiEvent);
  ETH.begin();
}


void loop()
{
  if (eth_connected) {
    testClient("google.com", 80);
  }
  delay(10000);
}
Title: Re: ESP32-EVB- Ethernet not working
Post by: LubOlimex on May 02, 2023, 11:32:25 AM
Try adding a delay at start of main, something like:

void setup()
{
  delay(1000);
  Serial.begin(115200);
  WiFi.onEvent(WiFiEvent);
  ETH.begin();
}
Title: Re: ESP32-EVB- Ethernet not working
Post by: LubOlimex on May 02, 2023, 11:42:39 AM
Also refer to this:

https://github.com/espressif/arduino-esp32/issues/6142
Title: Re: ESP32-EVB- Ethernet not working
Post by: CANguru on May 09, 2023, 02:31:41 PM
Hi,
I am having exactly the same problem.
Unfortunately the hint to insert a delay surpresses the error message, but does not solve the problem. What I found out, is, that to use platform = espressif32 @ ~3.5.0 makes it going, but that is also no solution.
Could you please give me a working hint to make ETHERNET going.
Thank you!
Title: Re: ESP32-EVB- Ethernet not working
Post by: LubOlimex on May 09, 2023, 04:57:04 PM
Read carefully what I shared above, it explains why it happens. There is no software fix for this, only workarounds.
Title: Re: ESP32-EVB- Ethernet not working
Post by: CANguru on May 09, 2023, 05:28:16 PM
Thank you for your fast reply.
I did read your post(s) to this item very carefully! And I understood there is no software fix, but your workaround (adding the 350ms delay at the beginning of ETH.begin()) does not what your promissing.
Something between the platform espressif32 version 3.5.0 and version 4.0.0 (under PlatformIO) must have changed that makes the problem. But up to now I could not find out.
Title: Re: ESP32-EVB- Ethernet not working
Post by: SSEV on June 09, 2023, 04:45:40 AM
It did end up working.  For some reason it needed the delay and a power cycle.