Set up scheduled program cycles #24

Merged
W1CDN merged 41 commits from program-cycle into main 2023-09-15 16:51:45 -05:00
Showing only changes of commit 57a1c1af80 - Show all commits

View File

@ -33,6 +33,7 @@
AsyncWebServer server(80);
RTC_DS3231 rtc; // set up RTC
const int alarmPin = 4; // pin to monitor for RTC alarms
// Read from config.h
const char* ssid = WIFI_SSID;
@ -403,6 +404,14 @@ bool start_program(){
void setup() {
Serial.begin(115200);
pinMode(alarmPin, INPUT_PULLUP); // Set alarm pin as pullup
// Disable and clear both alarms
// rtc.disableAlarm(1);
// rtc.disableAlarm(2);
// rtc.clearAlarm(1);
// rtc.clearAlarm(2);
// rtc.writeSqwPinMode(DS3231_OFF); // Place SQW pin into alarm interrupt mode
// https://github.com/JChristensen/DS3232RTC/blob/master/examples/TimeRTC/TimeRTC.ino
// rtc.begin();
// setSyncProvider(rtc.get); // the function to get the time from the RTC
@ -427,6 +436,11 @@ void setup() {
//rtc.adjust(DateTime(2023, 9, 2, 17, 32, 0));
}
// Are there any RTC alarms set?
DateTime alarm_two = rtc.getAlarm2(); // Get the current time
char buff[] = "Alarm 2 set for at hh:mm:ss DDD, DD MMM YYYY";
Serial.println(alarm_two.toString(buff));
// Timer example, blink main LED
pinMode(LED_BUILTIN, OUTPUT); // set LED pin to OUTPUT
// call the toggle_led function every 10000 millis (10 second)
@ -645,15 +659,16 @@ void loop() {
// We don't want old alarms, though.
//& (rtc.getAlarm2() >= rtc.now())
// if ((rtc.alarmFired(2) == 1) ){
if (digitalRead(alarmPin) == LOW) {
// // Print current time and date
// DateTime now = rtc.now(); // Get the current time
// char buff[] = "Alarm triggered at hh:mm:ss DDD, DD MMM YYYY";
// Serial.println(now.toString(buff));
// Print current time and date
DateTime now = rtc.now(); // Get the current time
char buff[] = "Alarm triggered at hh:mm:ss DDD, DD MMM YYYY";
Serial.println(now.toString(buff));
// // Disable and clear alarm
// rtc.clearAlarm(2);
// }
// Disable and clear alarm
rtc.clearAlarm(2);
}
// DateTime now = rtc.now();
// Serial.print(now.year(), DEC);