2024-12-2200 RCT

This commit is contained in:
hans-jurgen 2024-12-22 01:17:47 +01:00
parent 6491bd17b7
commit 41a8516d10
2 changed files with 24 additions and 0 deletions

View File

@ -17,6 +17,7 @@ lib_deps =
;adafruit/Adafruit BME280 Library @ 2.2.4 ;adafruit/Adafruit BME280 Library @ 2.2.4
adafruit/Adafruit BMP280 Library @ 2.6.8 adafruit/Adafruit BMP280 Library @ 2.6.8
adafruit/Adafruit Unified Sensor @ 1.1.14 adafruit/Adafruit Unified Sensor @ 1.1.14
adafruit/RTClib @ 2.1.4
SD SD
FS FS
SPI SPI

View File

@ -53,6 +53,9 @@ SPIClass mySpi = SPIClass(VSPI);
#include <mcp9808.h> #include <mcp9808.h>
#include <mess_BMP280.h> #include <mess_BMP280.h>
#include <Preferences.h> #include <Preferences.h>
#include "RTClib.h"
RTC_DS3231 rtc;
Preferences preferences; Preferences preferences;
@ -283,6 +286,24 @@ void setup() {
ESP.restart(); ESP.restart();
} }
} }
if (!rtc.begin()) {
tft.fillScreen(TFT_RED);
Serial.println("Couldn't find RTC");
tft.setTextColor(TFT_BLACK, TFT_WHITE);
tft.drawCentreString(" Couldn't find RTC ", 160, 110, 2);
//Serial.flush();
while(1);
}
//Serial.println("Setting the time...");
// When time needs to be set on a new device, or after a power loss, the
// following line sets the RTC to the date & time this sketch was compiled
//rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
// Print local IP address and start web server // Print local IP address and start web server
tft.fillScreen(TFT_BLACK); tft.fillScreen(TFT_BLACK);
Serial.println(""); Serial.println("");
@ -343,6 +364,8 @@ void setup() {
ESP.restart(); ESP.restart();
} }
lastNTPtime = time(&now); lastNTPtime = time(&now);
getNTPtime(10);
//rtc.adjust(DateTime(timeinfo.tm_year, timeinfo.tm_mon, timeinfo.tm_mday, timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec));
preferences.begin("Interval", false); preferences.begin("Interval", false);
interval = preferences.getUInt("Interval", SAVE_INTERVAL);; interval = preferences.getUInt("Interval", SAVE_INTERVAL);;