Format of context/message from Particle library to get a map dashboard

I am trying to push gps data from Particle Electron.

I included the library and am able to push e.g. battery level and get a nice chart in ubidots.

However I struggle with GPS coordinates.

I didn’t find any documentation on ‘what should the format of GPS data be to be handled in Maps dashboard’, although from https://www.hackster.io/chipmc/out-for-a-walk-with-my-iot-thing-gps-location-logger-6279b7 and from example value http://ubidots.com/docs/api/#values I presume it get a feeling of that.

So i tried a few formats:

"lat" : 10.10,"lng":20.20
{"lat" : 10.10,"lng":20.20}
"context" : {"lat" : 10.10,"lng":20.20}
{"context" : {"lat" : 10.10,"lng":20.20}}

which I pass to a ubidots.add(“GPS”, 1, data);
as last parameter;

However in ubidots I can see that this variable ‘GPS’ gets value ‘10.10’ for initial reading and ‘1’ for all the others, while ‘context’ field is always ‘–’.

I am using UDP as a transport layer

ubidots.setDatasourceName("Electron");
ubidots.setMethod(TYPE_UDP);

Anyone managed to set this up? Thanks for any help!

Hello my firend, the new library of Ubidots for partcle supports it, you can send multiple context like this:

ubidots.add("Var_Name", value, "lat=-3.2$lng=-73"); 
ubidots.sendAll();

if you want to sned more context add it like: context=context_value$context_2=context_value_2$context_3=context_value_3…

Thanks @Metavix. I’m new to Ubidots. Thanks to you and others who have created such a great project. I am following after @kretes in trying to get my Particle Electron to log GPS lat/lon data to the Ubidots map widget. I read your explanation above:

ubidots.add(“Var_Name”, value, “lat=-3.2$lng=-73”);

I wondered if you could explain it in some more detail?
Do I need a sprintf function to create the string (like your “lat=-3.2$lng=-73” in the above)?
Will Ubidots understand the string as two “context” items associated with “Var_Name”?

Sorry for such basic questions.
and thanks again…

A quick post to say I managed to get the logging of Electron/GPS location data to Ubidots and display this as a tracking map on the Ubidots dashboard. :grinning:
I wrote this up and posted code here:

Sure i can explain that, well you can use an sprintf if you lik it. Because the functionce receive an string and it is the context. All context have the same format.

name_of_context=value_of_context

And if you want to add another context you just put an “$” before other context, like this:

name_of_context_one=value_of_context_one$name_of_context_two=value_of_context_two

By the way don’t forget remember that “add” function has 3 args:

first arg is the name of the variable and it is an string
Second Arg is the value of the variable and is a float
third arg is the context and is an String, this arg is optional if you don’t want to send a context then only pass two arg to add function

Hi @Metavix, thanks for the explanation (both here in this forum and at Particle). Yes, confirming I made this work and got a nice map of GPS data from my Electron.

I do have an observation (and feature request). It seems that when the map is created the value of the variable is not visible live at the latest GPS point and also none of the previous track points can be interrogated from the map (ie by cursor click) to reveal the value and/or GPS data. Is this a feature that Ubidots could consider adding to the map widget?

Thanks again.

Thank you I report it to the support area and it will be fixed as soon as possible