   {
     /* no data. Do nothing */
   }
-
-  /* if REQUEST_INTERVAL milliseconds have passed since your last connection,
-     then connect again and send data */
-  if (millis() - lastReceivedTime > REQUEST_INTERVAL) {
-    /* send a get request */
-    get_request();
-  }
-  else if (millis() - lastSentTime > REQUEST_INTERVAL) {
-    send_dweet();
+  if (thing_name != "")
+  {
+    /* if REQUEST_INTERVAL milliseconds have passed since your last connection,
+       then connect again and send data */
+    if (millis() - lastReceivedTime > REQUEST_INTERVAL) {
+      /* send a get request */
+      get_request();
+    }
+    else if (millis() - lastSentTime > REQUEST_INTERVAL) {
+      send_dweet();
+    }
+    else {
+      /* do nothing and wait */
+    }
   }
   else {
-    /* do nothing and wait */
+    /* thing_name not set - wait for server response */
   }  
 }
 

  if (client.connect(TARGET_SERVER, HTTP_PORT)) {
    /* connection request succeed */
    Serial.println("connected!");
  }
  else {
    /* connection request failed */

  lastReceivedTime = millis();
}

void requestThingName() {
  client.print("GET /dweet");
  client.println(" HTTP/1.1");
  client.println("Host: thingspace.io");
  client.println("Connection: Keep-Alive");
  client.println();
}


/* function to read eventual received data */
boolean read_received_data() {
