Skip to content

getBattery()

Arnd edited this page Dec 11, 2020 · 2 revisions

(MCP7940N only)
This function will return true if the battery backup flag is set in the MCP7940N. By default the battery backup mode is turned off on power-up, the state needs to be enabled using setBattery.


Example:

...
MCP7940_Class MCP7940; // Create an instance of the MCP7940
...
void setup() {
  Serial.begin(SERIAL_SPEED);
  while (!MCP7940.begin()) { // Initialize RTC communications
    Serial.println("Unable to find MCP7940. Checking again in 1 second.");
    delay(1000);
  } // of loop until device is located
 MCP7940.begin(); // start with compile date-time
 MCP7940.setBattery(true); // enable battery backup mode
 ...
 Serial.print("Battery Backup mode is ");
 if (MCP7940.getBattery()) 
   Serial.println("enabled.");
 else
   Serial.println("disabled.");
...
Clone this wiki locally