Hello,
I am trying to connect my ESP32 device (OLIMEX ESP32-POE-ISO-EA-IND) to my PC (host machine) with Ethernet. I have looked to examples (eth2ap and tcpclient) and was able to install the ETH driver and also attach the ETH to netif using esp_eth_new_netif_glue().
But I am not able to have a communication (like socket) between my PC and the ESP. Every time I try to have a socket connection with the localhost (host PC) at port 3333, the connection fails, and I am getting an errno 104 (Socket unable to connect: errno 104).
Also, there is no IP address allocated to the ESP board when I connect it to my PC, however the ESP device gets an IP if I connect it to my router. I do not know whether this is an expected behavior, or do I even need an IP address to start a communication.
I would be grateful if you can help me overcome this issue.
Thank you for your help
----------------------Examples Link------------------------------
eth2ap - https://github.com/espressif/esp-idf/tr ... net/eth2ap
tcpclient - https://github.com/espressif/esp-idf/tr ... tcp_client
Connect ESP32 to host pc with ethernet
-
- Posts: 2
- Joined: Thu Dec 22, 2022 2:50 pm
Connect ESP32 to host pc with ethernet
Last edited by GlenMorris on Fri Dec 23, 2022 8:36 am, edited 1 time in total.
-
- Posts: 211
- Joined: Fri May 07, 2021 10:35 am
Re: Connect ESP32 to host pc with ethernet
Hi GlenMorris,
1) Connect both ESP device and your PC to the router so both devices get the IP address and are going to be in the same subnet.
2) Configure your PC as DHCP server. It is not that hard on Linux OS. Search the internet.
3) Configure static IP address on your PC and static address on the ESP device. See example how https://github.com/espressif/esp-idf/tr ... /static_ip
Ondrej
Localhost (127.0.0.1) is your PC. You need to have specific IP address assigned to your ESP32 device and specific IP address in the same subnet assigned to your PC to be able to communicate.But I am not able to have a communication (like socket) between my PC and the ESP. Every time I try to have a socket connection with the localhost (host PC) at port 3333, the connection fails, and I am getting an errno 104 (Socket unable to connect: errno 104).
You didn't specify which exact example do you use. However, yes, this is expected behavior in most of the cases since in the most of the configurations, the device is configured as DHCP client. Therefore it waits for DHCP server to get some IP address. Routers are usually configured as DHCP servers, hence it gives the address to your device. The PC's are usually configured as DHCP clients by default hence there is no address provided to your ESP device. You have several options:Also, there is no IP address allocated to the ESP board when I connect it to my PC, however the ESP device gets an IP if I connect it to my router. I do not know whether this is an expected behavior, or do I even need an IP address to start a communication.
1) Connect both ESP device and your PC to the router so both devices get the IP address and are going to be in the same subnet.
2) Configure your PC as DHCP server. It is not that hard on Linux OS. Search the internet.
3) Configure static IP address on your PC and static address on the ESP device. See example how https://github.com/espressif/esp-idf/tr ... /static_ip
Ondrej
-
- Posts: 2
- Joined: Thu Dec 22, 2022 2:50 pm
Re: Connect ESP32 to host pc with ethernet
Hello,
Thank you for the detailed reply. It took me some time to set up a DHCP server, as I was trying it on Windows, but I have finally able to do it in Linux (was much easier).
Have a nice day
Thank you for the detailed reply. It took me some time to set up a DHCP server, as I was trying it on Windows, but I have finally able to do it in Linux (was much easier).
Have a nice day
Who is online
Users browsing this forum: benrank, MicroController, 快乐的小尾巴 and 106 guests