I'm using an Arduino RTC module, which gives me date and time. I would like to know how I can send a message every 5 minutes. Below is the algorithm I'm using, the variable that prints the time is the variable ( rtc.getTimeStr()
). Note: The "delay" instruction should not be used. If it was set in the algorithm " rtc.setTime(23, 00, 0);
" a message should be sent at 23:05:00
#include <DS1307.h>
DS1307 rtc(D1, D2);
void setup()
{
//Aciona o relogio
rtc.halt(false);
//As linhas abaixo setam a data e hora do modulo
//e podem ser comentada apos a primeira utilizacao
rtc.setDOW(Segunda); //Define o dia da semana
rtc.setTime(23, 00, 0); //Define o horario
rtc.setDate(20, 07, 2017); //Define o dia, mes e ano
//Definicoes do pino SQW/Out
rtc.setSQWRate(SQW_RATE_1);
rtc.enableSQW(true);
Serial.begin(2400);
}
void loop()
{
// Mostra as informações no Serial Monitor
Serial.print("Hora : ");
Serial.print(rtc.getTimeStr());
Serial.print(" ");
Serial.print("Data : ");
Serial.print(rtc.getDateStr(FORMAT_SHORT));
Serial.print(" ");
Serial.println(rtc.getDOWStr(FORMAT_SHORT));
//Aguarda 1 segundo e repete o processo
delay (1000);
}