This is a familiar experience with IDE 2.3.6 and the inexpensive NANO boards.
The older 1.8.19 compiler works fine for me and the NANO boards; however, ...
What am I doing wrong with the 2.3.6 compiler?
This is a simple code that works with 1.8.19 but not 2.3.6. NANO board photo attached.
Your comments are welcomed.
#include <Wire.h>#include "RTClib.h"RTC_DS1307 rtc;DateTime myDT;char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};byte lastReadSecond = 0;
void setup (){Serial.begin(115200);Wire.begin();
Wire.beginTransmission(0x68);byte busStatus = Wire.endTransmission();if (busStatus != 0){Serial.println("RTC is not present.");while (true);}Serial.println("RTC is present.");
rtc.begin();rtc.adjust(DateTime(F(DATE), F(TIME)));//taking current time from PC// rtc.adjust(DateTime(2021, 12, 31, 01, 59, 57));//set date-time manualy:yr,mo,dy,hr,mn,sec}
void loop (){myDT = rtc.now();if (lastReadSecond != myDT.second())//wait 1-sec as long as they are equal = 1s has not gones{showTimeDate();//1-sec has e;apsed; show time and date}}
void showTimeDate(){//update to the new secondmyDT = rtc.now();lastReadSecond = myDT.second();//------------------------------Serial.print(myDT.year(), DEC);Serial.print('/');//-----------------------------Serial.print(myDT.month(), DEC);Serial.print('/');Serial.print(myDT.day(), DEC);Serial.print(" (");Serial.print(daysOfTheWeek[myDT.dayOfTheWeek()]);Serial.print(") ");//-----------------------------byte myHour = myDT.hour();// myHour = myHour - 12;if (myHour < 10){Serial.print('0'); //show leading zero}Serial.print(myHour, DEC);Serial.print(':');//-----------------------------byte myMin = myDT.minute();if (myMin < 10){Serial.print('0'); //show leading zero}Serial.print(myMin, DEC);Serial.print(':');//--------------------------byte mySec = myDT.second();if (mySec < 10){Serial.print('0'); //show leading zero}Serial.print(mySec, DEC);//----------------------------Serial.println();}