{"id":3117,"date":"2020-08-30T11:12:00","date_gmt":"2020-08-30T02:12:00","guid":{"rendered":"http:\/\/otsuka.biz\/blog1\/?p=3117"},"modified":"2024-02-12T17:44:43","modified_gmt":"2024-02-12T08:44:43","slug":"ntp-client-as-a-simple-clock-using-esp32-wroom-32","status":"publish","type":"post","link":"https:\/\/otsuka.biz\/blog1\/ntp-client-as-a-simple-clock-using-esp32-wroom-32\/","title":{"rendered":"NTP client as a simple clock using ESP32-WROOM-32"},"content":{"rendered":"\n<p>&lt;&lt; Introduction in Japanese &gt;&gt;<\/p>\n\n\n\n<p>\u521d\u3081\u3066 ESP32 \u306b\u89e6\u308c\u305f\u590f\u304c\u305d\u308d\u305d\u308d\u7d42\u308f\u308d\u3046\u3068\u3059\u308b\u4eca\u3001\u7a81\u7136\u306b\u9577\u671f\u5b89\u500d\u653f\u6a29\u304c\u7d42\u308f\u308a\u3092\u544a\u3052\u305f\u3002\u305d\u3057\u3066\u65e5\u672c\u306f\u65b0\u3057\u3044\u653f\u6cbb\u30ea\u30fc\u30c0\u30fc\u3092\u6234\u3044\u3066\u79cb\u3092\u8fce\u3048\u308b\u3002\u4e2d\u56fd\u304b\u3089\u3084\u3063\u3066\u6765\u305f ESP32 \u3092\u6307\u3067\u5f3e\u3044\u3066\u307f\u308b\u3068\u3001\u865a\u308d\u3067\u920d\u3044\u97f3\u304c\u3059\u308b\u3002<\/p>\n\n\n\n<p>\u3055\u3066\u3001\u3053\u308c\u307e\u3067 PIC \u3092\u4f7f\u3063\u3066\u5b9f\u9a13\u3057\u3066\u304d\u305f\u4e8b\u3092\u3001ESP32 \u306b\u7f6e\u304d\u63db\u3048\u3066\u518d\u5b9f\u9a13\u3057\u3066\u307f\u308b\u3053\u3068\u306b\u3059\u308b\u3002\u4eca\u56de\u306e\u5b9f\u9a13\u306f\u5353\u4e0a\u6642\u8a08\u3067\u3042\u308b\u3002\u30b7\u30b9\u30c6\u30e0\u306e\u521d\u671f\u5316\u6642\u306b NTP server \u304b\u3089\u73fe\u5728\u6642\u523b\u3092\u53d6\u5f97\u3057\u3066\u3001\u305d\u3053\u304b\u3089\u306f\u30bf\u30a4\u30de\u30fc\u306b\u3088\u308b\u5272\u308a\u8fbc\u307f\u3067\uff11\u79d2\u3092\u523b\u3093\u3067\u306f\u3001\u6642\u9593\u3092\u6db2\u6676\u8868\u793a\u5668\u306b\u8868\u793a\u3055\u305b\u308b\u3002<\/p>\n\n\n\n<p>\u6642\u523b\u306e\u88dc\u6b63\u306f\u3001\u6bce\u65e5\u6df1\u591c\u96f6\u6642\u306b\u81ea\u52d5\u3067\u30b7\u30b9\u30c6\u30e0\u3092\u518d\u8d77\u52d5\u3055\u305b\u308b\u4e8b\u3067\u6e08\u307e\u305b\u305f\u3002\u52ff\u8ad6\u3001\u968f\u6642\u30ea\u30bb\u30c3\u30c8\u30fb\u30dc\u30bf\u30f3\u3067\u518d\u8d77\u52d5\u3055\u305b\u308b\u4e8b\u3082\u3067\u304d\u308b\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"775\" src=\"http:\/\/otsuka.biz\/blog1\/wp-content\/uploads\/2020\/08\/ESP32_NTP-1024x775.jpg\" alt=\"\" class=\"wp-image-3128\" srcset=\"https:\/\/otsuka.biz\/blog1\/wp-content\/uploads\/2020\/08\/ESP32_NTP-1024x775.jpg 1024w, https:\/\/otsuka.biz\/blog1\/wp-content\/uploads\/2020\/08\/ESP32_NTP-300x227.jpg 300w, https:\/\/otsuka.biz\/blog1\/wp-content\/uploads\/2020\/08\/ESP32_NTP-768x581.jpg 768w, https:\/\/otsuka.biz\/blog1\/wp-content\/uploads\/2020\/08\/ESP32_NTP-1536x1163.jpg 1536w, https:\/\/otsuka.biz\/blog1\/wp-content\/uploads\/2020\/08\/ESP32_NTP-2048x1551.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The ESP32 board in my page on Aug. 16, 2020 is working as a simple clock.<\/p>\n\n\n\n<p>The NTP server of <a href=\"https:\/\/www.nict.go.jp\/en\/\">National Institute of Information and Communications Technology<\/a> is used in this project and Coordinated Universal Time (UTC) is converted to Japan Standard Time (JST: UTC + 9 hours).<\/p>\n\n\n\n<p>An interruption of every one second is generated by the timer module, which increments the timestamp obtained from the NTP server.<\/p>\n\n\n\n<p><br><br><\/p>\n\n\n\n<p>&lt;&lt; Sample sketch of the NTP client &gt;&gt;<\/p>\n\n\n\n<div class='w3eden'><!-- WPDM Link Template: Default Template -->\n\n<div class=\"link-template-default card mb-2\">\n    <div class=\"card-body\">\n        <div class=\"media\">\n            <div class=\"mr-3 img-48\"><img decoding=\"async\" class=\"wpdm_icon\" alt=\"\u30a2\u30a4\u30b3\u30f3\" src=\"data:image\/svg+xml;base64,CiAgICAgICAgICAgIDxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2aWV3Qm94PSIwIDAgNDAgNDAiPgogICAgICAgICAgICAgICAgPGRlZnM+CiAgICAgICAgICAgICAgICAgICAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkaWVudCIgeDE9IjAiIHkxPSIwIiB4Mj0iMCIgeTI9IjEiPgogICAgICAgICAgICAgICAgICAgICAgICA8c3RvcCBzdG9wLWNvbG9yPSIjMjY5ZGVmIiBvZmZzZXQ9IjAiLz4KICAgICAgICAgICAgICAgICAgICAgICAgPHN0b3Agc3RvcC1jb2xvcj0iIzI2YmRlZiIgb2Zmc2V0PSIxIi8+CiAgICAgICAgICAgICAgICAgICAgPC9saW5lYXJHcmFkaWVudD4KICAgICAgICAgICAgICAgIDwvZGVmcz4KICAgICAgICAgICAgICAgIDxnPgogICAgICAgICAgICAgICAgICAgIDxyZWN0IGZpbGw9InVybCgjZ3JhZGllbnQpIiB4PSIwIiB5PSIwIiB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHJ4PSIzIiByeT0iMyIvPgogICAgICAgICAgICAgICAgICAgIDx0ZXh0IHg9IjUiIHk9IjE5IiBmb250LWZhbWlseT0iQXJpYWwsIEhlbHZldGljYSwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxM3B4IiBsZXR0ZXItc3BhY2luZz0iMSIgZmlsbD0iI0ZGRkZGRiI+CiAgICAgICAgICAgICAgICAgICAgICAgIDx0c3Bhbj5MWkg8L3RzcGFuPgogICAgICAgICAgICAgICAgICAgICAgICA8dHNwYW4geD0iNiIgeT0iMjgiPl88L3RzcGFuPgogICAgICAgICAgICAgICAgICAgIDwvdGV4dD4KICAgICAgICAgICAgICAgIDwvZz4KICAgICAgICAgICAgPC9zdmc+CgoJCQk=\" \/><\/div>\n            <div class=\"media-body\">\n                <h3 class=\"package-title\"><a href='https:\/\/otsuka.biz\/blog1\/download\/esp32-ntp\/'>ESP32 NTP<\/a><\/h3>\n                <div class=\"text-muted text-small\"><i class=\"fas fa-copy\"><\/i> 1 \u30d5\u30a1\u30a4\u30eb <i class=\"fas fa-hdd ml-3\"><\/i> 1.21 KB<\/div>\n            <\/div>\n            <div class=\"ml-3\">\n                <a class='wpdm-download-link download-on-click btn btn-primary ' rel='nofollow' href='#' data-downloadurl=\"https:\/\/otsuka.biz\/blog1\/download\/esp32-ntp\/?wpdmdl=3406&refresh=69d5364856e581775580744\">\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/a>\n            <\/div>\n        <\/div>\n    <\/div>\n<\/div>\n\n<\/div>\n\n\n\n<p>(Compiled by the Arduino IDE with the Arduino Core for the ESP32)<\/p>\n\n\n\n<p>const char* ssid = &#8220;**********&#8221;;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Fill in your ssid. \/\/<\/p>\n\n\n\n<p>const char* password = &#8220;**********&#8221;;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Fill in your password. \/\/<\/p>\n\n\n\n<p><br><br><\/p>\n\n\n\n<p>&lt;&lt; Operation of the NTP client &gt;&gt;<\/p>\n\n\n\n<p>The current time can be automatically obtained from the NTP server on the process of the setup() function.<\/p>\n\n\n\n<p>At every 12:00 a.m., the ESP32 is reset to get the current time.<\/p>\n\n\n\n<p>Pulling down the EN-pin can also reset the ESP32.<\/p>\n\n\n\n<p><br><\/p>\n\n\n\n<p>&lt;&lt; Summary in Japanese &gt;&gt;<\/p>\n\n\n\n<p>LCD \u306e\u30b7\u30ea\u30a2\u30eb\u5236\u5fa1\u304c\u4e0d\u5b89\u5b9a\u306a\u306e\u3067\u3001\u9577\u3081\u306e\u9045\u5ef6\u95a2\u6570\u3092\u9593\u7f6e\u3057\u3066\u3044\u308b\u3002<\/p>\n\n\n\n<p>\u672c\u6765 NTP (Network Time Protocol) \u306f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306b\u63a5\u7d9a\u3055\u308c\u305f\u6a5f\u5668\u306e\u6642\u523b\u540c\u671f\u306b\u958b\u767a\u3055\u308c\u305f\u3082\u306e\u3067\u3001 \u76ee\u899a\u307e\u3057\u6642\u8a08\u3084\u8155\u6642\u8a08\u306b\u306f\u3084\u306f\u308a\u96fb\u6ce2\u6642\u8a08\u3067\u3042\u308b\u3002<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&lt;&lt; Introduction in Japanese &gt;&gt; \u521d\u3081\u3066 ESP32 \u306b\u89e6\u308c\u305f\u590f\u304c\u305d\u308d\u305d\u308d\u7d42\u308f\u308d\u3046\u3068\u3059\u308b\u4eca\u3001\u7a81\u7136\u306b\u9577\u671f\u5b89\u500d\u653f\u6a29\u304c\u7d42\u308f\u308a\u3092\u544a\u3052\u305f\u3002\u305d\u3057\u3066\u65e5\u672c\u306f\u65b0\u3057\u3044\u653f\u6cbb\u30ea\u30fc\u30c0\u30fc\u3092\u6234\u3044\u3066\u79cb [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"vkexunit_cta_each_option":"","footnotes":""},"categories":[13,12,5],"tags":[],"class_list":["post-3117","post","type-post","status-publish","format-standard","hentry","category-esp32","category-internet","category-radio-frequency"],"_links":{"self":[{"href":"https:\/\/otsuka.biz\/blog1\/wp-json\/wp\/v2\/posts\/3117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/otsuka.biz\/blog1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/otsuka.biz\/blog1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/otsuka.biz\/blog1\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/otsuka.biz\/blog1\/wp-json\/wp\/v2\/comments?post=3117"}],"version-history":[{"count":2,"href":"https:\/\/otsuka.biz\/blog1\/wp-json\/wp\/v2\/posts\/3117\/revisions"}],"predecessor-version":[{"id":3407,"href":"https:\/\/otsuka.biz\/blog1\/wp-json\/wp\/v2\/posts\/3117\/revisions\/3407"}],"wp:attachment":[{"href":"https:\/\/otsuka.biz\/blog1\/wp-json\/wp\/v2\/media?parent=3117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/otsuka.biz\/blog1\/wp-json\/wp\/v2\/categories?post=3117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/otsuka.biz\/blog1\/wp-json\/wp\/v2\/tags?post=3117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}