MCP7940
v1.2.0
Arduino Library for the MCP7940N and MCP7940M Real-time clocks
|
#include <MCP7940.h>
Enumerations | |
enum | alarmTypes { matchSeconds, matchMinutes, matchHours, matchDayOfWeek, matchDayOfMonth, Unused1, Unused2, matchAll, Unknown } |
Functions | |
void | setup () |
void | loop () |
Variables | |
const uint32_t | SERIAL_SPEED {115200} |
Set the baud rate for Serial I/O. | |
const uint8_t | LED_PIN {13} |
Arduino built-in LED pin number. | |
const uint8_t | SPRINTF_BUFFER_SIZE {32} |
Buffer size for sprintf() | |
const uint8_t | ALARM1_INTERVAL {15} |
Interval seconds for alarm. | |
MCP7940_Class | MCP7940 |
Create instance of the MCP7940M. | |
char | inputBuffer [SPRINTF_BUFFER_SIZE] |
Buffer for sprintf() / sscanf() | |
Example program for using the MCP7940 library which demonstrate the use of alarms on the MCP7940N/M real time clock chip. The library as well as the most current version of this program is available at GitHub using the address https://github.com/Zanduino/MCP7940 and a more detailed description of this program can be found at https://github.com/Zanduino/MCP7940/wiki/SetAlarms.ino
The MCP7940 library uses the standard SPI Wire library for communications with the RTC chip and has also used the class definitions of the standard RTClib library from Adafruit/Jeelabs.
The data sheet for the MCP7940M is located at http://ww1.microchip.com/downloads/en/DeviceDoc/20002292B.pdf. The MCP7940N has extra functionality revolving around battery backup but this library's functionality covers that chip as well.
The MCP7940 has two alarms that can be set. Either can be set to trigger once at a specific point in time or can be set to be a recurring alarm. When the alarm goes off it sets an alarm bit which can be read using the the library routine getAlarmState() or via an input pin if the MCP7940's multifunction pin is attached to it.
This example program sets alarm 0 to trigger every time the RTC's seconds reads "0". Alarm 1 is set to trigger at a time "ALARM1_INTERVAL" seconds from the last time it was triggered.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Written by Arnd Arnd@ at Zand uino. Comhttps://www.github.com/SV-Zanshin
Version | Date | Developer | Comments |
---|---|---|---|
1.0.3 | 2020-11-16 | SV-Zanshin | Issue #50 - Reformatted with clang-format |
1.0.2 | 2019-01-19 | SV-Zanshin | Changed comments to doxygen formatting |
1.0.1 | 2018-07-07 | SV-Zanshin | Changed code for compatability reasons to new library |
1.0.0 | 2017-07-29 | SV-Zanshin | Initial coding |
enum alarmTypes |
///< Enumeration of MCP7940 alarm types
void loop | ( | ) |
Arduino method called after setup() which loops forever
void setup | ( | ) |
Arduino method called once upon start or restart.