Ubidots Community

[SOLVED] Can't send context (lat and lng) from nodemcu

I am doing a project in which I have connected a temperature,humidity,and MQ2 sensors.This is my code snippet:

But when I checked the variable description,the context field was empty. I don’t know what’s wrong with this code.I used the library “UbidotsMicroESP8266.h”.There is no GPS on my device.

My project presentation is on this week.I don’t know what to do. Can anyone help me with this please?

Hello @Susmitha, I tried to reproduce your issue but the example provided for context coordinates worked properly here, can you please set at UbidotsMicroESP8266.h file the debug flag (line 44) to true and post the console output? You should get something like this:


The string above should be correct according to the protocol specified here: http://help.ubidots.com/developers/send-data-to-ubidots-over-tcp-or-udp

Thanks for your reply. But I’m totally new at this. I could’nt find UbidotsMicroESP8266.h file in my system.I’m sure that I installed nodemcu-master zip file in my library.

Hello @Susmitha, if you are using windows you will find it at arduino/libraries at your user folder, if you are using Linux it should be at arduino/libraries at your home/ folder.

All the best

I’m sorry.But I couldn’t find the library in arduino/libraries .Do I need to install that again?
The list of available libraries are attached with this:

Hello, on your arduino IDE go to File–>Preferences and there you will get your arduino’s path (for my case at /home/jota/arduino):

OK.Got it. Where should I edit?

Hello @Susmitha,

I changed the code.But still no context is send to ubidots. I didnt actually understood what you meant by this :

Can you please provide the answer you print on your console as text in order to copy it properly?


Hello, I’ve done a test with this script and it seems to work properly

Ubidots client(TOKEN);

void setup(){
    client.wifiConnection(WIFISSID, PASSWORD);
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.add("temperature", value*10, context);

Can you give a try please?

I checked my libraries again.The UbidotsMicroESP8266.h i had installed was the older version.I have downloaded the newer one and changed the debug flag line to true.Now its working properly.
Thanks alot :slight_smile:

@Susmitha on your script there is an error, your variable ‘gas index’ is not valid, it has a blank space, replace it for ‘gas-index’.

@Susmitha, I’m glad to listen that it worked for you, keep in mind that the debug flag is only for ‘debug’ purposes, you can set it to false and it should work properly too.

Will there be any problem if it is set to true?

Hello, no, the only difference is that you won’t get message to your console prompt.


Thanks alot :slight_smile:

hello encountering the same problem with nodemcu been following but at @Susmitha screenshot are broken couldnt see them and also my major problem is that i followed the example on github (https://github.com/ubidots/ubidots-esp8266) to send context(latitude and longitude) to a variable on my dashboard the context field is empty after uploading and am unable to find the debug line(44) in my
UbidotsMicroESP8266.h file screenshot below

eventually found the debug line but its line 95 sorry for my ignorance its working