 void setup() {
 
   startTime = system_get_time();
+
   nextSleep = TEN_MIN_TIME;
+  pinMode(14, OUTPUT);
+  digitalWrite(14, LOW);
 
   WiFi.forceSleepBegin();
   yield();

    rtcStore[1] = STATE_COLDSTART;
    rtcStore[2] = 0;
    system_rtc_mem_write(RTC_BASE, rtcStore, 3);
  } else {
    if (rtcStore[1] == STATE_SLEEP_WAKE) {
      rtcStore[2] += 1;
      //      if (rtcStore[2] > 4) {
      //        nextSleep = SLEEP_TIME;
      //      }
      if (rtcStore[2] > 4) {
        rtcStore[1] = STATE_CONNECT_WIFI;
        rtcStore[2] = 0;
      }
    }
  }


  if (connectToInternet()) {
    getTime();
    if (rtcStore[1] == STATE_COLDSTART) {
      String timeString = "Time: ";
      timeString = timeString + hh + ":" + mm + ":" + ss;
      sendEmail("Device has powered up.", timeString);
    }
    delay(1000);
    disconnectInternet();
  }

}


#define RTC_BASE 64
byte rtcStore[3];
uint32_t nextSleep, startTime;
#define TEN_MIN_TIME 10*60*1000000    // 10 min
#define ONE_HOU_TIME 60*60*1000000   //  1 hour

// Time related Valriables
unsigned int localPort = 2390;      // local port to listen for UDP packets
