 String generateRegister(String ip, String identifier){
     int index;
 
-  StaticJsonBuffer<200> jsonBuffer;
-  JsonObject& root = jsonBuffer.createObject();
-
-  JsonArray& sensors = root.createNestedArray("sensors");
-  for(index = 0; index < MAX_SENSOR_COUNT; index++){
-      sensors.add(sensorsList[index].identifier);
-  }
-
-  root["sensors"] = sensors;
-  root["ip"] = ip;
-
-  char buffer[256];
-  root.printTo(buffer);
-
-  return buffer;
+    StaticJsonBuffer<400> jsonBuffer;
+    JsonObject& root = jsonBuffer.createObject();
+
+    JsonArray& sensors = root.createNestedArray("sensors");
+    for(index = 0; index < MAX_SENSOR_COUNT; index++){
+        sensors.add(sensorsList[index].identifier);
+    }
+
+    root["sensors"] = sensors;
+    root["ip"] = ip;
+
+    char buffer[256];
+    root.printTo(buffer);
+
+    return buffer;
 }
 
 /*
  * Check if response is valid and no errors are returned (like device blocked)
  */
 boolean errorInResponse(String response){
-  StaticJsonBuffer<200> jsonBuffer;
+  StaticJsonBuffer<400> jsonBuffer;
   JsonObject& root = jsonBuffer.parseObject(response);
   if (!root.success()){
     return true;

 * @return body: the filled/generated json body
 */
String generateBody(float value){
  StaticJsonBuffer<200> jsonBuffer;
  JsonObject& root = jsonBuffer.createObject();

  root["value"] = value;

/*
 * Register device at server
 */
boolean registerDevice(String body){

    // char buffer[100];
    // sprintf(buffer, "http://192.168.42.1:3000/register", server);

    String response = httpRequestPost(server + "/register", body);

    Serial.println("Checking register response");
    if(response != HTTP_ERROR_RESPONSE && !errorInResponse(response)){
        Serial.println("Parsing response");

        // Set the databaseid's for the sensors
        StaticJsonBuffer<400> jsonBuffer;
        JsonObject& root = jsonBuffer.parseObject(response);

        Serial.println("Response size:");
        Serial.println(response.length());

        if(root.success()){
            Serial.println("It's not the json");
        } else{
            Serial.println("It might be the json");
        }
        if(root.success() && root.containsKey("found")){
            int index;

            // Serial.println("REGISTER:\n" + response);
            Serial.println("REGISTERED succesfully!");
            Serial.println(response);

            for(index = 0; index < MAX_SENSOR_COUNT; index++){
                // JsonArray& array = root['found'];
                sensorsList[index].databaseId = root["found"][index]["database_id"];
            }

            return true;
        }
    }
    Serial.println("Delay");
    delay(1000);
    Serial.println("Retrying register, recursively");
    return registerDevice(body);   //retry recursive
}

/*
