ETH connected but not responding to requests

If you are asking a question, please follow this template:

  1. My goal is: Connect to an MQTT broker via Ethernet

  2. My actions are: I’ve setup the configuration as follows:

  - ["eth.enable", true]
  - ["eth.clk_mode", 3]
  - ["eth.ip", "192.168.128.41"]
  - ["eth.netmask", "255.255.255.0"]
  - ["eth.gw", "192.168.128.254"]
  1. The result I see is: The logs I see when booting the device:
...
[Jan  4 14:21:27.857] e[0;32mI (1411) esp_eth.netif.glue: 98:f4:ab:25:d3:8be[0m
[Jan  4 14:21:27.860] e[0;32mI (1421) esp_eth.netif.glue: ethernet attached to netife[0m
[Jan  4 14:21:27.866] esp32_eth.c:163         ETH: MAC 98:f4:ab:25:d3:8b; PHY: LAN87x0 @ 0
[Jan  4 14:21:27.875] esp32_eth.c:169         ETH: IP 192.168.128.41/255.255.255.0, GW 192.168.128.254
...
[Jan  4 14:21:45.883] mgos_net.c:93           ETH: connected
[Jan  4 14:21:45.886] mgos_net.c:104          ETH: ready, IP 192.168.128.41, GW 192.168.128.254, DNS 0.0.0.0, NTP 0.0.0.0
[Jan  4 14:21:45.894] mgos_mqtt_conn.c:435    MQTT0 connecting to broker.hivemq.com:1883
[Jan  4 14:21:45.902] mgos_mongoose.c:66      New heap free LWM: 197136
[Jan  4 14:21:45.908] mgos_mongoose.c:66      New heap free LWM: 197080
[Jan  4 14:21:55.143] mongoose.c:12126        Failed to resolve 'broker.hivemq.com', server 8.8.8.8
[Jan  4 14:21:55.149] mgos_mqtt_conn.c:188    MQTT0 TCP connect error (-1)
[Jan  4 14:21:55.155] mgos_mqtt_conn.c:214    MQTT0 Disconnect

What I see When trying to ping the device:

ping 192.168.128.41
PING 192.168.128.41 (192.168.128.41) 56(84) bytes of data.
From 192.168.128.30 icmp_seq=18 Destination Host Unreachable
From 192.168.128.30 icmp_seq=19 Destination Host Unreachable
From 192.168.128.30 icmp_seq=20 Destination Host Unreachable
From 192.168.128.30 icmp_seq=21 Destination Host Unreachable
From 192.168.128.30 icmp_seq=22 Destination Host Unreachable
From 192.168.128.30 icmp_seq=23 Destination Host Unreachable
From 192.168.128.30 icmp_seq=24 Destination Host Unreachable
From 192.168.128.30 icmp_seq=25 Destination Host Unreachable
From 192.168.128.30 icmp_seq=26 Destination Host Unreachable
From 192.168.128.30 icmp_seq=27 Destination Host Unreachable
From 192.168.128.30 icmp_seq=28 Destination Host Unreachable
From 192.168.128.30 icmp_seq=29 Destination Host Unreachable
...
  1. My expectation & question is: What am I missing? Why can the device not connect to the broker and why can I not ping the device?

since you can’t ping from your local network, possible causes are:
your hardware is not OK
you did not plug your device to a switch that is connected to a 192.168.128/24 network; or your host device (.30) has a different network mask.
your PHY config does not match your board, see here

BTW, you should run Wireshark on a machine connected to a hub or a monitoring port on a switch and see if there is actually any activity on your device

Later on you are going to need a DNS unless you trust Google to do name resolution

I’m a bit unsure about the PHY config. I’m using an Olimex esp32 Gateway (ESP32-GATEWAY - Open Source Hardware Board). As far as I understand, my configuration should work. can someone confirm?

I have a Olimex ESP32-POE which seems to be very similar to your board on the eth side.
It works very well for me with either DHCP or static IP.
Did you try to set it up with DHCP?

It doesn’t look like it’s getting any ip address from DHCP. That’s why I set it statically. I have tried with 3 different boards to rule out any hardware issues.

Never mind! DHCP works! I still can’t communincate with the device though. It won’t connect to the broker and won’t respond to ping. Wireshark doesn’t show any activity from the device

Maybe this can help:

- ["eth.phy_pwr_gpio", 5]

Please clarify this, did you actually see the DHCP transaction take place ?
If you are connected to a switch on a non-monitoring port you will only see your local port traffic and broadcasts. You need a hub or a switch with monitoring capability (and connect your Wireshark PC to that port)
Or you can run your Wireshark on the same machine that runs the DHCP server and preferably acts as a router

I got it working! The problem was that I was using UART1 for something else. Apparently that causes some kind of conflict. Ethernet started working when I switched to UART0 (UART2 didn’t seem to work either). I cannot find anything about UART blocking ethernet in the documentation.

If you observe the proper schematic for your board (revision specific, which you don’t say), and check the (default ?) UART pin assignment, my bet is that you will find that some pins for the UARTs you mention are clashing with Ethernet hardware.

@scaprile You are right.
Ethernet is using GPIOs 19, 22, 25, 26, 23, 18, 27 and 17 and the defaults for UART1 are GPIOs 25, 26, 27 and 13

@Oliver_Norin did not tell us he was using UART1 in the first and subsequent posts.

BTW, with esp32 one can set UARTx on any available GPIOs.

1 Like

Yes, I did not mention I was using UART because it didn’t seem relevant at first. The strange thing is though that pin assignment doesn’t matter. I am aware that some GPIOs are used by Ethernet so I have been avoiding assigning them for anything else. I am using GPIO 39 and 16 for UART0. I also had to set stdout uart to -1 (mgos_set_stdout_uart(-1);) since UART0 would otherwise be in use. So it seems like no matter what pins I use, UART1 and UART2 cannot be used together with ETH. I might still be missing something, I’m not sure, but the pin assignment wasn’t the problem.

If you don’t post your code, I can’t guess any further.

Olimex ESP32-POE connected to a ublox m8n-neo gps module on UART1 (rx pin 36) works very well for me:

[Feb  2 19:17:50.163] esp32_25E9F8 48 3.357 2 2|mgos_net.c:104          ETH: ready, IP 192.168.1.224, GW 192.168.1.1, DNS 192.168.1.171, NTP 0.0.0.0
[Feb  2 19:17:50.201] esp32_25E9F8 51 3.395 2 2|main.c:126              {"fix_info": {"mode":"A", "id": "Any", "fix_type":"3d", "pdop":2.910000, "hdop"=1.490000, "vdop":2.500000}}
[Feb  2 19:17:50.680] esp32_25E9F8 56 3.874 2 2|main.c:126              {"coords": {"valid"=1, "last_fix": 3861717, "lat":xxxx, "lon":yyyy, "time_of_day":"17:17:49.999695"}}