Page 1 of 1

ESP32 WROOVER IE LAN8720 Ethernet Connection Problem

Posted: Thu Sep 26, 2024 8:13 am
by mert200154
Hello everyone. I am new at IOT and ethernet connections. I made a custom ESP32 board, used chip ESP32 WROOVER IE and for a ethernet connection used a lan8720 ethernet module I checked my schematic all its looks like true and I checked my 50 mHz internal clock from GPIO0 its perfectly gives 50mHz clean signal. My problem is I cant connect any devices with ethernet. My pin configurations completely true. When I uploaded the code I wrote down below its not getting any errors. I can read my lan8720's mac adress but if I dont add my static ip in code IPv4:0.0.0.0 returns at the serial monitor. After that I tried to write static IP in code IPv4:192.168.127.244 shows as I initialized but still cant connect. After all of these when I pressed my BOOT button serial monitor writes ETH Connected when I didnt press the boot button ETH Disconnected occurs. I tested with keep pressed on to boot button and I saw the ETH Connected information came from serial monitor and checked connection, still couldnt connected. I really need help for that. What's am I doing wrong? Also Is arduino IDE version effective?
  1. /*
  2.     This sketch shows the Ethernet event usage
  3. */
  4.  
  5. #define ETH_PHY_TYPE        ETH_PHY_LAN8720
  6. #define ETH_PHY_ADDR        0
  7. #define ETH_PHY_MDC        23
  8. #define ETH_PHY_MDIO        18
  9.  
  10. #define ETH_CLK_MODE ETH_CLOCK_GPIO0_OUT
  11. #define ETH_PHY_POWER 4
  12.  
  13. #include <ETH.h>
  14.  
  15. IPAddress staticIP(192, 168, 127, 244);
  16. IPAddress gateway(192, 168, 127, 1);
  17. IPAddress subnet(255, 255, 255, 0);
  18. static bool eth_connected = false;
  19.  
  20. void WiFiEvent(WiFiEvent_t event)
  21. {
  22.   switch (event) {
  23.     case ARDUINO_EVENT_ETH_START:
  24.       Serial.println("ETH Started");
  25.       //set eth hostname here
  26.       ETH.setHostname("esp32-ethernet");
  27.       break;
  28.     case ARDUINO_EVENT_ETH_CONNECTED:
  29.       Serial.println("ETH Connected");
  30.       break;
  31.     case ARDUINO_EVENT_ETH_GOT_IP:
  32.       Serial.print("ETH MAC: ");
  33.       Serial.print(ETH.macAddress());
  34.       Serial.print(", IPv4: ");
  35.       Serial.print(ETH.localIP());
  36.       if (ETH.fullDuplex()) {
  37.         Serial.print(", FULL_DUPLEX");
  38.       }
  39.       Serial.print(", ");
  40.       Serial.print(ETH.linkSpeed());
  41.       Serial.println("Mbps");
  42.       eth_connected = true;
  43.       break;
  44.     case ARDUINO_EVENT_ETH_DISCONNECTED:
  45.       Serial.println("ETH Disconnected");
  46.       eth_connected = false;
  47.       break;
  48.     case ARDUINO_EVENT_ETH_STOP:
  49.       Serial.println("ETH Stopped");
  50.       eth_connected = false;
  51.       break;
  52.     default:
  53.       break;
  54.   }
  55. }
  56.  
  57. void testClient(const char * host, uint16_t port)
  58. {
  59.   Serial.print("\nconnecting to ");
  60.   Serial.println(host);
  61.  
  62.   WiFiClient client;
  63.   if (!client.connect(host, port)) {
  64.     Serial.println("connection failed");
  65.     return;
  66.   }
  67.   client.printf("GET / HTTP/1.1\r\nHost: %s\r\n\r\n", host);
  68.   while (client.connected() && !client.available());
  69.   while (client.available()) {
  70.     Serial.write(client.read());
  71.   }
  72.  
  73.   Serial.println("closing connection\n");
  74.   client.stop();
  75. }
  76.  
  77. void setup()
  78. {
  79.   Serial.begin(115200);
  80.   WiFi.onEvent(WiFiEvent);
  81.  
  82.  
  83.     pinMode(ETH_PHY_POWER, OUTPUT);
  84.     digitalWrite(ETH_PHY_POWER, HIGH);
  85.  
  86.  
  87.  
  88.  
  89.     if (!ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE)) {
  90.         Serial.println("ETH start Failed!");
  91.     }
  92.     else{  ETH.config(staticIP, gateway, subnet);
  93. }
  94.  
  95.  
  96. }
  97.  
  98. void loop()
  99. {
  100.   Serial.print("ETH MAC: ");
  101.   Serial.print(ETH.macAddress());
  102.   Serial.print(", IPv4: ");
  103.   Serial.println(ETH.localIP());
  104.   delay(1000);
  105. }

Re: ESP32 WROOVER IE LAN8720 Ethernet Connection Problem

Posted: Mon Sep 30, 2024 6:13 am
by mert200154
Is there anyone who can help?

Re: ESP32 WROOVER IE LAN8720 Ethernet Connection Problem

Posted: Mon Sep 30, 2024 9:14 am
by ESP_ondrej
Might be HW issue with your board. Could you please try to debug using https://github.com/espressif/esp-eth-dr ... phy_tester ? Ideally, run the pytest script. However, just note it was tested on Linux so far so you need to be on Linux.

Once you done, let me know the results.