I am in the process of turning a bunch of my spare parts into outdoor path lights and pretty yard art. WLED looks like a great way to do this…but I would like to add the deep sleep that ESP32 can do into the mix. I have found very little in the way of “how-tos” on the matter.
I grabbed a copy of the code and think I have narrowed down what will work. Adding a couple defines and a couple lines of code in the Sunset/Sunrise settings. Please correct me if I am wrong.
BUT I am getting several compile issues concerning Alexa stuff…which I am not even technically planning on using. It concerns a #EndIF without a #IF.
I would love to have this turn off at sunrise for eight or 9 hours…then kick back on at dusk.
Here is the additions for the NTP.cpp tab.
#define uS_TO_S_FACTOR 1000000 /* Conversion factor for micro seconds to seconds */
#define TIME_TO_SLEEP 28800 /* Time ESP32 will go to sleep (in seconds) */
and the code change in the sunrise/set area.
if (timerMacro[8] != 0
&& hour(tmp) == hour(localTime)
&& minute(tmp) == minute(localTime)
&& (timerWeekday[8] & 0x01) //timer is enabled
&& ((timerWeekday[8] >> weekdayMondayFirst()) & 0x01)) //timer should activate at current day of week
{
unloadPlaylist();
applyPreset(timerMacro[8]);
DEBUG_PRINTF("Sunrise macro %d triggered.",timerMacro[8]);
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR)
esp_deep_sleep_start();
}
}
// sunset macro
if (sunset) {
time_t tmp = sunset + timerMinutes[9]*60; // NOTE: may not be ok
DEBUG_PRINTF("Trigger time: %02d:%02d\n", hour(tmp), minute(tmp));
if (timerMacro[9] != 0
&& hour(tmp) == hour(localTime)
&& minute(tmp) == minute(localTime)
&& (timerWeekday[9] & 0x01) //timer is enabled
&& ((timerWeekday[9] >> weekdayMondayFirst()) & 0x01)) //timer should activate at current day of week
{
unloadPlaylist();
applyPreset(timerMacro[9]);
DEBUG_PRINTF("Sunset macro %d triggered.",timerMacro[9]);
}
If there is an alternate way to deep_sleep the esp32 that I am missing, or a download out there already it would be much appreciated. I have spent several hours getting this far, which feels like I have not moved.
The specific error is during verify and says there is I can’t have a EndIF without an IF. I located the file ESPAlexa.h which was the one mentioned and indeed there is a EndIF on one of the last lines that does not seem to correlate to a IF. I removed it and am testing now.
Thanks.