-
Notifications
You must be signed in to change notification settings - Fork 0
RTC
This library is used to communicate with the PCF2123 RTC. It can be used to set and retrieve the time. It can be included by adding the following include statement at the top of your Arduino sketch.
#include <PCF2123.h>
More features need to be added to this library in order to access the more advanced features of this RTC. Features like the Alarm function with interrupt output.
struct Time{
uint8_t Second;
uint8_t Minute;
uint8_t Hour;
uint8_t Day;
uint8_t Wday;
uint8_t Month;
uint8_t Year;
};
The time structure is used to set the time or is returned if the current time is requested.
PCF2123(uint8_t ss_);
This needs to be called first to create an instance of the RTC class.
- ss_ = Pin that the RTC, SPI slave select is connected to
void begin();
This needs to be called before any other functions. Its used to setup the create pins as inputs, outputs and to initialise the SPI used by the RTC chip.
void get_time(Time *t);
- t = A pointer to a Time struct where the current time will be stored
PCF2123 time(A5);
time.begin();
Time t;
time.get_time(&t);
The struct t now contains the current date time information.
Used to set the time stored on the RTC. A Time struct needs to be created and the time in it set to the correct value. This struct needs to then be passed to the function which will then set the time.
void set_time(Time new_time);
- new_time = A time struct containing the current time set by the user
There is an example with the library called "Set_time". This allows the user to send the time over serial to the node and it will set the time in the RTC. See the example for for details