Skip to content

setBattery()

Arnd edited this page Dec 11, 2020 · 2 revisions

(MCP7940N only)
This function will turn on or off the battery backup mode of the MCP7940N. Power-on default is off. The state can be retrieved using getBattery.


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