Making a Clock With M5stick C Using Arduino IDE | RTC Real Time Clock With M5stack M5stick-C

Hi guys in this instructables we will learn how to make a clock with m5stick-C development board of m5stack using Arduino IDE.
So m5stick will display date, time & week of the month on the display.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Things You Need

For this instructables you will need following things :

m5stick-c development board
Type C cable

Step 2: Setting Up the Arduino IDE

Make sure you installed ESP32 boards in your Arduino IDE and if it is not the case then make please follow the following instructables to do that :

ESP32 BOARDS INSTALL : https://www.instructables.com/id/Getting-Started-...

Step 3: Code

Copy the following code below and upload it to your m5stick-C development board :

include "M5StickC.h"

RTC_TimeTypeDef RTC_TimeStruct;
RTC_DateTypeDef RTC_DateStruct;

void setup() {
// put your setup code here, to run once:
M5.begin();
M5.Lcd.setRotation(3);
M5.Lcd.fillScreen(BLACK);

M5.Lcd.setTextSize(1);
M5.Lcd.setCursor(40, 0, 2);
M5.Lcd.println("RTC TEST");
RTC_TimeTypeDef TimeStruct;
TimeStruct.Hours = 18;
TimeStruct.Minutes = 56;
TimeStruct.Seconds = 10;
M5.Rtc.SetTime(&TimeStruct);
RTC_DateTypeDef DateStruct;
DateStruct.WeekDay = 3;
DateStruct.Month = 3;
DateStruct.Date = 22;
DateStruct.Year = 2019;
M5.Rtc.SetData(&DateStruct);
}

void loop() {
// put your main code here, to run repeatedly:
M5.Rtc.GetTime(&RTC_TimeStruct);
M5.Rtc.GetData(&RTC_DateStruct);
M5.Lcd.setCursor(0, 15);
M5.Lcd.printf("Data: %04d-%02d-%02d\n",RTC_DateStruct.Year, RTC_DateStruct.Month,RTC_DateStruct.Date);
M5.Lcd.printf("Week: %d\n",RTC_DateStruct.WeekDay);
M5.Lcd.printf("Time: %02d : %02d : %02d\n",RTC_TimeStruct.Hours, RTC_TimeStruct.Minutes, RTC_TimeStruct.Seconds);
delay(500);
}

Step 4: Getting Date, Time & No. of Week on Display

After uploading the code you can see the display and the date time & week of the month will be displayed on display as it is showing in my case.
If you want to see the time running properly on this clock please refer the video provided and let me know in comment section if you wanna share anything about it.

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    Discussions