Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. morguane
    M
    • Continue chat with morguane
    • Start new chat with morguane
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups
    Save
    Saving

    morguane

    @morguane

    0
    Reputation
    4
    Posts
    544
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    morguane Follow

    Posts made by morguane

    • RE: DS3231 on M5Stack - Need your Help

      @felmue

      OMG it works.
      Thank you sooo much !

      I put here some details if it can help someone else.

      First, here is the result of your double I2C scan :

      0_1610971112713_IMG_2712.jpg

      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).

      Then , I changed all the functions of my RTCLib library (Adafruit library for using RTC modules).
      And now my previous code is working fine :

      #include "RTClib.h"
      #include <M5Stack.h>
      
      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);
      }
      

      Morgan

      posted in Arduino
      M
      morguane
    • RE: DS3231 on M5Stack - Need your Help

      @felmue

      First, thank you for taking of your time to help me.

      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 :

      0_1610962971341_IMG_2711.jpg

      So I am assuming that the address is 0x68. When I unplug it, here is whan I scan :

      0_1610963224194_IMG_2709.jpg

      So I am assuming that I still see the 0x68 because it is the address of the MPU 6886, right ?

      When I am running the I2C scan with the first DS3231 RTC, here is what I can scan :

      0_1610961965723_IMG_2706.jpg

      I have understood reading the datasheet of the M5 stack that :

      0x10 is for BMM150 sensor
      0x75 is for IP5306
      0x68 is for MPU6886 (as you said)

      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).

      0_1610961974058_IMG_2707.jpg

      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 ?

      Thank you very much for your help,

      Morgan

      posted in Arduino
      M
      morguane
    • DS3231 on M5Stack - Need your Help

      HI everyone,

      I am currently trying to use a DS3231 external RTC on my M5Stack core grey.

      I have tried many different libraries but problem remains the same :

      • I know the RTC is seen. I have run I2C scan and my DS3231 RTC has the 0x57 address.
      • I am able to set the current time into the RTC.
      • 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...

      For example :

      alt text

      Here, for this exemple, I am using the RTCLib library from Adafruit.

      Here is my code :


      #include "RTClib.h"
      #include <M5Stack.h>
      #include <Wire.h>

      RTC_DS3231 rtc;

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

      void setup () {

      Serial.begin(9600);
      M5.begin();
      Wire.begin();

      if (! rtc.begin()) {

      M5.Lcd.println("Couldn't find RTC");
      Serial.flush();
      abort();
      

      }

      //Adjust the time to the current one
      rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
      

      }

      void loop () {

      //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);
      

      }

      My question are :

      • what is wrong with my code ?
      • 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 ?
      • should I specify which adress of the I2C to read ? something like Wire.requestFrom(0x57, ...) ?

      Thank you for your help, I am stuck here for 2 days...!

      Best wishes to everybody for the new year.

      Morgan

      posted in Arduino
      M
      morguane