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


#1

Hi,
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?


#2

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:

UbidotsESP8266/1.1|POST|aauuer2OooFkwv7ncXXfCVqcshfwRQW|a020a6133e21:ESP8266=>humidity:1.00000$lat=1.2343$lng=132.1233|end

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


#3

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.


#4

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


#5

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:


#6

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):


#7

OK.Got it. Where should I edit?


#8

Hello @Susmitha,


#9

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


#10

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

Thanks


#11

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

Ubidots client(TOKEN);

void setup(){
    Serial.begin(115200);
    delay(10);
    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);
    client.sendAll(true); 
    delay(5000);
}

Can you give a try please?


#12

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:


#13

@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’.


#14

@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.


#15

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


#16

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

Regards


#17

Thanks alot :slight_smile:


#18

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


#19


#20

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