Getting The Time
Network time is served by NTP, and we can contact a server to be synced with everything from laptops to cell phones. ezTime stays true to its name and keeps things simple.
To add it to the sketch, we just need to tell the compiler to #include <ezTime.h>.
First NTP needs to be contacted with waitForSync(). This does DNS translation, finds
an appropriate server, calculates network delay and other things that fix the clock.
Getting the time zone right takes a little more. We need a Timezone variable to store
the local zone and daylight savings info, and need to call a second server to get that
populated. Serial statements can be used like they were with WiFi to show that status.
The ISO 8601 standard just provides a common way to describe time and keep people from fighting over whether the month or day goes first.
| |
With the board plugged in to USB, go ahead and upload it with time info. The serial monitor will now show it updating with the current time and zone.
Next Up: JSON Message
