Example Code for Arduino-32K Square Wave Output

Run this routine to control pin 32K to output square wave.

Hardware Preparation

Software Preparation

Wiring Diagram

DFR0998 Wiring diagram

Sensor Side Pin Name MCU Side Pin Name
Fermion: SD3031 RTC Module VCC UNO R3 3.3V
Fermion: SD3031 RTC Module GND UNO R3 GND
Fermion: SD3031 RTC Module SDA UNO R3 SDA
Fermion: SD3031 RTC Module SCL UNO R3 SCL

Sample Code

/*!
 * @file control32k.ino
 * @brief Run this routine to control pin 32K to output square wave
 * @copyright    Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
 * @license      The MIT License (MIT)
 * @author       [TangJie]([email protected])
 * @version      V1.0.0
 * @date         2022-07-27
 * @url         https://github.com/DFRobot/DFRobot_SD3031
 */
#include "DFRobot_SD3031.h"

DFRobot_SD3031 rtc;
void setup()
{
    uint8_t data= 0;
    Serial.begin(115200);
    /*Wait for the chip to be initialized completely, and then exit*/
    while(rtc.begin() != 0){
        Serial.println("Failed to init chip, please check if the chip connection is fine. ");
        delay(1000);
    }

    rtc.enable32k();
    delay(1000);
    //rtc.disable32k();
}

void loop()
{
    delay(1000);
}

Result

Using an oscilloscope to test the 32K pin of the module, the waveform can be observed.

Was this article helpful?

TOP