- /*
- This sketch shows the Ethernet event usage
- */
- #define ETH_PHY_TYPE ETH_PHY_LAN8720
- #define ETH_PHY_ADDR 0
- #define ETH_PHY_MDC 23
- #define ETH_PHY_MDIO 18
- #define ETH_CLK_MODE ETH_CLOCK_GPIO0_OUT
- #define ETH_PHY_POWER 4
- #include <ETH.h>
- IPAddress staticIP(192, 168, 127, 244);
- IPAddress gateway(192, 168, 127, 1);
- IPAddress subnet(255, 255, 255, 0);
- 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);
- pinMode(ETH_PHY_POWER, OUTPUT);
- digitalWrite(ETH_PHY_POWER, HIGH);
- if (!ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE)) {
- Serial.println("ETH start Failed!");
- }
- else{ ETH.config(staticIP, gateway, subnet);
- }
- }
- void loop()
- {
- Serial.print("ETH MAC: ");
- Serial.print(ETH.macAddress());
- Serial.print(", IPv4: ");
- Serial.println(ETH.localIP());
- delay(1000);
- }
ESP32 WROOVER IE LAN8720 Ethernet Connection Problem
-
- Posts: 2
- Joined: Thu Sep 26, 2024 7:57 am
ESP32 WROOVER IE LAN8720 Ethernet Connection Problem
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?
-
- Posts: 2
- Joined: Thu Sep 26, 2024 7:57 am
Re: ESP32 WROOVER IE LAN8720 Ethernet Connection Problem
Is there anyone who can help?
-
- Posts: 210
- Joined: Fri May 07, 2021 10:35 am
Re: ESP32 WROOVER IE LAN8720 Ethernet Connection Problem
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.
Once you done, let me know the results.
Who is online
Users browsing this forum: No registered users and 15 guests