Show map location from GPS


#1

I am attempting to send lat/lng to Ubidots to display on a map. I’ve tried the sample code but it doesn’t work for me.
I’m running on an ESP8266 using C++
Ubidots is the Community Edition

float value1 = analogRead(A0);
client.add(“temperature”, value1);
char context[25];
sprintf(context, ““lat”:39.727482, “lng”:-105.077”);
//sprintf(context, “nonsense”);
client.add(“position”, 15, context);
client.sendAll(true);

If I use the info from the samples provided nothing is posted to my device/dashboard.
Neither the temperature nor the position show up and I don’t get the OK|OK on my serial monitor.
If I replace the lat long with nonsense, i.e. the line commented out above, then the temperature and the integer (15) are posted but their is no map image. I also see OK|OK on my serial monitor indicating a response from Ubidots.

Is there a purpose for the required integer, is is used for anything? If I post the context “nonsense”, the integer shows up on my Ubidot device variable.

Should this work or do I need to build an HTTP statement?

Thanks for your help!


#2

Greetings, you are not building properly your context, according to this example it should be as follows:

#include "UbidotsMicroESP8266.h"

#define TOKEN  "Your_token_here"  // Put here your Ubidots TOKEN
#define WIFISSID "Your_WiFi_SSID" // Put here your Wi-Fi SSID
#define PASSWORD "Your_WiFi_Password" // Put here your Wi-Fi password

Ubidots client(TOKEN);

void setup(){
    Serial.begin(115200);
    client.wifiConnection(WIFISSID, PASSWORD);
    //client.setDebug(true); // Uncomment this line to set DEBUG on
}

void loop(){
    float value = analogRead(0);
    char context[25];
    sprintf(context, "lat=1.2343$lng=132.1233"); //Sends latitude and longitude for watching position in a map

    client.add("humidity", value, context);
    client.sendAll(true); 
    delay(5000)
}

All the best


#3

And there I am, right on the map.
Thank you. Just didn’t have that syntax.
Max