How to enable the SQW output of the DS3231 on Arduino

Hi, someone could tell me how to enable the RTC square wave output (SWQ), I have tried to do it using these commands (commented) but I got an error when compiling them

#include <RTClib.h>
#include <Wire.h>

RTC_DS3231 rtc;
char t[32];

void setup() {
  Serial.begin(115200);
  Wire.begin();
  rtc.begin();
  //rtc.writeSqwPinMode (DS3231_SquareWave1Hz);          // ERROR SQW
  //rtc.sqw(DS3231_SquareWave1Hz);                       // ERROR SQW
  rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); 
}

void loop(){
  DateTime now = rtc.now();
  sprintf(t, "%02d:%02d:%02d %02d/%02d/%02d",  now.hour(), now.minute(), now.second(), now.day(), now.month(), now.year());   
  Serial.print(F("Date/Time: "));
  Serial.println(t);
  delay(1000);
}
rtc.writeSqwPinMode(DS3231_SquareWave1Hz);

did it for me.

It's always useful to post the error message(s) that you get.

In my Arduino UNO, I have no compilation error. Which board are you using?

I'm use a Arduino Pico

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.