<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">ESP32 / ESP8266 아두이노 IDE 코어의 기본 라이브러리 time.h를 이용하여 NTP 서버와 시간 동기화를 시키고 각 시간 및 날짜, 요일 값을 각각 지정 변수에 저장시켜 크리스털 LCD나 기타 디스플레이 모듈에 출력할 수 있도록 하고, 필요시 사용자가 특정 시간으로 변경할 수 있도록 코드를 수정해 보자.&nbsp;&nbsp;</p>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">&nbsp;</p>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">1. ESP32</p>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">아두이노 IDE에서 파일 -&gt; 예제 -&gt; ESP32 -&gt; Time -&gt; SimpleTime를 실행한다.&nbsp;</p>
<figure class="imageblock alignCenter" data-filename="esp32_simpletime.png" data-origin-width="0" data-origin-height="0" style="margin: 0px auto 20px; max-width: 100%; clear: both; display: table; position: relative; text-align: center; font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;"><span data-url="https://blog.kakaocdn.net/dn/yNslK/btqzkDEX8NW/W6zdlC16kX1qJxKd9G3ms0/img.png" data-lightbox="lightbox" data-alt="" style="box-sizing: border-box; cursor: pointer;"><img src="https://blog.kakaocdn.net/dn/yNslK/btqzkDEX8NW/W6zdlC16kX1qJxKd9G3ms0/img.png" srcset="https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FyNslK%2FbtqzkDEX8NW%2FW6zdlC16kX1qJxKd9G3ms0%2Fimg.png" data-filename="esp32_simpletime.png" data-origin-width="0" data-origin-height="0" style="border: 0px; max-width: 100%; display: inline-block; width: 734px; margin: 0px; height: auto;" /></span></figure>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">아래 코드는 기본 예제의 변수 const long&nbsp;&nbsp;gmtOffset_sec = 3600;과 const int&nbsp;&nbsp;&nbsp;daylightOffset_sec = 3600;를 timezone과 summertime 변수로 변경하고 단순화시킨 코드이다.</p>
<figure class="fileblock" data-ke-align="alignCenter" style="margin: 28px auto 20px; max-width: 100%; clear: both; width: 470px; height: 71px; border: 1px solid rgb(233, 233, 233); position: relative; border-radius: 1px; font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;"><a href="https://blog.kakaocdn.net/dn/cyAQ1R/btqzmkqwIEH/fEpzWVgWlhqA8ECgU5tjck/ESP32_SimpleTime_example.ino?attach=1&amp;knm=tfile.ino" class="" style="color: #000000; text-decoration-line: none; transition: all 0.3s ease 0s; display: block; height: 71px;" target="_blank">
      <div class="image" style="box-sizing: border-box; position: absolute; left: 0px; top: 0px; width: 30px; height: 30px; background-image: url(&quot;https://t1.daumcdn.net/tistory_admin/static/manage/post-editor/img_editor_content.svg&quot;); background-position: 0px 0px; margin: 21px 17px 20px 22px;">&nbsp;</div>
      <div class="desc" style="box-sizing: border-box; position: absolute; inset: 0px 60px 0px 70px;">
         <div class="filename" style="box-sizing: border-box; color: #333333; font-size: 14px; text-overflow: ellipsis; height: 20px; margin: 17px 0px 0px;"><span class="name" style="box-sizing: border-box; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 272px; height: 20px; display: block;">ESP32_SimpleTime_example.ino</span></div>
         <div class="size" style="box-sizing: border-box; font-family: &quot;Avenir Next&quot;, sans-serif; font-size: 12px; color: #777777; height: 16px; margin: 2px 0px 0px;">0.00MB</div>
         </div>
      </a></figure>
<pre id="code_1572237388495" class="c++ cpp arduino" data-ke-language="c++" data-ke-type="codeblock" style="overflow: auto hidden; padding: 10px; margin-top: 5px; margin-bottom: 5px; max-width: 100%; border: 1px solid rgb(221, 221, 221); font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; line-height: 21.6px; font-family: &quot;Lucida Console&quot;; background-color: #fafafa; border-radius: 3px;">
   <code class="hljs cpp" style="border: 1px solid rgb(238, 238, 238); background: rgb(40, 44, 52); color: #abb2bf; border-radius: 5px; padding: 0.5em; margin: 3px 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 17px; line-height: 1.3em; font-family: D2Coding, monospace; display: block; overflow-x: auto;"><span class="hljs-meta" style="box-sizing: border-box; color: #61aeee;">#<span class="hljs-meta-keyword" style="box-sizing: border-box;">include</span><span class="hljs-meta-string" style="box-sizing: border-box; color: #98c379;">&lt;WiFi.h&gt;</span></span><span class="hljs-meta" style="box-sizing: border-box; color: #61aeee;">#<span class="hljs-meta-keyword" style="box-sizing: border-box;">include</span><span class="hljs-meta-string" style="box-sizing: border-box; color: #98c379;">"time.h"</span></span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">const</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">char</span>* ssid       = <span class="hljs-string" style="box-sizing: border-box; color: #98c379;">"YOUR_SSID"</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">const</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">char</span>* password   = <span class="hljs-string" style="box-sizing: border-box; color: #98c379;">"YOUR_PASS"</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">const</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">char</span>* ntpServer = <span class="hljs-string" style="box-sizing: border-box; color: #98c379;">"pool.ntp.org"</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">uint8_t</span> timeZone = <span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">9</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">uint8_t</span> summerTime = <span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">0</span>; <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 3600</span><span class="hljs-function" style="box-sizing: border-box; color: #61aeee;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">void</span><span class="hljs-title" style="box-sizing: border-box;">printLocalTime</span><span class="hljs-params" style="box-sizing: border-box; color: #a6e22e;">()</span></span>{
  <span class="hljs-class" style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">struct</span><span class="hljs-title" style="box-sizing: border-box; color: #e6c07b;">tm</span><span class="hljs-title" style="box-sizing: border-box; color: #e6c07b;">timeinfo</span>;</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">if</span>(!getLocalTime(&amp;timeinfo)){
    Serial.println(<span class="hljs-string" style="box-sizing: border-box; color: #98c379;">"Failed to obtain time"</span>);
    <span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">return</span>;
  }
  Serial.println(&amp;timeinfo, <span class="hljs-string" style="box-sizing: border-box; color: #98c379;">"%A, %B %d %Y %H:%M:%S"</span>);
}
<span class="hljs-function" style="box-sizing: border-box; color: #61aeee;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">void</span><span class="hljs-title" style="box-sizing: border-box;">setup</span><span class="hljs-params" style="box-sizing: border-box; color: #a6e22e;">()</span></span>{
  Serial.begin(<span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">115200</span>);
  Serial.<span class="hljs-built_in" style="box-sizing: border-box; color: #e6c07b;">printf</span>(<span class="hljs-string" style="box-sizing: border-box; color: #98c379;">"Connecting to %s "</span>, ssid);  <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">//connect to WiFi</span>
  WiFi.begin(ssid, password);
  <span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">while</span> (WiFi.status() != WL_CONNECTED) {
      delay(<span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">500</span>);
      Serial.print(<span class="hljs-string" style="box-sizing: border-box; color: #98c379;">"."</span>);
  }
  Serial.println(<span class="hljs-string" style="box-sizing: border-box; color: #98c379;">" CONNECTED"</span>);
  configTime(<span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">3600</span> * timeZone, <span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">3600</span> * summerTime, ntpServer); <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">//init and get the time</span>
  printLocalTime();
  WiFi.disconnect(<span class="hljs-literal" style="box-sizing: border-box; color: #56b6c2;">true</span>);  <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">//disconnect WiFi as it's no longer needed</span>
  WiFi.mode(WIFI_OFF);
}
<span class="hljs-function" style="box-sizing: border-box; color: #61aeee;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">void</span><span class="hljs-title" style="box-sizing: border-box;">loop</span><span class="hljs-params" style="box-sizing: border-box; color: #a6e22e;">()</span></span>{
  delay(<span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">1000</span>);
  printLocalTime();
}</code>
   </pre>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">상기 스케치에 사용 중인 와이파이 공유기의 SSID와 비밀번호를 입력해주고 아두이노에 업로드해준다.&nbsp; &nbsp;</p>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">const&nbsp;char*&nbsp;ssid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;"YOUR_SSID";&nbsp;&nbsp;//&nbsp;공유기&nbsp;wifi&nbsp;접속&nbsp;ID&nbsp;<br />const&nbsp;char*&nbsp;password&nbsp;&nbsp;&nbsp;=&nbsp;"YOUR_PASS";&nbsp;&nbsp;//&nbsp;비밀번호</p>
<figure class="imageblock alignCenter" data-filename="esp32_simpletime_monitor.jpg" width="600" data-origin-width="0" data-origin-height="0" style="margin: 0px auto 20px; max-width: 100%; clear: both; display: table; position: relative; text-align: center; font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;"><span data-url="https://blog.kakaocdn.net/dn/moveU/btqzBr3wHkG/OZNXvEPoJ49NwDaRCkUnL0/img.jpg" data-lightbox="lightbox" data-alt="" style="box-sizing: border-box; cursor: pointer;"><img src="https://blog.kakaocdn.net/dn/moveU/btqzBr3wHkG/OZNXvEPoJ49NwDaRCkUnL0/img.jpg" srcset="https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FmoveU%2FbtqzBr3wHkG%2FOZNXvEPoJ49NwDaRCkUnL0%2Fimg.jpg" data-filename="esp32_simpletime_monitor.jpg" width="600" data-origin-width="0" data-origin-height="0" style="border: 0px; max-width: 100%; display: inline-block; margin: 0px; height: auto;" /></span></figure>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">와이파이가 연결되면 NTP 서버와 동기화가 되고 현재 시간이 시리얼 모니터에 출력된다.&nbsp;</p>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">&nbsp;</p>
<div style="box-sizing: border-box; font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1; position: relative; text-align: center; overflow: hidden; margin: auto;"><ins class="adsbygoogle" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-8269928309278636" data-ad-slot="7589244047" data-adsbygoogle-status="done" data-ad-status="filled" style="display: block; height: 108px; width: 879px;"><ins id="aswift_2_expand" tabindex="0" title="Advertisement" aria-label="Advertisement" style="border: none; height: 108px; width: 879px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: inline-table;"><ins id="aswift_2_anchor" style="border: none; height: 108px; width: 879px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: block; overflow: hidden;"><iframe id="aswift_2" name="aswift_2" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" width="879" height="108" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" src="https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-8269928309278636&amp;output=html&amp;h=200&amp;slotname=7589244047&amp;adk=3278490821&amp;adf=1597229448&amp;pi=t.ma~as.7589244047&amp;w=879&amp;fwrn=4&amp;lmt=1642077912&amp;rafmt=11&amp;psa=0&amp;format=879x200&amp;url=https%3A%2F%2Fpostpop.tistory.com%2F84&amp;flash=0&amp;host=ca-host-pub-9691043933427338&amp;wgl=1&amp;uach=WyJXaW5kb3dzIiwiMTAuMC4wIiwieDg2IiwiIiwiOTcuMC40NjkyLjcxIixbXSxudWxsLG51bGwsIjY0Il0.&amp;dt=1642077912621&amp;bpp=1&amp;bdt=659&amp;idt=179&amp;shv=r20220110&amp;mjsv=m202201040101&amp;ptt=9&amp;saldr=aa&amp;abxe=1&amp;cookie=ID%3Dc94963fbc3dd591a-22cdf34e8acf0086%3AT%3D1640687636%3ART%3D1640687636%3AS%3DALNI_MZda89KtmEfIh3gOEJUkRlNH2OqzA&amp;prev_fmts=0x0%2C300x250&amp;nras=1&amp;correlator=3201282353056&amp;frm=20&amp;pv=1&amp;ga_vid=559507242.1640687637&amp;ga_sid=1642077913&amp;ga_hid=1915058806&amp;ga_fc=1&amp;rplot=4&amp;u_tz=540&amp;u_his=5&amp;u_h=1440&amp;u_w=2560&amp;u_ah=1400&amp;u_aw=2560&amp;u_cd=24&amp;u_sd=1&amp;dmc=8&amp;adx=336&amp;ady=2364&amp;biw=1261&amp;bih=1287&amp;scr_x=0&amp;scr_y=0&amp;eid=31063752%2C21067496&amp;oid=2&amp;pvsid=2900713002779533&amp;pem=365&amp;tmod=350&amp;ref=https%3A%2F%2Fwww.google.com%2F&amp;eae=0&amp;fc=1920&amp;brdim=-7%2C0%2C-7%2C0%2C2560%2C0%2C1294%2C1407%2C1278%2C1287&amp;vis=1&amp;rsz=%7C%7CeoEbr%7C&amp;abl=CS&amp;pfx=0&amp;fu=128&amp;bc=31&amp;ifi=3&amp;uci=a!3&amp;btvi=1&amp;fsb=1&amp;xpc=3RO8atDGal&amp;p=https%3A//postpop.tistory.com&amp;dtd=183" data-google-container-id="a!3" data-google-query-id="CK_Lu_XgrvUCFRzJfAodogEPAQ" data-load-complete="true" style="max-width: 100%; left: 0px; position: absolute; top: 0px; border-width: 0px; border-style: initial; width: 879px; height: 108px;"></iframe></ins></ins></ins></div>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">&nbsp;</p>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">코드 분석</p>
<table border="1" style="color: #000000; font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; width: 4799.28px; border-style: solid; border-color: #99cefa; background-color: #f6f9fd;">
   <tbody>
      <tr>
         <td style="width: 4777.28px; padding: 10px;">
            <p>configTime(3600 * timeZone, 3600 * summerTime, ntpServer); //init and get the time</p>
            </td>
         </tr>
      </tbody>
   </table>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">상기 코드는 NTP 서버에 연결하고 서버로부터&nbsp;유닉스 UTC 값을 수신하여 시간 값에 반영하고 time.h에 의해 시간 값(10자리&nbsp;UTC 값)은 매 1초마다 자동으로 증가한다(시계 작동 시작). NTP 서버로부터 값을 받지 못하면 시간 값은 1970년&nbsp; 1월 1일 09 : 00 : 00에서 증가하게 된다.&nbsp;</p>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">&nbsp;</p>
<table border="1" style="color: #000000; font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; width: 4799.28px; border-style: solid; border-color: #99cefa; background-color: #f6f9fd;">
   <tbody>
      <tr>
         <td style="width: 4777.28px; padding: 10px;">
            <p>void&nbsp;printLocalTime()&nbsp;{&nbsp;<br />&nbsp;&nbsp;struct tm timeinfo;&nbsp; // 구조체 변수 선언<br />&nbsp;&nbsp;if(!getLocalTime(&amp;timeinfo)){&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;Serial.println("Failed&nbsp;to&nbsp;obtain&nbsp;time");&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;return;&nbsp;<br />&nbsp;&nbsp;}&nbsp;<br />&nbsp;&nbsp;Serial.println(&amp;timeinfo,&nbsp;"%A,&nbsp;%B&nbsp;%d&nbsp;%Y&nbsp;%H:%M:%S");&nbsp;<br />}</p>
            </td>
         </tr>
      </tbody>
   </table>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">상기 코드는 구조체 변수&nbsp;timeinfo를 선언하고&nbsp;UTC형식 시간 값을 로컬 시간으로 변경해주는 함수와 변경된 로컬 시간을 서식에 맞게 출력해주는 코드이다.</p>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">시간 출력이 서식에 맞게 잘되고 있다. 하지만 상기 코드로는 ESP32를 리셋시켜야만&nbsp;NTP 서버와 시간 동기화를 할 수 있어서 매일 1회 또는 정해진 시간마다 NTP 서버와 시간 동기화를 시킬 수가 없다.</p>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">또한, 크리스탈 LCD 등에 출력하기에는 서식 출력 코드를 사용하는데 제약이 있고 사용자 시간을 설정 역시 할 수 없다.</p>
<div class="google-auto-placed ap_container" style="box-sizing: border-box; font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1; width: 4799.28px; height: auto; clear: both; text-align: center;"><ins data-ad-format="auto" class="adsbygoogle adsbygoogle-noablate" data-ad-client="ca-pub-8269928309278636" data-adsbygoogle-status="done" data-ad-status="filled" style="display: block; margin: auto; background-color: transparent; height: 280px;"><ins id="aswift_6_expand" tabindex="0" title="Advertisement" aria-label="Advertisement" style="border: none; height: 280px; width: 879px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: inline-table;"><ins id="aswift_6_anchor" style="border: none; height: 280px; width: 879px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: block; overflow: visible;"><iframe id="aswift_6" name="aswift_6" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" width="879" height="280" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" src="https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-8269928309278636&amp;output=html&amp;h=280&amp;adk=854006705&amp;adf=4195724218&amp;pi=t.aa~a.3057235084~i.51~rp.4&amp;w=879&amp;fwrn=4&amp;fwrnh=100&amp;lmt=1642077913&amp;num_ads=1&amp;rafmt=1&amp;armr=3&amp;sem=mc&amp;pwprc=6730866626&amp;psa=0&amp;ad_type=text_image&amp;format=879x280&amp;url=https%3A%2F%2Fpostpop.tistory.com%2F84&amp;flash=0&amp;host=ca-host-pub-9691043933427338&amp;fwr=0&amp;pra=3&amp;rh=200&amp;rw=879&amp;rpe=1&amp;resp_fmts=3&amp;wgl=1&amp;fa=27&amp;uach=WyJXaW5kb3dzIiwiMTAuMC4wIiwieDg2IiwiIiwiOTcuMC40NjkyLjcxIixbXSxudWxsLG51bGwsIjY0Il0.&amp;dt=1642077913491&amp;bpp=1&amp;bdt=1529&amp;idt=-M&amp;shv=r20220110&amp;mjsv=m202201040101&amp;ptt=9&amp;saldr=aa&amp;abxe=1&amp;cookie=ID%3Dc94963fbc3dd591a-22cdf34e8acf0086%3AT%3D1640687636%3ART%3D1640687636%3AS%3DALNI_MZda89KtmEfIh3gOEJUkRlNH2OqzA&amp;prev_fmts=0x0%2C300x250%2C879x200&amp;nras=2&amp;correlator=3201282353056&amp;frm=20&amp;pv=1&amp;ga_vid=559507242.1640687637&amp;ga_sid=1642077913&amp;ga_hid=1915058806&amp;ga_fc=1&amp;u_tz=540&amp;u_his=5&amp;u_h=1440&amp;u_w=2560&amp;u_ah=1400&amp;u_aw=2560&amp;u_cd=24&amp;u_sd=1&amp;dmc=8&amp;adx=336&amp;ady=3373&amp;biw=1261&amp;bih=1287&amp;scr_x=0&amp;scr_y=0&amp;eid=31063752%2C21067496&amp;oid=2&amp;pvsid=2900713002779533&amp;pem=365&amp;tmod=350&amp;ref=https%3A%2F%2Fwww.google.com%2F&amp;eae=0&amp;fc=1408&amp;brdim=-7%2C0%2C-7%2C0%2C2560%2C0%2C1294%2C1407%2C1278%2C1287&amp;vis=1&amp;rsz=%7C%7Cs%7C&amp;abl=NS&amp;fu=128&amp;bc=31&amp;ifi=7&amp;uci=a!7&amp;btvi=2&amp;fsb=1&amp;xpc=K99Qc6hLzj&amp;p=https%3A//postpop.tistory.com&amp;dtd=20" data-google-container-id="a!7" data-google-query-id="CJ7K5vXgrvUCFYZgvQodbKQGfg" data-load-complete="true" style="max-width: 100%; margin: 0px auto; left: 0px; position: absolute; top: 0px; border-width: 0px; border-style: initial; width: 879px; height: 280px;"></iframe></ins></ins></ins></div>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">&nbsp;</p>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">원하는 시간에 NTP 서버와 시간 동기화를 할 수 있도록 사용자 함수 get_NTP() 함수를 만들어 주었다. 만약 어떠한 이유로 동기화가 되지 않는다면 약 5초 정도 시간 동기화 시도 후 사용자 시간 설정 set_time() 함수가 실행되어 미리 설정해둔 시간 값을 시작 값으로 하여 시계가 작동하게 된다.&nbsp;&nbsp;</p>
<table border="1" style="color: #000000; font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; width: 4799.28px; border-style: solid; border-color: #99cefa; background-color: #f6f9fd;">
   <tbody>
      <tr>
         <td style="width: 4777.28px; padding: 10px;">
            <p>void&nbsp;get_NTP()&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;NTP&nbsp;서버&nbsp;시간&nbsp;동기화&nbsp;&nbsp;<br />&nbsp;&nbsp;configTime(3600&nbsp;*&nbsp;timeZone,&nbsp;3600&nbsp;*&nbsp;summerTime,&nbsp;ntpServer);&nbsp;&nbsp;//&nbsp;NTP&nbsp;서버&nbsp;접속&nbsp;및&nbsp;동기화&nbsp;함수<br />&nbsp;&nbsp;while(!getLocalTime(&amp;timeinfo)){&nbsp;&nbsp;//&nbsp;로컬&nbsp;시간&nbsp;반영 함수의&nbsp;리턴&nbsp;값이&nbsp;false이면,&nbsp;시간 값없으면&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;Serial.println("Failed&nbsp;to&nbsp;obtain&nbsp;time");&nbsp;&nbsp;//&nbsp;메시지&nbsp;표시&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;set_time();&nbsp;&nbsp;&nbsp;// set time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// 초기값으로 시간 설정&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;return;&nbsp;<br />&nbsp;&nbsp;}&nbsp;<br />}</p>
            </td>
         </tr>
      </tbody>
   </table>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">&nbsp;</p>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">시, 분, 초, 년, 월, 일에 해당하는 변수의 값을 변경하고 set_time() 사용자 함수를 실행하면 시계의 시간을 원하는 시간으로 변경할 수 있다.&nbsp;&nbsp;</p>
<table border="1" style="color: #000000; font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; width: 4799.28px; border-style: solid; border-color: #99cefa; background-color: #f6f9fd;">
   <tbody>
      <tr>
         <td style="width: 4777.28px; padding: 10px;">
            <p>void&nbsp;set_time()&nbsp;{&nbsp;&nbsp;&nbsp;//&nbsp;사용자&nbsp;시간&nbsp;설정&nbsp;함수&nbsp;<br />&nbsp;&nbsp;struct&nbsp;tm&nbsp;tm;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;사용자&nbsp;시간&nbsp;설정용&nbsp;구조체&nbsp;변수&nbsp;선언&nbsp;<br />&nbsp;&nbsp;tm.tm_year&nbsp;=&nbsp;s_yy&nbsp;-&nbsp;1900;&nbsp;&nbsp;<br />&nbsp;&nbsp;tm.tm_mon&nbsp;=&nbsp;s_MM&nbsp;-&nbsp;1;&nbsp;<br />&nbsp;&nbsp;tm.tm_mday&nbsp;=&nbsp;s_dd;&nbsp;<br />&nbsp;&nbsp;tm.tm_hour&nbsp;=&nbsp;s_hh;&nbsp;<br />&nbsp;&nbsp;tm.tm_min&nbsp;=&nbsp;s_mm;&nbsp;<br />&nbsp;&nbsp;tm.tm_sec&nbsp;=&nbsp;s_ss;&nbsp;<br />&nbsp;&nbsp;time_t&nbsp;t&nbsp;=&nbsp;mktime(&amp;tm);&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;UTC&nbsp;값으로&nbsp;변환&nbsp;<br />&nbsp;&nbsp;printf("Setting&nbsp;time:&nbsp;%s",&nbsp;asctime(&amp;tm));&nbsp;//&nbsp;설정&nbsp;시간을&nbsp;문자열로&nbsp;출력&nbsp;<br />&nbsp;&nbsp;struct&nbsp;timeval&nbsp;now&nbsp;=&nbsp;{&nbsp;.tv_sec&nbsp;=&nbsp;t&nbsp;};&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;설정시간을&nbsp;현재&nbsp;시간에&nbsp;반영&nbsp;&nbsp;<br />&nbsp;&nbsp;settimeofday(&amp;now,&nbsp;NULL);&nbsp;&nbsp;<br />}</p>
            </td>
         </tr>
      </tbody>
   </table>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">&nbsp;</p>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">시간 서식 출력 코드를 시, 분, 초 등으로 쪼개어 사용할 수 있도록 시간 출력용 사용자 함수&nbsp;printLocalTime()를 만들어 주었다.&nbsp;&nbsp;"time(&amp;now)"는 시간 동기화가 되거나 또는 set_time() 함수에 의해 사용자 시간 설정이 되면 시계 라이브러리를 통해 자동으로 매 초마다 1씩 증가하는&nbsp;10자리의 UTC 시간 값이다. 이렇게 증가하는 UTC 시간 값과 이전 시간 값을 저장해준 prevEpoch와 비교하여 다르면 시간 출력 코드를 실행하도록 해주었다. 즉 별도의 millis() 함수를 사용하지 않고도 1초가 증가할 때마다 조건을 만족하여 코드를 반복적으로&nbsp;실행하게 된다.&nbsp;&nbsp;</p>
<div class="google-auto-placed ap_container" style="box-sizing: border-box; font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1; width: 4799.28px; height: auto; clear: both; text-align: center;"><ins data-ad-format="auto" class="adsbygoogle adsbygoogle-noablate" data-ad-client="ca-pub-8269928309278636" data-adsbygoogle-status="done" data-ad-status="filled" style="display: block; margin: auto; background-color: transparent; height: 280px;"><ins id="aswift_7_expand" tabindex="0" title="Advertisement" aria-label="Advertisement" style="border: none; height: 280px; width: 879px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: inline-table;"><ins id="aswift_7_anchor" style="border: none; height: 280px; width: 879px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: block; overflow: visible;"><iframe id="aswift_7" name="aswift_7" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" width="879" height="280" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" src="https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-8269928309278636&amp;output=html&amp;h=280&amp;adk=854006705&amp;adf=92370475&amp;pi=t.aa~a.3057235084~i.67~rp.4&amp;w=879&amp;fwrn=4&amp;fwrnh=100&amp;lmt=1642077913&amp;num_ads=1&amp;rafmt=1&amp;armr=3&amp;sem=mc&amp;pwprc=6730866626&amp;psa=0&amp;ad_type=text_image&amp;format=879x280&amp;url=https%3A%2F%2Fpostpop.tistory.com%2F84&amp;flash=0&amp;host=ca-host-pub-9691043933427338&amp;fwr=0&amp;pra=3&amp;rh=200&amp;rw=879&amp;rpe=1&amp;resp_fmts=3&amp;wgl=1&amp;fa=27&amp;uach=WyJXaW5kb3dzIiwiMTAuMC4wIiwieDg2IiwiIiwiOTcuMC40NjkyLjcxIixbXSxudWxsLG51bGwsIjY0Il0.&amp;dt=1642077913491&amp;bpp=1&amp;bdt=1529&amp;idt=1&amp;shv=r20220110&amp;mjsv=m202201040101&amp;ptt=9&amp;saldr=aa&amp;abxe=1&amp;cookie=ID%3Dc94963fbc3dd591a-22cdf34e8acf0086%3AT%3D1640687636%3ART%3D1640687636%3AS%3DALNI_MZda89KtmEfIh3gOEJUkRlNH2OqzA&amp;prev_fmts=0x0%2C300x250%2C879x200%2C879x280&amp;nras=3&amp;correlator=3201282353056&amp;frm=20&amp;pv=1&amp;ga_vid=559507242.1640687637&amp;ga_sid=1642077913&amp;ga_hid=1915058806&amp;ga_fc=1&amp;u_tz=540&amp;u_his=5&amp;u_h=1440&amp;u_w=2560&amp;u_ah=1400&amp;u_aw=2560&amp;u_cd=24&amp;u_sd=1&amp;dmc=8&amp;adx=336&amp;ady=4615&amp;biw=1261&amp;bih=1287&amp;scr_x=0&amp;scr_y=0&amp;eid=31063752%2C21067496&amp;oid=2&amp;pvsid=2900713002779533&amp;pem=365&amp;tmod=350&amp;ref=https%3A%2F%2Fwww.google.com%2F&amp;eae=0&amp;fc=1408&amp;brdim=-7%2C0%2C-7%2C0%2C2560%2C0%2C1294%2C1407%2C1278%2C1287&amp;vis=1&amp;rsz=%7C%7Cs%7C&amp;abl=NS&amp;fu=128&amp;bc=31&amp;ifi=8&amp;uci=a!8&amp;btvi=3&amp;fsb=1&amp;xpc=dZbdMqspCD&amp;p=https%3A//postpop.tistory.com&amp;dtd=25" data-google-container-id="a!8" data-google-query-id="CML95vXgrvUCFZDQfAod5qME9w" data-load-complete="true" style="max-width: 100%; margin: 0px auto; left: 0px; position: absolute; top: 0px; border-width: 0px; border-style: initial; width: 879px; height: 280px;"></iframe></ins></ins></ins></div>
<table border="1" style="color: #000000; font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; width: 4799.28px; border-style: solid; border-color: #99cefa; background-color: #f6f9fd;">
   <tbody>
      <tr>
         <td style="width: 4777.28px; padding: 10px;">
            <p>void&nbsp;printLocalTime()&nbsp;{&nbsp;<br />&nbsp;&nbsp;if&nbsp;(time(&amp;now)&nbsp;!=&nbsp;prevEpoch)&nbsp;{&nbsp;//&nbsp;현재&nbsp;UTC&nbsp;시간&nbsp;값과&nbsp;이전&nbsp;UTC&nbsp;시간&nbsp;값이&nbsp;다르면&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;Serial.println(time(&amp;now));&nbsp;&nbsp;//&nbsp;현재&nbsp;UTC&nbsp;시간&nbsp;값&nbsp;출력&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;getLocalTime(&amp;timeinfo);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;로컬&nbsp;변경 함수 이용&nbsp;UTC&nbsp;시간 값&nbsp;변경&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;dd&nbsp;=&nbsp;timeinfo.tm_mday;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;구조체&nbsp;내&nbsp;해당 값&nbsp;가져오기&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;MM&nbsp;=&nbsp;timeinfo.tm_mon&nbsp;+&nbsp;1;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;yy&nbsp;=&nbsp;timeinfo.tm_year&nbsp;+1900;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;ss&nbsp;=&nbsp;timeinfo.tm_sec;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;mm&nbsp;=&nbsp;timeinfo.tm_min;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;hh&nbsp;=&nbsp;timeinfo.tm_hour;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;week&nbsp;=&nbsp;timeinfo.tm_wday;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;Serial.print(week);&nbsp;Serial.print(".&nbsp;");&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;Serial.print(yy);&nbsp;Serial.print(".&nbsp;");&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;Serial.print(MM);&nbsp;Serial.print(".&nbsp;");&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;Serial.print(dd);&nbsp;Serial.print("&nbsp;");&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;Serial.print(hh);&nbsp;Serial.print(":&nbsp;");&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;Serial.print(mm);&nbsp;Serial.print(":&nbsp;");&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;Serial.println(ss);&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;prevEpoch&nbsp;=&nbsp;time(&amp;now);&nbsp;//&nbsp;현재&nbsp;UTC&nbsp;시간&nbsp;값을&nbsp;저장하여&nbsp;1초마다&nbsp;실행되도록&nbsp;함.&nbsp;<br />&nbsp;&nbsp;}&nbsp;<br />}</p>
            </td>
         </tr>
      </tbody>
   </table>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">&nbsp;</p>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">ESP32 아두이노 IDE 코어의 time.h 라이브러리에 정의된 로컬 시간 관련 구조체 변수는 아래와 같다.&nbsp;</p>
<table border="1" style="color: #000000; font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; width: 4799.28px; border-style: solid; border-color: #99cefa; background-color: #f6f9fd;">
   <tbody>
      <tr>
         <td style="width: 4777.28px; padding: 10px;">
            <p>struct&nbsp;tm&nbsp;{&nbsp;<br />&nbsp;&nbsp;int tm_sec;&nbsp;<br />&nbsp;&nbsp;int&nbsp;tm_min;&nbsp;<br />&nbsp;&nbsp;int&nbsp;tm_hour;&nbsp;<br />&nbsp;&nbsp;int&nbsp;tm_mday;&nbsp;<br />&nbsp;&nbsp;int&nbsp;tm_mon;&nbsp;<br />&nbsp;&nbsp;int&nbsp;tm_year;&nbsp;<br />&nbsp;&nbsp;int&nbsp;tm_wday;&nbsp;<br />&nbsp;&nbsp;int&nbsp;tm_yday;&nbsp;<br />&nbsp;&nbsp;int&nbsp;tm_isdst;&nbsp;<br />#ifdef&nbsp;__TM_GMTOFF&nbsp;<br />&nbsp;&nbsp;long&nbsp;&nbsp;__TM_GMTOFF;&nbsp;<br />#endif&nbsp;<br />#ifdef&nbsp;__TM_ZONE&nbsp;<br />&nbsp;&nbsp;const&nbsp;char&nbsp;*__TM_ZONE;&nbsp;<br />#endif&nbsp;<br />};</p>
            </td>
         </tr>
      </tbody>
   </table>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">week값은 "0 = 일요일, 1 = 월요일, , , 6 = 토요일"이다.</p>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">&nbsp;</p>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">시리얼 모니터에서 전송 옵션을 "새 글"로 하고 "1"을 입력하면 시간 설정 함수가 실행되고 "2"를 입력하면 NTP 서버 동기화가 실행되도록 시리얼 통신 제어 코드를 아래와 같이 작성해 주었다.&nbsp;</p>
<table border="1" style="color: #000000; font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; width: 4799.28px; border-style: solid; border-color: #99cefa; background-color: #f6f9fd;">
   <tbody>
      <tr>
         <td style="width: 4777.28px; padding: 10px;">
            <p>&nbsp;&nbsp;if(Serial.available()&nbsp;&gt;&nbsp;0){&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;temp&nbsp;=&nbsp;Serial.readStringUntil('\n');&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(temp&nbsp;==&nbsp;"1")&nbsp;set_time();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;set&nbsp;time&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;(temp&nbsp;==&nbsp;"2")&nbsp;get_NTP();&nbsp;//&nbsp;NTP&nbsp;Sync&nbsp;<br />&nbsp;&nbsp;}</p>
            </td>
         </tr>
      </tbody>
   </table>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">&nbsp;</p>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">아래 스케치는 상기 코드를 반영한 것이다.</p>
<figure class="fileblock" data-ke-align="alignCenter" style="margin: 28px auto 20px; max-width: 100%; clear: both; width: 470px; height: 71px; border: 1px solid rgb(233, 233, 233); position: relative; border-radius: 1px; font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;"><a href="https://blog.kakaocdn.net/dn/cm9LI8/btqzoATTTC7/waX7uAtei08DDjKUrZQEI1/ESP32_SimpleTime.ino?attach=1&amp;knm=tfile.ino" class="" style="color: #000000; text-decoration-line: none; transition: all 0.3s ease 0s; display: block; height: 71px;" target="_blank">
      <div class="image" style="box-sizing: border-box; position: absolute; left: 0px; top: 0px; width: 30px; height: 30px; background-image: url(&quot;https://t1.daumcdn.net/tistory_admin/static/manage/post-editor/img_editor_content.svg&quot;); background-position: 0px 0px; margin: 21px 17px 20px 22px;">&nbsp;</div>
      <div class="desc" style="box-sizing: border-box; position: absolute; inset: 0px 60px 0px 70px;">
         <div class="filename" style="box-sizing: border-box; color: #333333; font-size: 14px; text-overflow: ellipsis; height: 20px; margin: 17px 0px 0px;"><span class="name" style="box-sizing: border-box; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 272px; height: 20px; display: block;">ESP32_SimpleTime.ino</span></div>
         <div class="size" style="box-sizing: border-box; font-family: &quot;Avenir Next&quot;, sans-serif; font-size: 12px; color: #777777; height: 16px; margin: 2px 0px 0px;">0.00MB</div>
         </div>
      </a></figure>
<pre id="code_1572237388523" class="c++ cpp arduino" data-ke-language="c++" data-ke-type="codeblock" style="overflow: auto hidden; padding: 10px; margin-top: 5px; margin-bottom: 5px; max-width: 100%; border: 1px solid rgb(221, 221, 221); font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; line-height: 21.6px; font-family: &quot;Lucida Console&quot;; background-color: #fafafa; border-radius: 3px;">
   <code class="hljs cpp" style="border: 1px solid rgb(238, 238, 238); background: rgb(40, 44, 52); color: #abb2bf; border-radius: 5px; padding: 0.5em; margin: 3px 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 17px; line-height: 1.3em; font-family: D2Coding, monospace; display: block; overflow-x: auto;"><span class="hljs-meta" style="box-sizing: border-box; color: #61aeee;">#<span class="hljs-meta-keyword" style="box-sizing: border-box;">include</span><span class="hljs-meta-string" style="box-sizing: border-box; color: #98c379;">&lt;WiFi.h&gt;  // 와이파이 라이브러리</span></span><span class="hljs-meta" style="box-sizing: border-box; color: #61aeee;">#<span class="hljs-meta-keyword" style="box-sizing: border-box;">include</span><span class="hljs-meta-string" style="box-sizing: border-box; color: #98c379;">"time.h"</span><span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 시계 라이브러리</span></span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">const</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">char</span>* ssid       = <span class="hljs-string" style="box-sizing: border-box; color: #98c379;">"SK_WiFiGIGA40F7"</span>; <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 공유기 SSID</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">const</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">char</span>* password   = <span class="hljs-string" style="box-sizing: border-box; color: #98c379;">"1712037218"</span>;      <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 공유기 비밀번호</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">const</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">char</span>* ntpServer = <span class="hljs-string" style="box-sizing: border-box; color: #98c379;">"pool.ntp.org"</span>;     <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// NTP 서버</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">uint8_t</span> timeZone = <span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">9</span>;                       <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 한국 타임존 설정</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">uint8_t</span> summerTime = <span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">0</span>; <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 3600             // 썸머타임 시간</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">int</span> s_hh = <span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">12</span>;         <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 시간 설정용 시 변수 및 초기값, &lt; 0 조건 위해 자료형 int</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">int</span> s_mm = <span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">59</span>;         <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 시간 설정용 분 변수 및 초기값 </span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">uint8_t</span> s_ss = <span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">45</span>;     <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 시간 설정용 초 변수 및 초기값</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">uint16_t</span> s_yy = <span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">2017</span>;  <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 시간 설정용 년 변수 및 초기값 </span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">uint8_t</span> s_MM = <span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">11</span>;     <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 시간 설정용 월 변수 및 초기값 </span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">uint8_t</span> s_dd = <span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">19</span>;     <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 시간 설정용 일 변수 및 초기값 </span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">time_t</span> now;          <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 현재 시간 변수 </span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">time_t</span> prevEpoch;    <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 이전 UTC 시간 변수</span><span class="hljs-class" style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">struct</span><span class="hljs-title" style="box-sizing: border-box; color: #e6c07b;">tm</span><span class="hljs-title" style="box-sizing: border-box; color: #e6c07b;">timeinfo</span>;</span><span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 로컬 시간 반영용 구조체 변수 선언</span><span class="hljs-function" style="box-sizing: border-box; color: #61aeee;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">void</span><span class="hljs-title" style="box-sizing: border-box;">get_NTP</span><span class="hljs-params" style="box-sizing: border-box; color: #a6e22e;">()</span></span>{     <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// NTP 서버 시간 동기화 </span>
  configTime(<span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">3600</span> * timeZone, <span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">3600</span> * summerTime, ntpServer); <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// NTP 서버 접속 및 동기화 함수</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">while</span>(!getLocalTime(&amp;timeinfo)){  <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 로컬 시간 반영함수이 리턴 값이 false이면, 시간값 없으면</span>
    Serial.println(<span class="hljs-string" style="box-sizing: border-box; color: #98c379;">"Failed to obtain time"</span>);  <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 메시지 표시</span>
    set_time();   <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// set time                 // 초기값으로 시간 설정</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">return</span>;
  }
}
<span class="hljs-function" style="box-sizing: border-box; color: #61aeee;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">void</span><span class="hljs-title" style="box-sizing: border-box;">set_time</span><span class="hljs-params" style="box-sizing: border-box; color: #a6e22e;">()</span></span>{   <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 사용자 시간 설정 함수</span><span class="hljs-class" style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">struct</span><span class="hljs-title" style="box-sizing: border-box; color: #e6c07b;">tm</span><span class="hljs-title" style="box-sizing: border-box; color: #e6c07b;">tm</span>;</span><span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 사용자 시간 설정용 구조체 변수 선언</span>
  tm.tm_year = s_yy - <span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">1900</span>; 
  tm.tm_mon = s_MM - <span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">1</span>;
  tm.tm_mday = s_dd;
  tm.tm_hour = s_hh;
  tm.tm_min = s_mm;
  tm.tm_sec = s_ss;
  <span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">time_t</span> t = mktime(&amp;tm);    <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// UTC 값으로 변환</span><span class="hljs-built_in" style="box-sizing: border-box; color: #e6c07b;">printf</span>(<span class="hljs-string" style="box-sizing: border-box; color: #98c379;">"Setting time: %s"</span>, asctime(&amp;tm)); <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 설정 시간을 문자열로 출력</span><span class="hljs-class" style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">struct</span><span class="hljs-title" style="box-sizing: border-box; color: #e6c07b;">timeval</span><span class="hljs-title" style="box-sizing: border-box; color: #e6c07b;">now</span> = {</span> .tv_sec = t };     <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 설정시간을 현재 시간에 반영 </span>
  settimeofday(&amp;now, <span class="hljs-literal" style="box-sizing: border-box; color: #56b6c2;">NULL</span>); 
}
<span class="hljs-function" style="box-sizing: border-box; color: #61aeee;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">void</span><span class="hljs-title" style="box-sizing: border-box;">printLocalTime</span><span class="hljs-params" style="box-sizing: border-box; color: #a6e22e;">()</span></span>{
  <span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">if</span> (time(&amp;now) != prevEpoch) { <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 현재 UTC 시간 값과 이전 UTC 시간 값이 다르면 </span>
    Serial.println(time(&amp;now));  <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 현재 UTC 시간 값 출력</span>
    getLocalTime(&amp;timeinfo);     <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 로컬 변경함수이용 UTC 시간값 변경</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">int</span> dd = timeinfo.tm_mday;       <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 구조체 내 해당값 가져오기</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">int</span> MM = timeinfo.tm_mon + <span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">1</span>;
    <span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">int</span> yy = timeinfo.tm_year +<span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">1900</span>;
    <span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">int</span> ss = timeinfo.tm_sec;
    <span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">int</span> mm = timeinfo.tm_min;
    <span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">int</span> hh = timeinfo.tm_hour;
    <span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">int</span> week = timeinfo.tm_wday;
    Serial.print(week); Serial.print(<span class="hljs-string" style="box-sizing: border-box; color: #98c379;">". "</span>);
    Serial.print(yy); Serial.print(<span class="hljs-string" style="box-sizing: border-box; color: #98c379;">". "</span>);
    Serial.print(MM); Serial.print(<span class="hljs-string" style="box-sizing: border-box; color: #98c379;">". "</span>);
    Serial.print(dd); Serial.print(<span class="hljs-string" style="box-sizing: border-box; color: #98c379;">" "</span>);
    Serial.print(hh); Serial.print(<span class="hljs-string" style="box-sizing: border-box; color: #98c379;">": "</span>);
    Serial.print(mm); Serial.print(<span class="hljs-string" style="box-sizing: border-box; color: #98c379;">": "</span>);
    Serial.println(ss);
    prevEpoch = time(&amp;now); <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 현재 UTC 시간 값을 저장하여 1초마다 실행되도록 함.</span>
  }
}
<span class="hljs-function" style="box-sizing: border-box; color: #61aeee;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">void</span><span class="hljs-title" style="box-sizing: border-box;">setup</span><span class="hljs-params" style="box-sizing: border-box; color: #a6e22e;">()</span></span>{
  Serial.begin(<span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">115200</span>);
  Serial.<span class="hljs-built_in" style="box-sizing: border-box; color: #e6c07b;">printf</span>(<span class="hljs-string" style="box-sizing: border-box; color: #98c379;">"Connecting to %s "</span>, ssid); <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 공유기 아이디 표시</span>
  WiFi.begin(ssid, password);               <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 와이파이 STA모드 시작 및 연결</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">while</span> (WiFi.status() != WL_CONNECTED) {   <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 와이파이 연결이 안된 상태이면 </span>
    delay(<span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">500</span>);                             <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 0.5초마다</span>
    Serial.print(<span class="hljs-string" style="box-sizing: border-box; color: #98c379;">"."</span>);                      <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// '.' 표시</span>
  }
  Serial.println(<span class="hljs-string" style="box-sizing: border-box; color: #98c379;">" CONNECTED"</span>);
  get_NTP();                                <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// NTP 서버 시간 동기화 시작</span>
}
<span class="hljs-function" style="box-sizing: border-box; color: #61aeee;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">void</span><span class="hljs-title" style="box-sizing: border-box;">loop</span><span class="hljs-params" style="box-sizing: border-box; color: #a6e22e;">()</span></span>{
  <span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">if</span>(Serial.available() &gt; <span class="hljs-number" style="box-sizing: border-box; color: #d19a66;">0</span>){
    String temp = Serial.readStringUntil(<span class="hljs-string" style="box-sizing: border-box; color: #98c379;">'\n'</span>);
    <span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">if</span> (temp == <span class="hljs-string" style="box-sizing: border-box; color: #98c379;">"1"</span>) set_time();     <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// set time</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">else</span><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">if</span> (temp == <span class="hljs-string" style="box-sizing: border-box; color: #98c379;">"2"</span>) get_NTP(); <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// NTP Sync</span>
  }
  printLocalTime();                  <span class="hljs-comment" style="box-sizing: border-box; color: #b18eb1; font-style: italic;">// 로컬 시간 출력</span>
}</code>
   </pre>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">&nbsp;</p>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">상기 코드에서는 매 초에 대한 오차값 보정을 해줄 수는 없다. 이전 글&nbsp;<b><a href="https://postpop.tistory.com/39" style="color: #000000; text-decoration-line: none; transition: all 0.3s ease 0s;" target="_blank">아두이노 시계 예제, ESP01 WiFi 이용 시간 동기화 하기</a></b>&nbsp;는 자체 millis() 함수를 사용하여 시계를 구현했으므로 실제 초와 millis() 함수의 초값에 발생하는 오차를 측정하고 millis() 함수의 조건 범위를 조정하여 좀 더 정확한 시계를 구현할 수 있었다.&nbsp;</p>
<p style="font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1;">&nbsp;</p>
<div style="box-sizing: border-box; font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1; position: relative; text-align: center; overflow: hidden; margin: auto;"><ins class="kakao_ad_area" data-ad-unit="DAN-1k1zja6dnrfj7" data-ad-width="728" data-ad-height="90" id="kakao_ad_KX2KPc" style="display: inline-block; text-decoration-line: none; height: 90px; max-height: inherit; min-height: 90px; min-width: 728px; width: 728px;">
      <div data-ad-creative-wrap="outer" class="adfit__html-banner" style="box-sizing: border-box; position: relative; overflow: hidden; max-height: inherit; min-width: 728px; min-height: 90px;">
         <div data-ad-creative-wrap="inner" class="adfit__html-banner__inner" style="box-sizing: border-box; overflow: hidden; border: 0px; margin: 0px auto; height: 90px;">
            <div style="box-sizing: border-box;"><iframe src="https://t1.daumcdn.net/adfit/adunit_style/3901799efbe401fc1813f3f94e575a9eb944204d" width="100%" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" name="%5B%7B%22usePrefersColorScheme%22%3A%22N%22%2C%22usePreferColorScheme%22%3A%22N%22%2C%22frameId%22%3A%227c4d694b-2f0d-45c6-a4e7-7ffba0785004%22%2C%22frameName%22%3A%227c4d694b-2f0d-45c6-a4e7-7ffba0785004%22%2C%22title%22%3A%22%EB%8C%80%EA%B5%AC%ED%95%9C%EA%B5%AD%EA%B3%B5%EB%AC%B4%EC%9B%90%ED%95%99%EC%9B%90%22%2C%22body%22%3A%22%EB%8C%80%EA%B5%AC%EA%B2%BD%EB%B6%81%20%EC%98%A4%ED%94%84%EB%9D%BC%EC%9D%B8%201%EC%9C%84%2C%ED%95%A9%EA%B2%A9%ED%9B%84%EA%B8%B0%208000%EB%AA%85%2C11%EC%9B%94%2015%EC%9D%BC%202%EC%B0%A8%20%EA%B0%9C%EA%B0%95%20%EB%93%B1%EB%A1%9D%EC%A4%91%22%2C%22adInfoIcon%22%3A%7B%22url%22%3A%22https%3A%2F%2Ft1.daumcdn.net%2Fbiz%2Fui%2Fad%2FADmark%2Fi_mark_200803.png%22%2C%22width%22%3A15%2C%22height%22%3A15%7D%2C%22adInfoUrl%22%3A%22https%3A%2F%2Finfo.ad.daum.net%2Foptout.do%22%2C%22landingUrl%22%3A%22https%3A%2F%2Fka.ad.daum.net%2Fclick%2Fhttp%253A%252F%252Ftestb.com%253Futm_source%253Dkakao%2526utm_medium%253Dkeyword%2526utm_campaign%253DPREMIUM_LINK%2526k_campaign%253D244548035410108416%2526k_adgroup%253D244549374898839552%2526k_media%253DPREMIUM_LINK_CONTENT%2526k_creative%253D246349500930752512%2526k_creativelink%253D246349501006249984%2526k_rank%253D1%2FTpn9jrMaHHPsWmxn2b6D508UiU86WqTukyuiDIXBMwww34YrIF9k6ArjBotdGLzU0tHLgnfVdeKf2dZdOgs3Prt4wTzs_OQEpUC8vKLdyUCobcnt5c9KKFBjjLFKDT_um9cyCT6HE5jnnZqbYWVWx4-AUDzP7_a8P9o4bX3AfTZD38q3TeMZlPtrGx6GclpHEKH563A1vlpfA0LZJl1Oe7J_JhQSxMEFMnlMsLOAwUpxnMClKl-5j3yUBVxmrwuAFCcqc1piMBoA5p48OXjIoA_xKQrOooNl434PaliNbZeXHSJ2j6mHw6ASV_1SFdkbgcygQc808H737OZH6HPdy92tgY-Esc5AoMwLx7Zm1wtIXNRtmoKW0YNxbuI1dg%3D%3D%3Fp%3DQQe_TsL00pHe_Io9C4WKHw%22%2C%22useAdInfoIcon%22%3Atrue%2C%22useAdInfoUrl%22%3Atrue%2C%22events%22%3A%5B%7B%22type%22%3A%22viewable%22%2C%22url%22%3A%22https%3A%2F%2Fka.ad.daum.net%2Fvimp%2FTpn9jrMaHHPsWmxn2b6D508UiU86WqTukyuiDIXBMwww34YrIF9k6ArjBotdGLzU0tHLgnfVdeKf2dZdOgs3Prt4wTzs_OQEpUC8vKLdyUCobcnt5c9KKFBjjLFKDT_um9cyCT6HE5jnnZqbYWVWx4-AUDzP_Pe-aIUQYn2IZ3pcmIPyEoQC%3Fp%3DQQe_TsL00pHe_Io9C4WKHw%22%7D%2C%7B%22type%22%3A%22rendered%22%2C%22url%22%3A%22https%3A%2F%2Fka.ad.daum.net%2Frimp%2FTpn9jrMaHHPsWmxn2b6D508UiU86WqTukyuiDIXBMwww34YrIF9k6ArjBotdGLzU0tHLgnfVdeKf2dZdOgs3Prt4wTzs_OQEpUC8vKLdyUCobcnt5c9KKFBjjLFKDT_um9cyCT6HE5jnnZqbYWVWx4-AUDzP_Pe-aIUQYn2IZ3pcmIPyEoQC%3Fp%3DQQe_TsL00pHe_Io9C4WKHw%22%7D%2C%7B%22type%22%3A%22rendered%22%2C%22url%22%3A%22https%3A%2F%2Fkyson.ad.daum.net%2Fad%2Frendered%3Frequest_id%3D364e5521-7e13-46fb-960a-520c8244d960%26adunit_id%3DDAN-1k1zja6dnrfj7%26bid_id%3Df6da1965-2dfe-47bf-aec6-64b86184fd0d1%26dsp_id%3DKEYWORDAD%26med_dsp_id%3DKAAS%26network_type%3DGENERAL%26sdk_type%3Dweb%26sdk_version%3D4.1.4%26ad_type%3DBanner%26w%3D728%26h%3D90%26template_seq%3D27%22%7D%2C%7B%22type%22%3A%22viewable%22%2C%22url%22%3A%22https%3A%2F%2Fkyson.ad.daum.net%2Fad%2Fviewable%3Frequest_id%3D364e5521-7e13-46fb-960a-520c8244d960%26adunit_id%3DDAN-1k1zja6dnrfj7%26bid_id%3Df6da1965-2dfe-47bf-aec6-64b86184fd0d1%26dsp_id%3DKEYWORDAD%26med_dsp_id%3DKAAS%26network_type%3DGENERAL%26sdk_type%3Dweb%26sdk_version%3D4.1.4%26ad_type%3DBanner%26w%3D728%26h%3D90%26template_seq%3D27%22%7D%2C%7B%22type%22%3A%22click%22%2C%22url%22%3A%22https%3A%2F%2Fkyson.ad.daum.net%2Fad%2Fclick%3Frequest_id%3D364e5521-7e13-46fb-960a-520c8244d960%26adunit_id%3DDAN-1k1zja6dnrfj7%26bid_id%3Df6da1965-2dfe-47bf-aec6-64b86184fd0d1%26dsp_id%3DKEYWORDAD%26med_dsp_id%3DKAAS%26network_type%3DGENERAL%26sdk_type%3Dweb%26sdk_version%3D4.1.4%26ad_type%3DBanner%26w%3D728%26h%3D90%26template_seq%3D27%22%7D%2C%7B%22type%22%3A%22duration%22%2C%22url%22%3A%22https%3A%2F%2Fkyson.ad.daum.net%2Fad%2Fduration%3Frequest_id%3D364e5521-7e13-46fb-960a-520c8244d960%26adunit_id%3DDAN-1k1zja6dnrfj7%26bid_id%3Df6da1965-2dfe-47bf-aec6-64b86184fd0d1%26dsp_id%3DKEYWORDAD%26med_dsp_id%3DKAAS%26network_type%3DGENERAL%26sdk_type%3Dweb%26sdk_version%3D4.1.4%26ad_type%3DBanner%26w%3D728%26h%3D90%26template_seq%3D27%22%7D%2C%7B%22type%22%3A%22rendered%22%2C%22url%22%3A%22https%3A%2F%2Fserv.ds.kakao.com%2Fdspr%2Fsync%3Fdspr%3DalHgmZ_rq05OpnPWXKqO-R1ac5RlRCnJcXuv3-y0kdqiWlg47tPEoJn7xQlhJ51M_oWcuWmn42H-OukDOErSL1X3BAy_ZaBhT2SJOhQftUn3XRUwCdGaZBcogvPNfqDeZlB5_6MxbUAcBeA6PwnS9LhVoOr0vghgcaB2YrN04vIYFMstJ364POVK5vnH3rvhsvRkXnIRQDb37WDRqkiG7lre_TK6XrnTmabC4xunlx6fF0HUykRUGGcAZY2-Lu_u9n5g1miwlD0A88yBijy-UmEgerNaAfyBvC1vrg3jk50hzZwX-ZgZ-lQz6YRUX4Fjab3STiM6NhKSHv0BMPDFof5K7S4EgXeeRj92PTxyNFBMyYNVbf-b0LKibWwYEvhJLT2FdgpPttz0-3-JfAquexCi437hBX4NVwwsWZKiMIxGZkq4i1I9aEwm8EsLLvTi6A15kLkvnbsnhXfF0PKPCaiGKX1RHDBcrf5_sJsqNvgpAl7qTnNKz8dB9DR8WjSeHJEn0RAtyD0hIM6c6u822TV7b4_nJ6c5d6BLbDfRwjalVjzrWAkWOz8JCNWkt0gq%22%7D%5D%2C%22dspId%22%3A%22KEYWORDAD%22%2C%22bodyLink%22%3A%7B%22url%22%3A%22https%3A%2F%2Fka.ad.daum.net%2Fclick%2Fhttp%253A%252F%252Ftestb.com%253Futm_source%253Dkakao%2526utm_medium%253Dkeyword%2526utm_campaign%253DPREMIUM_LINK%2526k_campaign%253D244548035410108416%2526k_adgroup%253D244549374898839552%2526k_media%253DPREMIUM_LINK_CONTENT%2526k_creative%253D246349500930752512%2526k_creativelink%253D246349501006249984%2526k_rank%253D1%2FTpn9jrMaHHPsWmxn2b6D508UiU86WqTukyuiDIXBMwww34YrIF9k6ArjBotdGLzU0tHLgnfVdeKf2dZdOgs3Prt4wTzs_OQEpUC8vKLdyUCobcnt5c9KKFBjjLFKDT_um9cyCT6HE5jnnZqbYWVWx4-AUDzP7_a8P9o4bX3AfTZD38q3TeMZlPtrGx6GclpHEKH563A1vlpfA0LZJl1Oe7J_JhQSxMEFMnlMsLOAwUpxnMClKl-5j3yUBVxmrwuAFCcqc1piMBoA5p48OXjIoA_xKQrOooNl434PaliNbZeXHSJ2j6mHw6ASV_1SFdkbgcygQc808H737OZH6HPdy92tgY-Esc5AoMwLx7Zm1wtIXNRtmoKW0YNxbrNKaGyYdu8eNjDx1bG6UkQ6LoOaBG5qCfY1r_aX%3Fp%3DQQe_TsL00pHe_Io9C4WKHw%22%7D%2C%22displayUrl%22%3A%22http%3A%2F%2Ftestb.com%22%2C%22nasTemplateSeq%22%3A27%2C%22type%22%3A%22native%22%7D%5D" id="7c4d694b-2f0d-45c6-a4e7-7ffba0785004" style="max-width: 100%; position: absolute; top: 0px; left: 0px; display: block; border-width: initial; border-style: none; height: 90px; width: 728px; min-width: 728px; min-height: 90px; overflow: hidden; padding: 0px; margin: 0px auto;"></iframe></div>
            </div>
         </div>
      </ins></div>
<div style="box-sizing: border-box; font-family: &quot;Ubuntu Condensed&quot;, &quot;Noto Sans Korean&quot;; font-size: 16px; background-color: #f1f1f1; position: relative; text-align: center; overflow: hidden; margin: auto;"><ins class="adsbygoogle" data-ad-client="ca-pub-8269928309278636" data-ad-slot="5172369234" data-ad-format="auto" data-full-width-responsive="true" data-adsbygoogle-status="done" data-ad-status="filled" style="display: block; height: 227px; width: 879px;"><ins id="aswift_3_expand" tabindex="0" title="Advertisement" aria-label="Advertisement" style="border: none; height: 227px; width: 879px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: inline-table;"><ins id="aswift_3_anchor" style="border: none; height: 227px; width: 879px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: block; overflow: hidden;"></ins></ins></ins></div>