Boa noite caros colegas,
Aconteceu hoje comigo o que nunca tinha visto em minha vida de Arduíno, o meu módulo RTC DS3231, não consegue mais setar a data setDate(x, y, z), no entanto todas as outras funções de hora, dia da semana e temperatura, setam normalmente. Alguém do fórum poderia me ajudar?
Código:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DS3231.h>
int temperature; // declarada como INTEIRO porque o getTemp() da bilbioteca trata a temperatura como FLOAT.
int rele = 8;
// Modulo I2C display no endereco 0x3F
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
// Init the DS3231 using the hardware interface
DS3231 rtc(SDA, SCL);
void setup()
{
pinMode(rele, OUTPUT);
// Setup Serial connection
Serial.begin(115200);
// Uncomment the next line if you are using an Arduino Leonardo
//while (!Serial) {}
//inicialização do display lcd
lcd.begin(16, 2);
lcd.clear();
// Initialize the rtc object
rtc.begin();
// The following lines can be uncommented to set the date and time
rtc.setDOW(6);
rtc.setTime(20, 13, 0);
rtc.setDate(10, 29, 2016);
temperature = rtc.getTemp();
}
void loop() {
digitalWrite(rele, HIGH);
// Send Day-of-Week
lcd.setCursor(0, 0);
lcd.print(rtc.getDOWStr());
Serial.print(" ");
// Send date
lcd.setCursor(0, 1);
lcd.print(rtc.getDateStr());
Serial.print("-- ");
// Send time
lcd.setCursor(8, 0);
lcd.println(rtc.getTimeStr());
lcd.setCursor(12, 1); //Seta a temperatura na 2ª linha 12ª Coluna do LCD
//lcd.print("Tempo: ");
lcd.print(temperature);
lcd.write(223);//imprime o caracter (°)
lcd.print("C");
// Wait one second before repeating :)
delay (1000);
}
Tags:
Boa noite amigo DM, tente no formato abaixo...
rtc.setDate(29, 10, 2016); //dia mes e ano
Bons projetos!!!
Obrigado Romário,
Simples assim, puxa, não tinha verificado que a função era do tipo (dia, mes, ano). Peguei a biblioteca em inglês e geralmente eles usam o mês primeiro.
<>Abraço</>
Bem-vindo a
Laboratorio de Garagem (arduino, eletrônica, robotica, hacking)
© 2024 Criado por Marcelo Rodrigues. Ativado por