-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added script to regularly send date and time to heater
- Loading branch information
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
BSB_LAN/custom_functions/Send_NTP_time_to_heater/BSB_LAN_custom.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |