From b3e4ec771b519a012da601803a6497d6e438a66a Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Sun, 4 Feb 2018 17:48:44 +0100 Subject: [PATCH] update time code --- src/main.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b29caaf..39fbb97 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,7 +29,7 @@ U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ 16, /* clock=*/ 15, /* data=*/ 4); -char timeStr[64]; +char timeStr[20]; char weatherStr[32]; RTC_DATA_ATTR static int boot_count = 0; @@ -66,6 +66,10 @@ void setup() { tzset(); localtime_r(&now, &timeinfo); + if (timeinfo.tm_year < (2016 - 1900)) { + // time not set + } + //Initialize Basecamp iot.begin(); @@ -237,8 +241,7 @@ void loop() tzset(); localtime_r(&now, &timeinfo); -strftime(timeStr, sizeof(timeStr), "%c", &timeinfo); -Serial.println(timeStr); +strftime(timeStr, sizeof(timeStr), "%H:%M:%S", &timeinfo); sprintf(weatherStr, "%.1f°C %.1f%% %.0fhPa", bme280.readTemperature(), bme280.readHumidity(), bme280.readPressure()); }