Ubidots Community

Im trying to sent location data to ubidots but i cant

hi im trying to sent location data to ubidots but i cant here is my payload example…help me…
{
“state”: {
“reported”: {
“time”: 54294,
“sensor_a0”: 0,
“Temp”: 1.635498,
“position”: {
“lat”: 40.78286,
“lng”: -73.96535
}
}
}
}

Good day @Radps

As Ubidots only receives numerical data as the main value of the variable, is necessary to make minor changes to the payload to be an Ubidots compatible JSON. This are the changes needed to be done:

{"sensor_a0":0,"temp":{value:1.635498, timestamp:5429400000000,},"position":{ value: 1, context:{"lat":40.78286,"lng":-73.9653}}}

Please note that the variable time needs to be call timestamp and send in milliseconds, also to store the latitude and longitude coordinates of your device you need to use the dot’s context, as all Ubidots maps use the lat and lng keys from a dot’s context to extract the coordinates, instead of sending separately both latitude and longitude in two different variables.

Please let us know if you have additional questions.

All the best,
-Isabel

Thanks @isalogi can you help me create the json format…mine is below one…

   StaticJsonDocument<500> doc;
  JsonObject root = doc.to<JsonObject>();
  JsonObject state = root["state"].to<JsonObject>();
  JsonObject reported = state["reported"].to<JsonObject>();
  reported["time"] = millis();
  reported["sensor_a0"] = analogRead(35);
  reported["Temperature"] =  tempC ;
  JsonObject Temp = reported["Temp"].to<JsonObject>();
  Temp["value"] =  tempC ;
  JsonObject context = Temp["context"].to<JsonObject>();
  context["lat"] = 40.782864;
  context["lng"] = -73.965355;

Thanks in advance…

i tried by manually publishing the JSON by using AWS to UBIDOTS …
when i tried this JSON Structure i got the device response.

  { 
	"state": {
			"reported": {
				"temperature": 23, 
				"humidity":55
			} 
	}
 }

After this i tried with these example…my bad there is no response. no last activity…but position variable created but no last activity…

{ 
  "state": { 
    "reported": { 
      "position": {
          "value" : 1, 
          "timestamp": 1514808000000, 
          "context":{
             "lat":-6.2,
             "lng":75.4, 
              "name" : "John"
          }
          }
         }
    } 
  } 

After that i mixed up above two examples… this time i got temp and humidity data values but no last activity in position variable …could u help me please…

{ 
  "state": { 
    "reported": { 
       "temperature": 23, 
      "humidity":55,
      "position": {
          "value" : 1, 
          "timestamp": 1514808000000, 
          "context":{
             "lat":-75.2,
             "lng":5.4, 
              "name" : "John"
          }
          }
         }
    } 
  }

Good day @Radps,

Thank you for your response.

The JSON format seems to be in order, to further investigate, can you please send us a screenshot of the AWS IoT core rule action and also an image of the decoder you have?

With that information, we can investigate the reason why the position variable is not creating as expected.

I will be attentive to your response.

Best,
-Isabel

hi @isalogi here is my rule action for AWS IOT CORE and my user id is Kyoot-Create and maill id is kyoot@leadup.in.