 }
 
 void doWork() {
+  if (connectToInternet()) {
+    String subject =  "Device ";
+    subject =  subject + ESP.getChipId();
+    subject =  subject + " is DO WORK!!!. Count: ";
+    subject =  subject + rtcStore[2];
+    String message =  "Battery Power: ";
+    message = message + ESP.getVcc();
+    sendEmail(subject, message);
+    disconnectInternet();
+  }
+
   digitalWrite(14, HIGH);
   delay(1000);
   yield();

    system_rtc_mem_write(RTC_BASE, rtcStore, 3);
  }

  if (rtcStore[1] == STATE_COLDSTART) {
    if (connectToInternet()) {
      getTime();
      nextSleep = doCalculation();
      
      String subject =  "Device ";
      subject =  subject + ESP.getChipId();
      subject =  subject + " has Powered up.";
      String message =  "Battery Power: ";
      message = message + ESP.getVcc();
      message = message + " Power Up Time: " + hh + ":" + mm + ":" + ss;

      if (ESP.getVcc() < 2650) {
        subject = "WARNING: Battery LOW - " + subject;
      }

      Serial.println(subject);
      Serial.println(message);
      
      sendEmail(subject, message);
      disconnectInternet();
      rtcStore[1] = STATE_COLDSTART;
      system_rtc_mem_write(RTC_BASE, rtcStore, 3);
    }
  }

  if (rtcStore[1] == STATE_SLEEP_WAKE) {
    if (rtcStore[2] < 73) {
      doWork();
    }
    if (rtcStore[1] >= 84) {
      rtcStore[1] = STATE_HOUSKEEPING;
      rtcStore[2] = 0;
      system_rtc_mem_write(RTC_BASE, rtcStore, 3);
      nextSleep = ONE_HOU_TIME - TEN_MIN_TIME;
      ESP.deepSleep(nextSleep, WAKE_RFCAL);
    }
  }

  if (rtcStore[1] == STATE_HOUSKEEPING) {
    if (connectToInternet()) {
      getTime();
      nextSleep = doCalculation();
      String subject =  "Device ";
      subject =  subject + ESP.getChipId();
      subject =  subject + " Syncronizing with time.";
      String message =  "Battery Power: ";
      message = message + ESP.getVcc();
      message = message + " Power Up Time: " + hh + ":" + mm + ":" + ss;

      if (ESP.getVcc() < 2650) {
        subject = "WARNING: Battery LOW - " + subject;
      }
      Serial.println(subject);
      Serial.println(message);
      sendEmail(subject, message);
      disconnectInternet();
      rtcStore[1] = STATE_SLEEP_WAKE;
      system_rtc_mem_write(RTC_BASE, rtcStore, 3);
    }
  }

  rtcStore[2]++;


  Serial.print("Next sleep : ");
  Serial.println(nextSleep);
  //  ESP.deepSleep(nextSleep, WAKE_RF_DISABLED);
  ESP.deepSleep(nextSleep, WAKE_RFCAL);

  yield();

