 
 void publishReadings()
 {
+    int res = 1;
+    int tries = 5;
+
     if ((millis() - lastT) > (CHTUPDPERIOD * 1000)) {
+        display_string_5x7(6,1,"Publishing");
         lastT = millis();
-        readAM2321();
-        char szEventInfo[64];
-        sprintf(szEventInfo, "field1=%.1f&field2=%.2f", temp, humi);
-        sendToThingSpeak(WRITEKEY,String(szEventInfo));
+        if (readOK == false) {
+            res = readAM2321();
+            while (res && (tries-- > 0)) {
+              delay(1000);
+              res = readAM2321();
+            }
+        }
+        if (!res || readOK) {
+            readOK = true;
+            char szEventInfo[64];
+            sprintf(szEventInfo, "field1=%.1f&field2=%.2f", temp, humi);
+            sendToThingSpeak(WRITEKEY,String(szEventInfo));
+        }
         Spark.sleep(CHTUPDPERIOD - 30);
     }
 }
 
 void backLightOn()
 {
+    display_string_5x7(6,1,"BL ON ");
+    detachInterrupt(BackLightTrigger);
     RGB.control(false);
     trigger = millis() + BACKLDUR;
     transfer_command_lcd(0xaf);//--turn on oled panel 


void loop()
{
    if (refresh) {
      Time.timeStr().substring(4,19).toCharArray(dispCS, 16);
      display_string_5x7(1,1,"     ");
      display_string_5x7(1,20,dispCS);

      readAM2321();
      status.toCharArray(dispCS, 20);
      display_string_5x7(6,1,dispCS);
    
//      sprintf(dispCS, "T: %0.1f, H: %0.1f    ", temp, humi);
//      display_string_5x7(3,1,dispCS);
      sprintf(dispCS, "%0.1fC, %0.1f%%    ", temp, humi);
      display_string_8x16(3,1,dispCS);
    }

    publishReadings();

      status = "Unknown            ";
      break;
  }
  if (!result) {
    temp = DHT22.getCelsius();
    humi = DHT22.getHumidity();
  }
  return result;
}


