-->
Page 1 of 3

ESP8266 ESP-12E/Arduino needs a 20hr Delay

PostPosted: Wed Jun 07, 2017 8:09 am
by johnnyfrx
ESP8266_LDR_IFTTT_SmartThings_BlueTooth_WIFI_Toggle_Share.ino
Good Day,
I am in need of a delay replacement that will pause the entire loop for upward of 20hrs.
Traditional delay works fine for a 1 hour delay. Anything past that and code locks up.
See attached sketch. My troublesome delay is at line 125.
Scenario - LDR sensor trips at designated low light threshold. Once tripped WiFi turns on, sends POST to IFTTT, WiFi turns off, Delay begins. (Delay is needed so the LDR doesn't continue to sense low-light overnight.)
Please take a look and let me know what you think.
Thanx,
JohnnyFRX

Re: ESP8266 ESP-12E/Arduino needs a 20hr Delay

PostPosted: Wed Jun 07, 2017 8:51 am
by atexit8
Unless my math is wrong, you should be able to use unsigned long integer with millis() to get you 20 hours.

Re: ESP8266 ESP-12E/Arduino needs a 20hr Delay

PostPosted: Wed Jun 07, 2017 12:24 pm
by johnnyfrx
I tried something like this with no luck.

const unsigned long seconds = 1000L;
const unsigned long minutes = 60000L;
const unsigned long hours = 3600000L;
const unsigned long myDelay = 32400000L;
const unsigned long myTestdelay = hours * 2;
const unsigned long mySecondsdelay = seconds * 10;

Re: ESP8266 ESP-12E/Arduino needs a 20hr Delay

PostPosted: Wed Jun 07, 2017 1:09 pm
by martinayotte
But you don't seems to call either delay() or millis() functions.
Simply defining a constant doesn't produce a delay by itself ...