   ArduinoOTA.begin();
 }
 
+void ledBlink() {
+  digitalWrite(LED_PIN, ! digitalRead(LED_PIN));
+}
+


    if (millis() - lastHeartBeat > heartBeatInterval) {
      Serial.println("loop running");
      lastHeartBeat = millis();
    }
}

#include <WiFiUdp.h>
#include <ArduinoOTA.h> 

#include <Ticker.h>

#define LED_PIN 2 // gpio2 for ESP-12, gpio1 for ESP-01, gpio12 for Sonoff

const String THIS_NAME = String("ESP-") + ESP.getChipId();

int heartBeatInterval = 15000; // 15 seconds
Ticker ledBlinker;


void setup(void) {
    Serial.begin(115200); Serial.println();
    Serial.print(THIS_NAME); Serial.print(__DATE__);Serial.println(__TIME__);

    pinMode(LED_PIN, OUTPUT);
    ledBlinker.attach(0.2, ledBlink); // start with fast blink to show Wifi connecting

    initWifi();
    Serial.print("WiFi connected to "); Serial.print(WiFi.SSID()); Serial.print(", IP address: "); Serial.println(WiFi.localIP());

    ledBlinker.detach();
    digitalWrite(LED_PIN, LOW);

    initOTA();
}
