Skip to content

SimpleBatteryBackup.ino

Arnd edited this page Dec 11, 2020 · 3 revisions

Sample Arduino sketch to demonstrate setting and using the two alarms on the MCP7940. For a detailed breadboard setup description see the SetAndCalibrate.ino page.

Program Overview

This sketch will only work correctly when using a MCP7940N. This example assumes that the Arduino and the MCP7940N are on the same power supply and that a separate battery-backup supply is going to the vBat and negative pins. When power fails to the Arduino and it reboots, the state of the MCP7940N is checked and if it detects a power failure it displays the relevant information and continues. Otherwise, if no power failure is detected, the program sets the MC7940N time to the compile date/time and continues.

Clone this wiki locally