There are lots of examples around how to connect with an NTP server, but I do not see how to find such an IP-address. From the examples I conclude I need to find it on for example pool.ntp.org, but I do not even see how to get IP-addresses out of there myself, let alone to let my Arduino do it. Of course I looked at the How do I use pool.ntp.org
page, but it doesn't seem to say anything about finding IP-addresses.
Questions
- Is it possible to let my Arduino find a working NTP server (using the EtherCard library), and if so, how?
- All the examples I saw have an NTP server IP address hard coded, isn't that a bad practice and also a bad idea for a longer running project?
The code I currently find the easiest to understand is from the Arduino forum, and has an IP address hard coded.
I have an Arduino Nano ATmega328 with a ENC28j60 ethernet shield, and therefore use the EtherCard
libray. I do know of existence of RTC devices but I would prefer NTP.
if (!ether.dnsLookup(website)) { Serial.println("DNS failed"); } ether.printIp("Server: ", ether.hisip);
but I'm new to the ethernet connections so I need to find out how to get an ip address out of that to use later in the code...ether.hisip
is not a string, it's an array of 4 bytes.ether.hisip
printed to, but now I see that's whyether.printIP
was used.