Closed HarterHorst closed 5 years ago
Try to add DNS. Also check the suggestions here: https://github.com/espressif/arduino-esp32/issues/1762#issuecomment-413913021
I am sure that a missing dns is not the reason for the disconnections, but I tried of course. Same error. I get a disconnect immediately after the SYSTEM_EVENT_ETH_GOT_IP.
et.Rչ⸮
8 2⸮L⸮⸮Ғ2:5SH⸮
⸮.⸮⸮⸮⸮ (POU⸮⸮9}IESETJI⸮⸮⸮i0x1⸮⸮SPIeMQ}⸮LAS⸮%==Q⸮
co˥⸮ͥ⸮: 0,⸮A%]Ai0xe⸮C⸮,k⸮E⸮⸮⸮0x00,⸮E⸮⸮⸮0x00,⸮E⸮⸮⸮0x00,⸮.⸮⸮⸮⸮:0x⸮⸮hd_⸮⸮⸮0⸮⸮b⸮⸮}drv:⸮⸮0
⸮[⸮⸮DIO, ,덭⸮div:1C!⸮+⸮i0x3⸮⸮⸮⸮⸮len'SH⸮⸮+⸮⸮0x&⸮⸮⸮01c,l⸮K⸮⸮⸮⸮j
loX⸮⸮⸮⸮00780⸮,leK⸮⸮⸮⸮j
ho tai⸮⸮⸮⸮om 4C!⸮+⸮i0x4⸮⸮040blen'⸮j
entr^⸮⸮⸮00806⸮j
Event ID: 20 ETH Started
Event ID: 24 ETH MAC: 30:AE:A4:1B:C1:FF, IPv4: 192.168.0.90, FULL_DUPLEX, 100Mbps
DNS: 192.168.0.2
Event ID: 24 ETH MAC: 30:AE:A4:1B:C1:FF, IPv4: 192.168.0.90, FULL_DUPLEX, 100Mbps
DNS: 192.168.0.2
Event ID: 23 ETH Disconnected
Event ID: 24 ETH MAC: 30:AE:A4:1B:C1:FF, IPv4: 192.168.0.90, FULL_DUPLEX, 100Mbps
DNS: 192.168.0.2
Event ID: 24 ETH MAC: 30:AE:A4:1B:C1:FF, IPv4: 192.168.0.90, FULL_DUPLEX, 100Mbps
DNS: 192.168.0.2
Event ID: 23 ETH Disconnected
Event ID: 24 ETH MAC: 30:AE:A4:1B:C1:FF, IPv4: 192.168.0.90, FULL_DUPLEX, 100Mbps
DNS: 192.168.0.2
Event ID: 24 ETH MAC: 30:AE:A4:1B:C1:FF, IPv4: 192.168.0.90, FULL_DUPLEX, 100Mbps
DNS: 192.168.0.2
Event ID: 23 ETH Disconnected
Event ID: 24 ETH MAC: 30:AE:A4:1B:C1:FF, IPv4: 192.168.0.90, FULL_DUPLEX, 100Mbps
DNS: 192.168.0.2
Event ID: 24 ETH MAC: 30:AE:A4:1B:C1:FF, IPv4: 192.168.0.90, FULL_DUPLEX, 100Mbps
DNS: 192.168.0.2
Event ID: 23 ETH Disconnected
``
/*
This sketch shows the Ethernet event usage
*/
#include <ETH.h>
static bool eth_connected = false;
void WiFiEvent(WiFiEvent_t event)
{
Serial.print ("Event ID: \t");
Serial.print (event);
Serial.print ("\t");
switch (event) {
case SYSTEM_EVENT_ETH_START:
Serial.println("ETH Started");
//set eth hostname here
ETH.setHostname("esp32-ethernet");
break;
case SYSTEM_EVENT_ETH_CONNECTED:
Serial.println("ETH Connected");
break;
case SYSTEM_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");
Serial.print("DNS:\t\t");
Serial.println(ETH.dnsIP());
eth_connected = true;
break;
case SYSTEM_EVENT_ETH_DISCONNECTED:
Serial.println("ETH Disconnected");
eth_connected = false;
break;
case SYSTEM_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();
ETH.config(IPAddress(192, 168, 0, 90), IPAddress(192, 168, 0, 1), IPAddress(255, 255, 255, 0), IPAddress(192, 168, 0, 2), IPAddress(192, 168, 0, 1));
}
void loop()
{
if (eth_connected) {
testClient("google.com", 80);
}
delay(10000);
}
What happens if you use the default example and DHCP instead of configuring it manually with ETH.config?
With default example you probably mean this: https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/examples/ETH_LAN8720/ETH_LAN8720.ino
I put it on but no changes. see below. I already changed the cable and next I will try another switch. Maybe there is an issue with link auto detection, because it's a 1GBit/s switch. Gonna dig through the basement to get a 100MBit/s switch.
I am not familiar with the librarie ETH.h uses or which library is responsible to detect connect/disconnect. Can the Wifi lib deliver more details?
clkE⸮⸮⸮0x0b⸮}⸮⸮⸮⸮0x00,d_dr⸮⸮⸮⸮0,c.z⸮⸮⸮⸮0⸮0,hd_d.⸮⸮⸮⸮0,}⸮⸮⸮⸮0⸮⸮
mode'T⸮ clk⸮⸮div:LC!녑⸮0x3fff00Lblen:4⸮!⸮+⸮⸮0x&⸮⸮⸮⸮⸮len:132SH⸮녑⸮0x400780⸮blen:77⸮
ho 0⸮⸮⸮⸮⸮12⸮⸮⸮⸮⸮4
!⸮+⸮⸮0x⸮80400⸮⸮⸮⸮6448C⸮⸮⸮⸮⸮0x400806Yj
ETH Started
ETH Connected
ETH Disconnected
ETH Connected
ETH Disconnected
ETH Connected
ETH Disconnected
ETH Connected
ETH Disconnected
ETH Connected
ETH Disconnected
ETH Connected
ETH Disconnected
ETH Connected
ETH Disconnected
ETH Connected
ETH Disconnected
ETH Connected
ETH Disconnected
ETH Connected
ETH Disconnected
Hmm I used the exact same code as you linked. Also compared the ETH.h file and they are the same. However, ETH.h has other includes inside (like WiFi.h and inside WiFi.h there are 12 more includes) and maybe some of these are outdated at your side. Have you updated the Arduino IDE and the ESP32 package recently? If not, try to update them.
Of course, it can be something related to the the network equipment or settings as you mentioned.
This is the result I get (picture and text):
ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x1b (SPI_FAST_FLASH_BOOT)
ets Jun 8 2016 00:22:57
rst:0x10 (RTCWDT_RTC_RESET),boot:0x1b (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:808
load:0x40078000,len:6084
load:0x40080000,len:6696
entry 0x400802e4
ETH Started
ETH Connected
ETH MAC: 24:0A:C4:04:73:07, IPv4: 192.168.0.183, FULL_DUPLEX, 100Mbps
connecting to google.com
HTTP/1.0 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Tue, 02 Oct 2018 10:01:16 GMT
Expires: Thu, 01 Nov 2018 10:01:16 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Age: 175
X-Cache: HIT from unconfigured
Via: 1.0 unconfigured:3128 (squid/2.6.STABLE1)
Proxy-Connection: close
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
closing connection
I can make it work and i can reproduce the error.
The power off makes it work.
We can close this one here, because it's hardware related.
I think the LAN8710 is not fully resetted. The LAN8710 has a NRST on Pin 19. From the schema I can see that it is not connected to the reset switch on the board, right?
So when the script is in the loop of "ETH connected ... ETH disconnected" and i short the two pads on the board (PHY_RST1) it starts working. Board get ip adresse from dhcp and all is fine.
I think there is an issue with the reset of the LAN8710 and when i totally unpower the board both ICs (ESP and 8710) are resetted.
@HarterHorst
Hi Harter,
I am trying your solution but I have a problem. When I unplug the USB cable and plug the cable back in, the serial on the monitor freezes and to see the monitor again I need to reload the script.
Thanks for your help
Hi, i have a problem with Olimex ESP32 EBV and Gateway. Code works, Ethernet connections works but i get a disconnect immediately.
Hardware:
Board: Olimex ESP32 Gateway & EVB Core Installation/update date: latest IDE name: Arduino IDE Flash Frequency: 80Mhz and 40Mhz PSRAM enabled: no Upload Speed: 115200 Computer OS: Windows 10
Description:
ETH Started ETH MAC: 30:AE:A4:1B:C1:FF, IPv4: 192.168.0.90, FULL_DUPLEX, 100Mbps ETH MAC: 30:AE:A4:1B:C1:FF, IPv4: 192.168.0.90, FULL_DUPLEX, 100Mbps ETH Disconnected ETH MAC: 30:AE:A4:1B:C1:FF, IPv4: 192.168.0.90, FULL_DUPLEX, 100Mbps ETH MAC: 30:AE:A4:1B:C1:FF, IPv4: 192.168.0.90, FULL_DUPLEX, 100Mbps ETH Disconnected ETH MAC: 30:AE:A4:1B:C1:FF, IPv4: 192.168.0.90, FULL_DUPLEX, 100Mbps ETH MAC: 30:AE:A4:1B:C1:FF, IPv4: 192.168.0.90, FULL_DUPLEX, 100Mbps ETH Disconnected ETH MAC: 30:AE:A4:1B:C1:FF, IPv4: 192.168.0.90, FULL_DUPLEX, 100Mbps ETH MAC: 30:AE:A4:1B:C1:FF, IPv4: 192.168.0.90, FULL_DUPLEX, 100Mbps ETH Disconnected ETH MAC: 30:AE:A4:1B:C1:FF, IPv4: 192.168.0.90, FULL_DUPLEX, 100Mbps ETH MAC: 30:AE:A4:1B:C1:FF, IPv4: 192.168.0.90, FULL_DUPLEX, 100Mbps ETH Disconnected
Sketch:
I have also tried this one as well.