Skip to content

Commit

Permalink
Added script to regularly send date and time to heater
Browse files Browse the repository at this point in the history
  • Loading branch information
fredlcore committed Nov 16, 2023
1 parent d8920a2 commit 8d6777d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions BSB_LAN/custom_functions/Send_NTP_time_to_heater/BSB_LAN_custom.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* This script sends the current time and date to the heater every 10 minutes.
* For this to make sense, you must have the USE_NTP definement enabled in BSB_LAN_config.h, in addition to the CUSTOM_COMMANDS definement.
* Works only on ESP32-based microcontrollers, not (yet) Arduino Due!
*/
#if defined(ESP32)
if (custom_timer > custom_timer_compare+600000) { // every 10 minutes
custom_timer_compare = millis();
char date_string[20];
struct tm now;
getLocalTime(&now,100);
sprintf_P(date_string,PSTR("%02d.%02d.%d_%02d:%02d:%02d"), now.tm_mday, now.tm_mon + 1, now.tm_year + 1900, now.tm_hour,now.tm_min,now.tm_sec);
if (now.tm_year > 100 && now.tm_hour > 4) { // only send time after 04:00 in case that day the heater changes time because of daylight saving
set(0,date_string,1);
}
}
#endif

0 comments on commit 8d6777d

Please sign in to comment.