Thanks. Deleted the unnecessary code. Removed delay (10000) and substituted:
unsigned long interval=10000; // the time we need to wait
unsigned long previousMillis=0; // millis() returns an unsigned long.
unsigned long currentMillis = millis();
if((unsigned long)(currentMillis - previousMillis)>= interval)
{
previousMillis = millis(); // save the “current” time
// The closing brace is at the end of all the code
Seems to work. The millis() and simple timing loop took a few iterations.
Do you know of a good starting point to use OTA to update an ESP-8266?