Day 9: TCP time
Today’s project uses the functions of the prior test to independently collect information from a website. The program specifically loads the current time from a dedicated website and thus sets the internal clock of the controller that is implemented by library.
Behind today’s door, there is another resistor with 1 kΩ. All three resistors will be needed for tomorrow’s experiment.
The program: Day9_TCPAutoTime
While yesterday’s program still required mostly manual operation, today’s program works mostly autonomously. The controller connects to the website entirely independently:
The URL can be used to call various time systems and conversions. The current time valid in Germany in winter is queried by the URL
Therefore, the call of the function getTime has the second parameter »utc/in-one-hour«. Based on the UTC (coordinated world time), you need to change the call to »utc/in-two-hours« in summer. You can treat all other time zones according to the same system.
The determined time is now handed over to the Time-Library of Michael Margolis (source: http://www.pjrc.com/teensy/td_libs_Time.html). For practical reasons, a copy of the Time-Library version that I use is enclosed in the sketch folder. It must be copied into the libraries folder of your sketchbook folder. In the background, the new time is continually calculated and output in the terminal every second. You can now simply program an alarm clock or another time-controlled application.