You are currently viewing Basics of Class and Different Functions in RTC – Micropython | Embedded c
Basics of Class and Different Functions in RTC - Micropython | Embedded c

Basics of Class and Different Functions in RTC – Micropython | Embedded c

Spread the love

In this article we will see Different methods and class for RTC (Real Time Clock). we know that in current scenario developer mostly prefer micropython programming concept to built or innovation of any idea. so in this section we refer some basics concept of RTC.

Basic Class of RTC

def settime():
    t = time()
    import machine
    import utime
    rtc_SACH = machine.RTC()
    rtc_SACH.datetime((2021, 9, 11, 2, 11, 32, 36, 0))
    print(rtc.datetime())

Explanation: This code basically show the syntax for RTC. Remember that we need to import machine and utime module, without this module it’s not possible to access RTC Functionality.

Different kinds of Methods for RTC

  1. RTC.init(datetime/dataformat)
  2. RTC.datetime()
  3. RTC.now()
  4. RTC.deinit()
  5. RTC.alarm()
  6. RTC.alarm_left()
  7. RTC.cancel(alarm_id=0)
Basics of Class and Different Functions in RTC - Micropython | Embedded c
Basics of Class and Different Functions in RTC – Micropython | Embedded c

  • RTC.init(datetime/dataformat)
  • This method help you to initialise the RTC.
    Format of datetime:

    (year, month, day[, hour[, minute[, second]]]])

  • RTC.datetime()
  • To set or get the date and time of the RTC we use this method.

  • RTC.now()
  • To get current or real time data we use this function

  • RTC.alarm()
  • If we want to provide alarm functionality then we prefer this function.

    Summary:

    In this article we saw Basic class and functions in RTC so about this section you have any query then free to ask me

    sachin Pagar

    I am Mr. Sachin pagar Embedded system engineer, the founder of Pythonslearning, a Passionate Educational Blogger and Author, who love to share the informative content on educational resources.

    Leave a Reply