DS3231 RTC clock with arduino

Hi there,

i am having trouble with the ds3231 module and getting it to do anything at a specific time. I have this code:

#include <DS3231.h>

// Init the DS3231 using the hardware interface
DS3231  rtc(SDA, SCL);
int led = 13;
void setup()
  // Setup Serial connection
  pinMode(led, OUTPUT); 
  // Uncomment the next line if you are using an Arduino Leonardo
  //while (!Serial) {}
  digitalWrite(led, LOW); 
  // Initialize the rtc object
  // The following lines can be uncommented to set the date and time
  //rtc.setDOW(SUNDAY);     // Set Day-of-Week to SUNDAY
  //rtc.setTime(12, 56, 10);     // Set the time to 12:00:00 (24hr format)
  //rtc.setDate(25, 3, 2016);   // Set the date to January 1st, 2014

void loop()
  // Send Day-of-Week
  //Serial.print(" ");
  // Send date
  //Serial.print(" -- ");

  // Send time

  if(rtc.getTimeStr() == "13:32:00"){
    Serial.println("IT WORKED!!!");
  // Wait one second before repeating :)
  delay (1000);

that is trying to get it to do something at a specified time, however it never works… With this fixed i can get an alarm working and maybe even change it to 12 hr time- as of now it is in 24 hr time for some reason. It seems to work when i try it for the date, ex: if(rtc.getDateStr() == “Thursday”){ Serial.println “THURS”}; so is there any way to get this figured out, and also change it form 24 to 12 hr?

I am stumped, thanks for your time.

You can try something like:

if( rtc.hour() == 13 && rtc.minute() == 32 && rtc.second() == 0 ) {
   Serial.println("IT WORKED!!!");

You can also see what you get when you do something like:

Serial.print( rtc.day() ) ;

I can confirm this sketch works with DUE and a DS3231 module. I could not get the libraries work. The code in the link seems so simple it hardly needs a (nonworking) library.

it hardly needs a (nonworking) library.

Indeed. I reckon this is all most people need