<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[Solved]using built-in RTC on ArduinoIDE?]]></title><description><![CDATA[<p dir="auto">In MicroPython, we can use built-in RTC as clock, such as NTP clock.<br />
Is there any way (library) to handle built-in RTC as clock on ArduinoIDE?</p>
]]></description><link>https://community.m5stack.com/topic/986/solved-using-built-in-rtc-on-arduinoide</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 06:22:06 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/986.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 07 May 2019 08:58:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Solved]using built-in RTC on ArduinoIDE? on Wed, 08 May 2019 09:31:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/akita11" aria-label="Profile: akita11">@<bdi>akita11</bdi></a> said in <a href="/post/4187">[Solved]using built-in RTC on ArduinoIDE?</a>:</p>
<blockquote>
<p dir="auto">No, my question is NOT solved yet...<br />
ah ok sorry, i don't know this...</p>
</blockquote>
]]></description><link>https://community.m5stack.com/post/4188</link><guid isPermaLink="true">https://community.m5stack.com/post/4188</guid><dc:creator><![CDATA[kat]]></dc:creator><pubDate>Wed, 08 May 2019 09:31:25 GMT</pubDate></item><item><title><![CDATA[Reply to [Solved]using built-in RTC on ArduinoIDE? on Wed, 08 May 2019 06:38:01 GMT]]></title><description><![CDATA[<p dir="auto">No, my question is NOT solved yet...</p>
]]></description><link>https://community.m5stack.com/post/4187</link><guid isPermaLink="true">https://community.m5stack.com/post/4187</guid><dc:creator><![CDATA[akita11]]></dc:creator><pubDate>Wed, 08 May 2019 06:38:01 GMT</pubDate></item><item><title><![CDATA[Reply to [Solved]using built-in RTC on ArduinoIDE? on Tue, 07 May 2019 23:46:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kat" aria-label="Profile: kat">@<bdi>kat</bdi></a> Thanks, this seems to be software-counting clock in main loop. I'm looking for background-counting clock...</p>
]]></description><link>https://community.m5stack.com/post/4181</link><guid isPermaLink="true">https://community.m5stack.com/post/4181</guid><dc:creator><![CDATA[akita11]]></dc:creator><pubDate>Tue, 07 May 2019 23:46:40 GMT</pubDate></item><item><title><![CDATA[Reply to [Solved]using built-in RTC on ArduinoIDE? on Tue, 07 May 2019 13:36:33 GMT]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I have found this, it's maybe what you want:</p>
<p dir="auto">#include &lt;M5Stack.h&gt;<br />
#define TFT_GREY 0x5AEB</p>
<p dir="auto">uint32_t targetTime = 0;                    // for next 1 second timeout<br />
static uint8_t conv2d(const char* p); // Forward declaration needed for IDE 1.6.x<br />
uint8_t hh = conv2d(<strong>TIME</strong>), mm = conv2d(<strong>TIME</strong> + 3), ss = conv2d(<strong>TIME</strong> + 6); // Get H, M, S from compile time</p>
<p dir="auto">byte omm = 99, oss = 99;<br />
byte xcolon = 0, xsecs = 0;<br />
unsigned int colour = 0;</p>
<p dir="auto">void setup(void) {<br />
<a href="//Serial.begin" target="_blank" rel="noopener noreferrer nofollow ugc">//Serial.begin</a>(115200);<br />
M5.begin();<br />
// M5.Lcd.setRotation(1);<br />
M5.Lcd.fillScreen(TFT_BLACK);</p>
<p dir="auto">M5.Lcd.setTextSize(1);<br />
M5.Lcd.setTextColor(TFT_YELLOW, TFT_BLACK);</p>
<p dir="auto">targetTime = millis() + 1000;<br />
}</p>
<p dir="auto">void loop() {<br />
if (targetTime &lt; millis()) {<br />
// Set next update for 1 second later<br />
targetTime = millis() + 1000;</p>
<pre><code>// Adjust the time values by adding 1 second
ss++;              // Advance second
if (ss == 60) {    // Check for roll-over
  ss = 0;          // Reset seconds to zero
  omm = mm;        // Save last minute time for display update
  mm++;            // Advance minute
  if (mm &gt; 59) {   // Check for roll-over
    mm = 0;
    hh++;          // Advance hour
    if (hh &gt; 23) { // Check for 24hr roll-over (could roll-over on 13)
      hh = 0;      // 0 for 24 hour clock, set to 1 for 12 hour clock
    }
  }
}


// Update digital time
int xpos = 0;
int ypos = 85; // Top left corner ot clock text, about half way down
int ysecs = ypos + 24;

if (omm != mm) { // Redraw hours and minutes time every minute
  omm = mm;
  // Draw hours and minutes
  if (hh &lt; 10) xpos += M5.Lcd.drawChar('0', xpos, ypos, 8); // Add hours leading zero for 24 hr clock
  xpos += M5.Lcd.drawNumber(hh, xpos, ypos, 8);             // Draw hours
  xcolon = xpos; // Save colon coord for later to flash on/off later
  xpos += M5.Lcd.drawChar(':', xpos, ypos - 8, 8);
  if (mm &lt; 10) xpos += M5.Lcd.drawChar('0', xpos, ypos, 8); // Add minutes leading zero
  xpos += M5.Lcd.drawNumber(mm, xpos, ypos, 8);             // Draw minutes
  xsecs = xpos; // Sae seconds 'x' position for later display updates
}
if (oss != ss) { // Redraw seconds time every second
  oss = ss;
  xpos = xsecs;

  if (ss % 2) { // Flash the colons on/off
    M5.Lcd.setTextColor(0x39C4, TFT_BLACK);        // Set colour to grey to dim colon
    M5.Lcd.drawChar(':', xcolon, ypos - 8, 8);     // Hour:minute colon
    xpos += M5.Lcd.drawChar(':', xsecs, ysecs, 6); // Seconds colon
    M5.Lcd.setTextColor(TFT_YELLOW, TFT_BLACK);    // Set colour back to yellow
  }
  else {
    M5.Lcd.drawChar(':', xcolon, ypos - 8, 8);     // Hour:minute colon
    xpos += M5.Lcd.drawChar(':', xsecs, ysecs, 6); // Seconds colon
  }

  //Draw seconds
  if (ss &lt; 10) xpos += M5.Lcd.drawChar('0', xpos, ysecs, 6); // Add leading zero
  M5.Lcd.drawNumber(ss, xpos, ysecs, 6);                     // Draw seconds
 }
</code></pre>
<p dir="auto">}<br />
}</p>
<p dir="auto">static uint8_t conv2d(const char* p) {<br />
uint8_t v = 0;<br />
if ('0' &lt;= *p &amp;&amp; *p &lt;= '9')<br />
v = *p - '0';<br />
return 10 * v + *++p - '0';<br />
}</p>
]]></description><link>https://community.m5stack.com/post/4178</link><guid isPermaLink="true">https://community.m5stack.com/post/4178</guid><dc:creator><![CDATA[kat]]></dc:creator><pubDate>Tue, 07 May 2019 13:36:33 GMT</pubDate></item></channel></rss>