Hello,
I got this RTC module called DS3231 and I don't know why is not keeping the time.
After I unplug and plug the board again, is counting time up from the moment I uploaded the code.
I tried with another module (because I bought a pack of 3), I tried with a rechargable battery LIR2032, and it's the same. The module is connected to pin A4 and A5 (i2c on Arduino Nano) and powered on the 3.3v pin.
What can I do?
This is my code:
#include <Wire.h>
#include "RTClib.h"
RTC_DS3231 rtc;
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup () {
Serial.begin(9600);
lcd.init();
rtc.begin();
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
void loop () {
DateTime now = rtc.now();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print(now.hour());
lcd.print(":");
lcd.print(now.minute());
lcd.print(":");
lcd.print(now.second());
}