Hey,
I work on a software for ESP32 and use Ethernet kit A ver1.1.
When I use wifi STA and connect to my router, the software taken from the SNTP example provided with ESP-IDF (v4.4) works well.
However, when I use ethernet, the time is unable to synchronize. In this case, wifi STA is not configured.
In both cases I am working with static IPs. I configured DNS server to 8.8.8.8.
I tested that ethernet is configured properly and works in a way, that I am able to display my website loaded from ethernet IP address on my local network.
Please, do you have any guiding advice, why SNTP might not work via ethernet?
Thank you,
Jakub
Unable to run SNTP via ethernet
Re: Unable to run SNTP via ethernet
I found out that DNS setup is missing in my ethernet configuration, therefore it is unable to connect to the NTP server. When I provide direct IP address, it works. As a solution, I will soon provide command which sets the DNS for ethernet here.
Re: Unable to run SNTP via ethernet
Here is the code snippet as promissed including DNS setup:
Code: Select all
esp_netif_dhcpc_stop(eth_netif);
esp_netif_ip_info_t info_t;
esp_netif_dns_info_t dns_info;
memset(&info_t, 0, sizeof(esp_netif_ip_info_t));
inet_pton(AF_INET, Configuration.staticip_eth, &info_t.ip);
inet_pton(AF_INET, Configuration.gateway_eth, &info_t.gw);
inet_pton(AF_INET, Configuration.subnetmask_eth, &info_t.netmask);
inet_pton(AF_INET, Configuration.dnsserver_eth, &dns_info.ip);
esp_netif_set_ip_info(eth_netif, &info_t);
esp_netif_set_dns_info(eth_netif, ESP_NETIF_DNS_MAIN, &dns_info);
Who is online
Users browsing this forum: Google [Bot] and 127 guests