I have made a sketch to experiment with DS 3231 RTC modules and want to have the “Month” in the conditional
argument of an IF function.
I can make it work with “day, hour and minute” but when I enter " month" and error message " Not a class of time from the RTC. or something to that regard.
Even though I can display the month on the LCD.
Suggestions on how to use this , would be appreciated
// Sketch to give an Output to control SSR shown here as ledPin for Output
// To be changed to Output for SSR
#include <DS3231.h> A
#include <LiquidCrystal.h>
DS3231 rtc(SDA, SCL);
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
Time t;
const int OnDay =1;
const int OnMonth =8;
const int OffDay =3;
const int OffMonth =8;
const int OnHour = 0; //SET TIME TO TURN ON RELAY (24 HOUR FORMAT)
const int OnMin = 0;
const int OffHour = 0; //SET TIME TO TURN OFF RELAY
const int OffMin = 1;
const int Led = 10; // To be Changed for Output to SSR
const int ledPin = LED_BUILTIN;
void setup() {
rtc.begin();
lcd.begin(16, 2);
rtc.setDOW(MONDAY); // Set Day-of-Week to (*)
rtc.setTime(23, 59, 50); // Set the time to 12:00:00 (24hr format)
rtc.setDate(31, 7, 2019); // Day, Month, Year
pinMode(ledPin, OUTPUT); // Output
pinMode(10,OUTPUT);
digitalWrite(ledPin, LOW); // Standby status
}
void loop() {
lcd.setCursor(0, 0);
lcd.print(“Time/Date/Output”);
lcd.setCursor(0, 1);
lcd.print("Time: ");
lcd.print(rtc.getTimeStr());
delay(750);
lcd.setCursor(0, 1);
lcd.print("Date: ");
lcd.print(rtc.getDateStr());
delay(750);
lcd.setCursor(0, 1);
lcd.print("Day: “);
lcd.print(rtc.getDOWStr());
lcd.print(” ");
delay(750);
lcd.setCursor(0, 1);
lcd.print("Month: “);
lcd.print(rtc.getMonthStr());
lcd.print(” ");
delay(750);
t = rtc.getTime();
if ( t.date == OnDay && t.hour == OnHour && t.min == OnMin) { // Condition to turn on Output
digitalWrite(ledPin, HIGH);
digitalWrite(10, HIGH); // Red LED to show output active
lcd.setCursor(0, 1);
lcd.print("SSR ON “);
lcd.print(” ");
delay(1000);
}
else {
digitalWrite(ledPin, LOW);
digitalWrite(10, LOW);
lcd.setCursor(0, 1);
lcd.print("SSR OFF “);
lcd.print(” ");
delay(1000);
}