[SOLVED] Cant display latitude and longitude coordinate to ubidots

Hello,
I encounter problem when try to send lat and lng to ubidots. Im using arduino uno and gps module neo 6m. Based on my reading, we need to use context to send the value. I try to implement context but it does not work. Do anyone know the solution? Below is the part of of code that im using. Thank you in advance.

gps_latitude = gps.location.lat();
gps_longitude = gps.location.lng();

dtostrf(sensor1, 4, 2, str_sensor1);
dtostrf(gps_latitude, 4, 2, str_lat);
dtostrf(gps_longitude, 4, 2, str_lng);

/* Building the logger command */
sprintf(second_command, "init#");
sprintf(second_command, "%s%s/%s|%s|%s|", second_command, USER_AGENT, VERSION, METHOD, TOKEN);
sprintf(second_command, "%s%s:%s=>", second_command, DEVICE_NAME, DEVICE_LABEL); 
sprintf(context, "lat=%.2f$lng=%.2f", str_lat ,str_lng);
sprintf(second_command, "%s%s:%s%s", second_command, VARIABLE_LABEL_2, str_lat, str_lng, context);
sprintf(second_command, "%s|end#final", second_command);  
esp.print(second_command); 


  while (esp.available() > 0) 
  {
    telemetry_unit[i++] = (char)esp.read();
    /* Change the status of the flag; allows the next command to be built */
  }
  
    Serial.write(telemetry_unit);
    i=0;
    delay(5000);

}

Hi use this format: “position”: {“value”:1, “context”:{“lat”:25.7742700, “lng”: -80.1936600}}"

Dear @paulo,

Taking a look of the payload built by you in the code provided, I note that the structure is not the right one. If you desire to send a variable position with their respective coordinates the command ought to be:

USER_AGENT/VERSION|POST|TOKEN|DEVICE_LABEL:DEVICE_NAME=>position:1.0$lat={Lat_value}$lng={Lng_value}|end

For more information you can see this article.

All the best,
Maria C.

Dear @mariahernandez,

Is the structure of my code is incorrect too? because i used the same structure to send my sensor values.

The structure below is the right one when you are posting values using the Ubidots REST API:

The structure below is the right one when you are posting values using TCP/UDP:

As I noted in your code, the following line is the one which is assigning the coordinates wrong.

Please compare it with the one that I provided you in order to build the right payload.

All the best,
Maria C.

Dear @mariahernandez,

im not familiar with the format. im newbies in creating this project. can you explain how the structure works. i have tried to compare and run the code. but it shows “lng?” in ubidots. what is it means by?? i think i still sending the wrong structure. thank you in advance and your help is much appreciated

Dear user,

To get familiar with the structures provided in the message above, I highly recommend you review:

In each page you will find all the information required to learn how the payload should be structured. If you have any additional question let us know.

As personal recommendation, you should print the payload to be sent in order to be able to compare it with the ones described in the guides, in this order you will be able to identify where can be the issue.

All the best,
Maria C.