<?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[DS3231 on M5Stack - Need your Help]]></title><description><![CDATA[<p dir="auto">HI everyone,</p>
<p dir="auto">I am currently trying to use a DS3231 external RTC on my M5Stack core grey.</p>
<p dir="auto">I have tried many different libraries but problem remains the same :</p>
<ul>
<li>I know the RTC is seen. I have run I2C scan and my DS3231 RTC has the 0x57 address.</li>
<li>I am able to set the current time into the RTC.</li>
<li>I am able to read the RTC. But the info displayed on the Lcd is not correct or maybe the reading is wrong. The seconds displayed are chaotic and the minutes go down when the seconds reach 60...</li>
</ul>
<p dir="auto">For example :</p>
<p dir="auto"><img src="https://imagizer.imageshack.com/img924/7969/CCCUWA.jpg" alt="alt text" class=" img-fluid img-markdown" /></p>
<p dir="auto">Here, for this exemple, I am using the RTCLib library from Adafruit.</p>
<p dir="auto">Here is my code :</p>
<hr />
<p dir="auto">#include "RTClib.h"<br />
#include &lt;M5Stack.h&gt;<br />
#include &lt;Wire.h&gt;</p>
<p dir="auto">RTC_DS3231 rtc;</p>
<p dir="auto">char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};</p>
<p dir="auto">void setup () {</p>
<p dir="auto">Serial.begin(9600);<br />
M5.begin();<br />
Wire.begin();</p>
<p dir="auto">if (! rtc.begin()) {</p>
<pre><code>M5.Lcd.println("Couldn't find RTC");
Serial.flush();
abort();
</code></pre>
<p dir="auto">}</p>
<pre><code>//Adjust the time to the current one
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void loop () {</p>
<pre><code>//Getting the time
DateTime now = rtc.now();

//Printing it on M5 Lcd
M5.Lcd.print(now.year(), DEC);
M5.Lcd.print('/');
M5.Lcd.print(now.month(), DEC);
M5.Lcd.print('/');
M5.Lcd.print(now.day(), DEC);
M5.Lcd.print(" (");
M5.Lcd.print(daysOfTheWeek[now.dayOfTheWeek()]);
M5.Lcd.print(") ");
M5.Lcd.print(now.hour(), DEC);
M5.Lcd.print(':');
M5.Lcd.print(now.minute(), DEC);
M5.Lcd.print(':');
M5.Lcd.print(now.second(), DEC);
M5.Lcd.println();

delay(3000);
</code></pre>
<p dir="auto">}</p>
<p dir="auto">My question are :</p>
<ul>
<li>what is wrong with my code ?</li>
<li>while scanning for I2C adress, I can find 4 different adresses. I know RTC is 0x57 because when disconnecting the DS21 this one disapear frome the scan. But is it possible tha the other devices scanned interfere with my RTC  ?</li>
<li>should I specify which adress of the I2C to read ? something like Wire.requestFrom(0x57, ...) ?</li>
</ul>
<p dir="auto">Thank you for your help, I am stuck here for 2 days...!</p>
<p dir="auto">Best wishes to everybody for the new year.</p>
<p dir="auto">Morgan</p>
]]></description><link>https://community.m5stack.com/topic/2745/ds3231-on-m5stack-need-your-help</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 00:09:14 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/2745.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 10 Jan 2021 11:04:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to DS3231 on M5Stack - Need your Help on Tue, 22 Mar 2022 16:11:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/morguane" aria-label="Profile: morguane">@<bdi>morguane</bdi></a> I just saw your topic (of almost a year ago). I guess you solved your problems with the external RTC by now. But anyway liked to inform you about the repo I published on GitHub, using a D3231 RTC with a M5Stack Core1 (BASIC). <a href="https://github.com/PaulskPt/M5Stack_DS3231_uRTC" target="_blank" rel="noopener noreferrer nofollow ugc">DS3231 on M5Stack_DS3231_uRTC</a>.<br />
Regards,</p>
]]></description><link>https://community.m5stack.com/post/16987</link><guid isPermaLink="true">https://community.m5stack.com/post/16987</guid><dc:creator><![CDATA[Paulskpt]]></dc:creator><pubDate>Tue, 22 Mar 2022 16:11:06 GMT</pubDate></item><item><title><![CDATA[Reply to DS3231 on M5Stack - Need your Help on Mon, 18 Jan 2021 12:20:56 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/morguane" aria-label="Profile: morguane">@<bdi>morguane</bdi></a></p>
<p dir="auto">glad to be of assistance and thank you for reporting back.</p>
<p dir="auto">Have fun!</p>
<p dir="auto">Cheers<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/11827</link><guid isPermaLink="true">https://community.m5stack.com/post/11827</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Mon, 18 Jan 2021 12:20:56 GMT</pubDate></item><item><title><![CDATA[Reply to DS3231 on M5Stack - Need your Help on Mon, 18 Jan 2021 12:05:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/felmue" aria-label="Profile: felmue">@<bdi>felmue</bdi></a></p>
<p dir="auto">OMG it works.<br />
Thank you sooo much !</p>
<p dir="auto">I put here some details if it can help someone else.</p>
<p dir="auto">First, here is the result of your double I2C scan :</p>
<p dir="auto"><img src="/assets/uploads/files/1610971149076-img_2712-resized.jpg" alt="0_1610971112713_IMG_2712.jpg" class=" img-fluid img-markdown" /></p>
<p dir="auto">We can clearly see that the first bus we have 10, 68 and 75 (as we spoke before), and then on the second one we have 68 (the RTC) and 57 (his memory).</p>
<p dir="auto">Then , I changed all the functions of my RTCLib library (Adafruit library for using RTC modules).<br />
And now my previous code is working fine :</p>
<pre><code>#include "RTClib.h"
#include &lt;M5Stack.h&gt;

RTC_DS3231 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup () {

Serial.begin(9600);
M5.begin(true, false, true, true);
M5.Power.begin();
Wire1.begin(16,17);

rtc.begin();
}

void loop () {
  M5.update();

  M5.Lcd.fillScreen(BLACK);
 
  //Getting the time
  DateTime now = rtc.now();

  M5.Lcd.setCursor(30,80);
  //Printing it on M5 Lcd
  M5.Lcd.print(now.year(), DEC);
  M5.Lcd.print('/');
  M5.Lcd.print(now.month(), DEC);
  M5.Lcd.print('/');
  M5.Lcd.print(now.day(), DEC);
  M5.Lcd.print(" (");
  M5.Lcd.print(daysOfTheWeek[now.dayOfTheWeek()]);
  M5.Lcd.print(") ");
  M5.Lcd.print(now.hour(), DEC);
  M5.Lcd.print(':');
  M5.Lcd.print(now.minute(), DEC);
  M5.Lcd.print(':');
  M5.Lcd.print(now.second(), DEC);
  M5.Lcd.println();
  
  delay(3000);
}
</code></pre>
<p dir="auto">Morgan</p>
]]></description><link>https://community.m5stack.com/post/11825</link><guid isPermaLink="true">https://community.m5stack.com/post/11825</guid><dc:creator><![CDATA[morguane]]></dc:creator><pubDate>Mon, 18 Jan 2021 12:05:37 GMT</pubDate></item><item><title><![CDATA[Reply to DS3231 on M5Stack - Need your Help on Mon, 18 Jan 2021 11:00:57 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/morguane" aria-label="Profile: morguane">@<bdi>morguane</bdi></a></p>
<p dir="auto">you are welcome. As I have mentioned before your <a href="https://www.gmelectronic.com/modul-rtc-ds323-i2c-and-32kb-flash" target="_blank" rel="noopener noreferrer nofollow ugc">RTC module</a> seems to contain a second IC (Memory chip: AT24C32  - storage capacity 32 KB) which uses I2C address 0x57. That is why you can see 0x57 with the module attached, but don't see 0x57 w/o the module attached.</p>
<p dir="auto">Re second I2C bus: there are at least two I2C buses available <code>Wire</code> and <code>Wire1</code>. If no arguments are given, default GPIOs are used, eg. GPIO21 and GPIO22 on the M5Stack Gray. But the GPIOs can be defined freely with arguments, e.g <code>Wire1.begin(16, 17)</code>.</p>
<p dir="auto">Here is an I2C scanner example which scans both I2C buses:</p>
<pre><code>#include &lt;M5Stack.h&gt;

#define USE_SECOND_I2C_BUS // GPIO16 and GPIO17

int textColor = YELLOW;

void setup()
{
  M5.begin(true, false, true, true);
  M5.Power.begin();

#ifdef USE_SECOND_I2C_BUS
  Wire1.begin(16, 17);
#endif // USE_SECOND_I2C_BUS

  M5.Lcd.begin();
  M5.Lcd.fillScreen(BLACK);
  M5.Lcd.setCursor(0, 0);
  M5.Lcd.setTextColor(YELLOW);
  M5.Lcd.setTextSize(2);
  M5.Lcd.fillScreen(BLACK);
  M5.Lcd.setCursor(0, 0);
  M5.Lcd.println("M5Stack I2C Tester");
  delay(1000);
  M5.Lcd.fillScreen(BLACK);
}

void loop()
{
  int address;
  int error;

  M5.Lcd.setCursor(0, 0);
  M5.Lcd.println("0: scanning Address [HEX]");
  for(address = 1; address &lt; 127; address++)
  {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
    if(error == 0)
    {
      M5.Lcd.print(address,HEX);
      M5.Lcd.print(" ");
    }
    else M5.Lcd.print(".");
    delay(10);
  }

#ifdef USE_SECOND_I2C_BUS
  M5.Lcd.println();
  M5.Lcd.println("1: scanning Address [HEX]");
  for(address = 1; address &lt; 127; address++)
  {
    Wire1.beginTransmission(address);
    error = Wire1.endTransmission();
    if(error == 0)
    {
      M5.Lcd.print(address,HEX);
      M5.Lcd.print(" ");
    }
    else M5.Lcd.print(".");
    delay(10);
  }
#endif // USE_SECOND_I2C_BUS

  if(textColor == YELLOW) textColor = GREEN;
  else textColor = YELLOW;
  M5.Lcd.setTextColor(textColor, BLACK);
}
</code></pre>
<p dir="auto">Whereever you want to use the second I2C bus (instead of the first one), replace <code>Wire</code> with <code>Wire1</code> in the appropriate locations. (This also applies to any libraries you are going to use which might have <code>Wire</code> hard coded - but you can modify that in your local copy of the library.)</p>
<p dir="auto">Cheers<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/11819</link><guid isPermaLink="true">https://community.m5stack.com/post/11819</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Mon, 18 Jan 2021 11:00:57 GMT</pubDate></item><item><title><![CDATA[Reply to DS3231 on M5Stack - Need your Help on Mon, 18 Jan 2021 09:47:27 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/felmue" aria-label="Profile: felmue">@<bdi>felmue</bdi></a></p>
<p dir="auto">First, thank you for taking of your time to help me.</p>
<p dir="auto">I have another external RTC (without battery) but I cannot make it work either. When I use the I2C scan, here is what I see :</p>
<p dir="auto"><img src="/assets/uploads/files/1610962972404-img_2711-resized.jpg" alt="0_1610962971341_IMG_2711.jpg" class=" img-fluid img-markdown" /></p>
<p dir="auto">So I am assuming that the address is 0x68. When I unplug it, here is whan I scan :</p>
<p dir="auto"><img src="/assets/uploads/files/1610963241070-img_2709-resized.jpg" alt="0_1610963224194_IMG_2709.jpg" class=" img-fluid img-markdown" /></p>
<p dir="auto">So I am assuming that I still see the 0x68 because it is the address of the MPU 6886, right ?</p>
<p dir="auto">When I am running the I2C scan with the first DS3231 RTC, here is what I can scan :</p>
<p dir="auto"><img src="/assets/uploads/files/1610962050192-img_2706-resized.jpg" alt="0_1610961965723_IMG_2706.jpg" class=" img-fluid img-markdown" /></p>
<p dir="auto">I have understood reading the datasheet of the M5 stack that :</p>
<p dir="auto">0x10 is for BMM150 sensor<br />
0x75 is for IP5306<br />
0x68 is for MPU6886 (as you said)</p>
<p dir="auto">If I disconnect the RTC from my M5stack, I do not find the 0x57 anymore of the scan. How can we explain it ? (I understand that even if the RTC is 0x68 we still see it because the MPU6886 as the same adress).</p>
<p dir="auto"><img src="/assets/uploads/files/1610962069833-img_2707-resized.jpg" alt="0_1610961974058_IMG_2707.jpg" class=" img-fluid img-markdown" /></p>
<p dir="auto">By the way, being quite new to the M5Stack world and arduino world in general, I do not have a clue on the way to setup a second I2C bus using other GPIOs. Could you help me on this way please ?</p>
<p dir="auto">Thank you very much for your help,</p>
<p dir="auto">Morgan</p>
]]></description><link>https://community.m5stack.com/post/11817</link><guid isPermaLink="true">https://community.m5stack.com/post/11817</guid><dc:creator><![CDATA[morguane]]></dc:creator><pubDate>Mon, 18 Jan 2021 09:47:27 GMT</pubDate></item><item><title><![CDATA[Reply to DS3231 on M5Stack - Need your Help on Thu, 14 Jan 2021 14:07:38 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/morguane" aria-label="Profile: morguane">@<bdi>morguane</bdi></a></p>
<p dir="auto">I2C address 0x57 is for the EEPROM IC on your board, the DS3231 uses 0x68. Unfortunately 0x68 already is used internally by MPU6886 of the M5Stack Gray.</p>
<p dir="auto">You'll need to setup a second I2C bus (using different GPIOs) or get a different RTC IC with a different I2C address not already used internally.</p>
<p dir="auto">Good luck!<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/11744</link><guid isPermaLink="true">https://community.m5stack.com/post/11744</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Thu, 14 Jan 2021 14:07:38 GMT</pubDate></item></channel></rss>