Eu inicialmente, tentei com a programação do site, mas dá-me um erro, então recorri aos exemplos da biblioteca DS3231, e apartir daí adaptei para mostrar no ecrã. Aparece valores só que não conta as horas e os minutos, apenas é esse o meu problema.
Se fiz um teste, e com esse teste consigo mostrar as horas a contar.
#include <DS3231.h>
#include <MCUFRIEND_kbv.h>
// Init the DS3231 using the hardware interface
DS3231 rtc(SDA, SCL);
MCUFRIEND_kbv tft;
// Init a Time-data structure
Time t;
#define PRETO 0x0000
void setup()
{
// Setup Serial connection
Serial.begin(115200);
// Uncomment the next line if you are using an Arduino Leonardo
//while (!Serial) {}
uint16_t ID = tft.readID();//leitura do controlador do display
tft.begin(ID);
// Initialize the rtc object
rtc.begin();
// The following lines can be uncommented to set the date and time
rtc.setDOW(WEDNESDAY); // Set Day-of-Week to SUNDAY
rtc.setTime(10, 19, 5); // Set the time to 12:00:00 (24hr format)
rtc.setDate(9, 5, 2018); // Set the date to January 1st, 2014
}
void loop()
{
// Get data from the DS3231
t = rtc.getTime();
tft.fillScreen(PRETO);
tft.setRotation(1);
tft.setTextSize(2);
// Send date over serial connection
tft.setCursor(120,70);
tft.print(t.date, DEC);
//tft.print(". day of ");
tft.print(rtc.getMonthStr());
//tft.print(" in the year ");
tft.print(t.year, DEC);
tft.println(".");
tft.setCursor(120,160);
delay(10000);
// Send Day-of-Week and time
//tft.print("It is the ");
tft.print(t.dow, DEC);
tft.print('.');
//tft.print(". day of the week (counting monday as the 1th), and it has passed ");
tft.print(t.hour, DEC);
tft.print('.');
//tft.print(" hour(s), ");
tft.print(t.min, DEC);
tft.print('.');
//tft.print(" minute(s) and ");
tft.print(t.sec, DEC);
//tft.println(" second(s) since midnight.");
// Send a divider for readability
//Serial.println(" - - - - - - - - - - - - - - - - - - - - -");
// Wait one second before repeating :)
delay (1000);
}
Envio a restante resposta asseguir.