Browse Source

update time code

main
Hendrik Langer 7 years ago
parent
commit
b3e4ec771b
  1. 9
      src/main.cpp

9
src/main.cpp

@ -29,7 +29,7 @@
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ 16, /* clock=*/ 15, /* data=*/ 4); 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]; char weatherStr[32];
RTC_DATA_ATTR static int boot_count = 0; RTC_DATA_ATTR static int boot_count = 0;
@ -66,6 +66,10 @@ void setup() {
tzset(); tzset();
localtime_r(&now, &timeinfo); localtime_r(&now, &timeinfo);
if (timeinfo.tm_year < (2016 - 1900)) {
// time not set
}
//Initialize Basecamp //Initialize Basecamp
iot.begin(); iot.begin();
@ -237,8 +241,7 @@ void loop()
tzset(); tzset();
localtime_r(&now, &timeinfo); localtime_r(&now, &timeinfo);
strftime(timeStr, sizeof(timeStr), "%c", &timeinfo); strftime(timeStr, sizeof(timeStr), "%H:%M:%S", &timeinfo);
Serial.println(timeStr);
sprintf(weatherStr, "%.1f°C %.1f%% %.0fhPa", bme280.readTemperature(), bme280.readHumidity(), bme280.readPressure()); sprintf(weatherStr, "%.1f°C %.1f%% %.0fhPa", bme280.readTemperature(), bme280.readHumidity(), bme280.readPressure());
} }

Loading…
Cancel
Save