Ubidots Community

Ubidots not receiving values

Greetings,

I have followed the tutorial to connect my arduino mega with an esp8266 device and send values to ubidots. Two months ago everything was working properly. I paused my project and resumed it this week and now I can’t receive the values on ubidots. I have checked the connection of my esp8266 which is working fine.

This is my code:
I have omitted my token and username purposely for this post.

/****************************************
 * Define Constants
 ****************************************/
namespace {
  bool flow_control = true; // control the flow of the requests
  const char * USER_AGENT = ""; // Assgin the user agent
  const char * VERSION =  "1.0"; // Assign the version
  const char * METHOD = "POST"; // Set the method
  const char * TOKEN = ""; // Assign your Ubidots TOKEN
  const char * DEVICE_LABEL = "ESP"; // Assign the device label
  const char * VARIABLE_LABEL = "gas"; // Assign the variable label
}

char telemetry_unit[100]; // response of the telemetry unit

/* Space to store values to send */
char str_sensor1[10];
//char str_sensor2[10];

/****************************************
 * Main Functions
 ****************************************/
void setup() {
  Serial.begin(115200);
  Serial1.begin(115200);
}

void loop() {
  char* command = (char *) malloc(sizeof(char) * 128);
  /* Wait for the server response to read the values and built the command */
  /* While the flag is true it will take the sensors readings, build the command,
     and post the command to Ubidots */
  if (flow_control) {
    /* Analog reading */
    float sensor1 = analogRead(A0);
    //float sensor2 = analogRead(A1);

    /* 4 is mininum width, 2 is precision; float value is copied onto str_sensor*/
    dtostrf(sensor1, 4, 2, str_sensor1);
    //dtostrf(sensor2, 4, 2, str_sensor2);

    /* Building the logger command */
    sprintf(command, "init#");
    sprintf(command, "%s%s/%s|%s|%s|", command, USER_AGENT, VERSION, METHOD, TOKEN);
    sprintf(command, "%s%s=>", command, DEVICE_LABEL);
    sprintf(command, "%s%s:%s", command, VARIABLE_LABEL, str_sensor1);
    sprintf(command, "%s|end#final", command);

    /* Prints the command sent */
    Serial.println(command);// uncomment this line to print the command

    /* Sends the command to the telemetry unit */
    Serial1.print(command);
    /* free memory*/
    free(command);
    /* Change the status of the flag to false. Once the data is sent, the status
       of the flag will change to true again */
    flow_control = false;
  }

  /* Reading the telemetry unit */
  int i = 0;
  while (Serial1.available() > 0) {
    telemetry_unit[i++] = (char)Serial1.read();
    /* Change the status of the flag; allows the next command to be built */
    flow_control = true;
  }

  if (flow_control) {
    /* Print the server response -> OK */
    Serial.write(telemetry_unit);
    /* free memory */
    memset(telemetry_unit, 0, i);
  }

  delay(1000);
}

This is what the serial monitor shows:
(omitted the username and token in here)
init#username/1.0|POkk|ESP=>gas:72.00|end#final
…Oo6ybK58HVVkk|ESP=>gas:72.00|end#final
…init#username/1.0|POST|token|ESP=>gas:72.00|end#final
…init#username1.0|POST|token|ESP=>gas:73.00|end#final