Skip to content

begin()

Arnd edited this page Dec 11, 2020 · 5 revisions

begin([I2CSpeed]);

This function must be called to initialize the MCP7940. The optional boolean return value is set to false if the MCP7940 is not detected otherwise it returns true.

The optional unsigned 16 bit integer "I2CSpeed" parameter allows the I2C bus to be initialized to either the default I2C_STANDARD_MODE of 100KHz or to I2C_FAST_MODE of 100KHz.

If the multifunction pin is to be used it should have a pull-up resistor and it will be set to a high state until an alarm is raised, when it is pulled low. By default the MCP7940 does not active the oscillator on power up, meaning that the time function will be turned off until explicitly turned on by using either deviceStart() or setting the time using the adjust().


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
...
} // of setup
Clone this wiki locally