Can an esp32 with RTC be woken up based on a conditional time statement (see Example below), or does it require a timer function? If a timer function is required, how could I have it wake up at the top of the hour every 60 mn?
Even if I need a timer, I would like to use the conditional statement. I am still learning cpp, so I need a bit of help correcting the syntax.
Example
int minutes = 30 ;
String time_1 ; << How to set time and convert for compare?
void loop(){
getTIme();
if time_1 < time_current < time_1 + minutes ; << ?
wake ; << ?
while time_current < time_1 + minutes ;
do something ;
else ;
sleep; << ? }
void getTime(){
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
// retrieve data from DS3231
readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
&year);
}
void readDS3231time(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year){
Wire.beginTransmission(DS3231_I2C_ADDRESS);
// Wire.write(0xE); // set DS3231 register pointer to 00h
Wire.write(0);
Wire.endTransmission();
Wire.requestFrom(DS3231_I2C_ADDRESS, 7);
// request seven bytes of data from DS3231 starting from register 00h
*second = bcdToDec(Wire.read() & 0x7f);
*minute = bcdToDec(Wire.read());
*hour = bcdToDec(Wire.read() & 0x3f);
*dayOfWeek = bcdToDec(Wire.read());
*dayOfMonth = bcdToDec(Wire.read());
*month = bcdToDec(Wire.read());
*year = bcdToDec(Wire.read());
timeDate = *dayOfMonth;
timeDay = *dayOfWeek;
timeMonth = *month;
timeYear = *year;
timeHour = *hour;
timeMinutes = *minute;
timeSeconds = *second;
}