Real Time Clock

Description

This is a feature present on OI-Core/OI-CoreLite (x1).

The Real Time Clock (RTC) is power from an internal battery. The lifetime of the internal 3V battery is over 60 years. The time derivation is less than ±20 ppm @ 25°C.

Code examples

#include "OpenIndus.h"
#include "Arduino.h"
#include "RTClock.h"

DateTime currTime;

void rtc_alarm(void)
{
    static uint8_t color = LED_RED;

    DateTime currTime= RTC.now();
    DateTime awakeTime(currTime.year(), currTime.month(), currTime.day(), currTime.hour(), currTime.minute() + 1, currTime.second());    
    RTC.setRTCAlarm(awakeTime);
}

void setup(void)
{
    Serial.begin(115200);
    RTC.setTime(DateTime(__DATE__, __TIME__));

    currTime = RTC.now();
    DateTime awakeTime(currTime.year(), currTime.month(), currTime.day(), currTime.hour(), currTime.minute() + 1, currTime.second());

    RTC.attachRTCAlarm(rtc_alarm, NULL);
    RTC.enableRTCAlarm();
    RTC.setRTCAlarm(awakeTime);
}

void loop(void)
{
    currTime = RTC.now();
    Serial.printf("[%d-%d %d:%d:%d]\r\n", 
            currTime.day(), 
            currTime.month(), 
            currTime.hour(), 
            currTime.minute(), 
            currTime.second());
    
    delay(1000);
}

Software API

Warning

doxygenfunction: Cannot find function “OIRTC::time” in doxygen xml output for project “OI-Firmware” from directory: ../build/xml/

Warning

doxygenfunction: Cannot find function “OIRTC::now” in doxygen xml output for project “OI-Firmware” from directory: ../build/xml/

Warning

doxygenfunction: Cannot find function “OIRTC::setTime” in doxygen xml output for project “OI-Firmware” from directory: ../build/xml/

Warning

doxygenfunction: Cannot find function “OIRTC::setTime” in doxygen xml output for project “OI-Firmware” from directory: ../build/xml/

Warning

doxygenfunction: Cannot find function “OIRTC::enableRTCAlarm” in doxygen xml output for project “OI-Firmware” from directory: ../build/xml/

Warning

doxygenfunction: Cannot find function “OIRTC::disableRTCAlarm” in doxygen xml output for project “OI-Firmware” from directory: ../build/xml/

Warning

doxygenfunction: Cannot find function “OIRTC::setRTCAlarm” in doxygen xml output for project “OI-Firmware” from directory: ../build/xml/

Warning

doxygenfunction: Cannot find function “OIRTC::setRTCAlarm” in doxygen xml output for project “OI-Firmware” from directory: ../build/xml/

Warning

doxygenfunction: Cannot find function “OIRTC::attachRTCAlarm” in doxygen xml output for project “OI-Firmware” from directory: ../build/xml/

Warning

doxygenfunction: Cannot find function “OIRTC::detachRTCAlarm” in doxygen xml output for project “OI-Firmware” from directory: ../build/xml/