{"id":13187,"date":"2017-02-08T15:26:52","date_gmt":"2017-02-08T20:26:52","guid":{"rendered":"http:\/\/embedded-lab.com\/blog\/?p=13187"},"modified":"2023-04-11T22:16:12","modified_gmt":"2023-04-12T02:16:12","slug":"tutorial-8-esp8266-internet-clock","status":"publish","type":"post","link":"https:\/\/embedded-lab.com\/blog\/tutorial-8-esp8266-internet-clock\/","title":{"rendered":"Tutorial 8: ESP8266 Internet clock"},"content":{"rendered":"<p>The National Institute of Standards and Technology (NIST) provides official time in the United States. NIST disseminates the time using several methods, including\u00a0radio broadcasting over short-wave and long-wave frequencies, telephone dial-in services (ACTS), and Network Time Service (NTS) over the internet. This tutorial\u00a0describes how to build an ESP8266-based internet clock that uses NIST\u2019s NTS service to retrieve accurate time information. The time is displayed on a colorful TFT LCD (ILI9341 driven) in both\u00a0analog clock dial and digital formats. The time is synchronized to the NIST server in every 2-minute interval.<\/p>\n<div id=\"attachment_13211\" style=\"width: 810px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2017\/02\/P_20170206_225019.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-13211\" class=\"size-full wp-image-13211\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2017\/02\/P_20170206_225019.jpg\" alt=\"ESP8266 Internet Clock\" width=\"800\" height=\"619\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2017\/02\/P_20170206_225019.jpg 800w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2017\/02\/P_20170206_225019-580x449.jpg 580w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><p id=\"caption-attachment-13211\" class=\"wp-caption-text\">ESP8266 Internet Clock<\/p><\/div>\n<h4>Hardware<\/h4>\n<p>This project uses an ESP8266 module to connect to the NIST time server through a local home\/office WiFi. I am using <strong><a href=\"http:\/\/embedded-lab.com\/blog\/easyesp-1-rapid-prototyping-development-board-esp8266\/\" target=\"_blank\" rel=\"noopener noreferrer\">EasyESP-1<\/a><\/strong> board for illustration. The time will be displayed on a 2.2&#8243; ILI9341-driven TFT LCD. Please read <strong><a href=\"http:\/\/embedded-lab.com\/blog\/tutorial-7-esp8266-ili9341-tft-lcd\/\" target=\"_blank\" rel=\"noopener noreferrer\">Tutorial 7<\/a><\/strong> for more details on how to interface the TFT LCD to EasyESP-1. The hardware setup for this project is same as for <strong><a href=\"http:\/\/embedded-lab.com\/blog\/tutorial-7-esp8266-ili9341-tft-lcd\/\" target=\"_blank\" rel=\"noopener noreferrer\">Tutorial 7<\/a><\/strong>.<\/p>\n<div id=\"attachment_13200\" style=\"width: 810px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2017\/02\/setup.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-13200\" class=\"size-full wp-image-13200\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2017\/02\/setup.jpg\" alt=\"Complete setup of LCD on the EasyESP-1 breadboard\" width=\"800\" height=\"797\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2017\/02\/setup.jpg 800w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2017\/02\/setup-150x150.jpg 150w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2017\/02\/setup-580x578.jpg 580w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2017\/02\/setup-90x90.jpg 90w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><p id=\"caption-attachment-13200\" class=\"wp-caption-text\">Complete setup of LCD on the EasyESP-1 breadboard for Internet Clock<\/p><\/div>\n<h4>Software<\/h4>\n<p>As\u00a0discussed in <strong><a href=\"http:\/\/embedded-lab.com\/blog\/tutorial-7-esp8266-ili9341-tft-lcd\/\" target=\"_blank\" rel=\"noopener noreferrer\">Tutorial 7<\/a><\/strong>, we will use the same <strong><a href=\"https:\/\/github.com\/Bodmer\/TFT_ILI9341_ESP\" target=\"_blank\" rel=\"noopener noreferrer\">TFT ILI9341 ESP<\/a>\u00a0<\/strong>library by <a href=\"https:\/\/github.com\/Bodmer\" target=\"_blank\" rel=\"noopener noreferrer\">Bodmer<\/a>\u00a0in this project too.\u00a0The library comes with some really cool demo examples. This tutorial actually incorporates their\u00a0<strong>TFT_Clock<\/strong> example for displaying time in an analog clock dial format. There are several examples available online showing how to implement\u00a0Network Time Protocol (NTP) in Arduino to fetch time from NIST server. NIST operates several time servers for its Internet Time Service (ITS). The list of these\u00a0time servers and their IP addresses can be found <strong><a href=\"http:\/\/tf.nist.gov\/tf-cgi\/servers.cgi\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a><\/strong>. Note that NIST does not allow\u00a0queries to any of their servers more frequently than once every 4 seconds. In this project, the queries are made once every two minutes. In between the queries, which is a 2-minute interval, the time is\u00a0kept running locally using the <strong>delay()<\/strong> routine. You can download the complete ESP8266 Firmware for this project from the following link.<\/p>\n<p><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2017\/02\/InternetClock_ILI9341.zip\">Download Internet Clock ILI9341 code<\/a><\/p>\n<p><em><strong>Important notes:<\/strong><\/em><\/p>\n<ul>\n<li>The time-fetching code was derived from\u00a0<strong>Kev_MacD<\/strong>\u2018s instructables on <a href=\"http:\/\/www.instructables.com\/id\/Steampunk-ESP8622-Internet-connected-Clock-using-t\/\" target=\"_blank\" rel=\"noopener noreferrer\">Steampunk ESP8266 Internet connected Clock<\/a>.<\/li>\n<li>In the code, you need to change the network SSID and password to match to your network.<\/li>\n<li>In addition, you also need to adjust the GMT offset for your location to get the correct local time. For example, the GMT offset for EST is -5 (<em>int hours_Offset_From_GMT = -5;<\/em>).<\/li>\n<li>The display part of the code uses the\u00a0<strong><a href=\"https:\/\/github.com\/Bodmer\/TFT_ILI9341_ESP\" target=\"_blank\" rel=\"noopener noreferrer\">TFT ILI9341 ESP<\/a>\u00a0<\/strong>library. You can read more about it in <strong><a href=\"http:\/\/embedded-lab.com\/blog\/tutorial-7-esp8266-ili9341-tft-lcd\/\" target=\"_blank\" rel=\"noopener noreferrer\">Tutorial 7<\/a>.<\/strong><\/li>\n<li>The time is displayed in 12 hour format on analog dial as well as\u00a0in 24 hour digital format .<\/li>\n<\/ul>\n<div id=\"attachment_13212\" style=\"width: 810px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2017\/02\/P_20170207_153616.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-13212\" class=\"size-full wp-image-13212\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2017\/02\/P_20170207_153616.jpg\" alt=\"Internet clock\" width=\"800\" height=\"716\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2017\/02\/P_20170207_153616.jpg 800w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2017\/02\/P_20170207_153616-580x519.jpg 580w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><p id=\"caption-attachment-13212\" class=\"wp-caption-text\">ESP8266 Internet clock<\/p><\/div>\n<h4><a href=\"https:\/\/www.elecrow.com\/cde82664e.html\" target=\"_blank\" rel=\"noopener noreferrer\">Buy EasyESP-1 board<\/a><\/h4>\n<h4>More tutorials<\/h4>\n<h5 class=\"post-title\"><a href=\"http:\/\/embedded-lab.com\/blog\/easyesp-1-rapid-prototyping-development-board-esp8266\/\" target=\"_blank\" rel=\"noopener noreferrer\">EASYESP-1: A RAPID PROTOTYPING AND DEVELOPMENT BOARD FOR ESP8266<\/a><\/h5>\n<h5 class=\"post-title\"><a href=\"http:\/\/embedded-lab.com\/blog\/tutorial-1-setting-arduino-ide-easyesp-1\/\" target=\"_blank\" rel=\"noopener noreferrer\">TUTORIAL 1: SETTING UP THE ARDUINO IDE FOR EASYESP-1<\/a><\/h5>\n<h5 class=\"post-title\"><a href=\"http:\/\/embedded-lab.com\/blog\/tutorial-2-easyesp-1-hello-world-example\/\" target=\"_blank\" rel=\"noopener noreferrer\">TUTORIAL 2: EASYESP-1 \u201cHELLO WORLD\u201d EXAMPLE<\/a><\/h5>\n<h5 class=\"post-title\"><a href=\"http:\/\/embedded-lab.com\/blog\/tutorial-3-connecting-oled-display-esp8266\/\" target=\"_blank\" rel=\"noopener noreferrer\">TUTORIAL 3: CONNECTING AN OLED DISPLAY TO ESP8266<\/a><\/h5>\n<h5 class=\"post-title\"><a href=\"http:\/\/embedded-lab.com\/blog\/tutorial-4-working-esp8266-wifi-scan-class\/\" target=\"_blank\" rel=\"noopener noreferrer\">TUTORIAL 4: WORKING WITH ESP8266 WIFI SCAN CLASS<\/a><\/h5>\n<h5 class=\"post-title\"><a href=\"http:\/\/embedded-lab.com\/blog\/tutorial-5-setting-esp8266-web-server\/\" target=\"_blank\" rel=\"noopener noreferrer\">TUTORIAL 5: SETTING UP AN ESP8266 WEB SERVER<\/a><\/h5>\n<h5 class=\"post-title\"><a href=\"http:\/\/embedded-lab.com\/blog\/tutorial-6-esp8266-bme280-make-localremote-weather-station\/\" target=\"_blank\" rel=\"noopener noreferrer\">TUTORIAL 6: ESP8266 AND BME280 MAKE A LOCAL\/REMOTE WEATHER STATION<\/a><\/h5>\n<h5 class=\"post-title\"><a href=\"http:\/\/embedded-lab.com\/blog\/tutorial-7-esp8266-ili9341-tft-lcd\/\" target=\"_blank\" rel=\"noopener noreferrer\">TUTORIAL 7: ESP8266 AND ILI9341 TFT LCD<\/a><\/h5>\n","protected":false},"excerpt":{"rendered":"<p>The National Institute of Standards and Technology (NIST) provides official time in the United States. NIST disseminates the time using several methods, including\u00a0radio broadcasting over short-wave and long-wave frequencies, telephone dial-in services (ACTS), and Network Time Service (NTS) over the internet. This tutorial\u00a0describes how to build an ESP8266-based internet clock that uses NIST\u2019s NTS service to retrieve accurate time information. The time is displayed on a colorful TFT LCD (ILI9341 driven) in both\u00a0analog clock dial and digital formats. The time is synchronized to the NIST server in every 2-minute interval. Hardware This project uses an ESP8266 module to connect to<\/p>\n","protected":false},"author":1,"featured_media":13211,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1603,1044,1464,1467],"tags":[1626,1627],"class_list":["post-13187","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp8266-tutorials","category-esp8266","category-featured","category-projects","tag-esp8266-clock","tag-nist-clock"],"_links":{"self":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/13187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/comments?post=13187"}],"version-history":[{"count":7,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/13187\/revisions"}],"predecessor-version":[{"id":15137,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/13187\/revisions\/15137"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/media\/13211"}],"wp:attachment":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/media?parent=13187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/categories?post=13187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/tags?post=13187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}