[SOLVED] getValueWithDatasource for Particle doesn't work

Hello!

I found this online http://ubidots.com/docs/devices/particlePhoton.html#send-one-value-to-ubidots

// This example is to get the last value of variable from the Ubidots API

#include "Ubidots.h"

#define TOKEN "Your_Token_Here"  // Put here your Ubidots TOKEN
#define DATA_SOURCE_NAME "Your_Data_Source_Name_Here"  // Put here your Ubidots data source name 

Ubidots ubidots(TOKEN);

void setup() {
    Serial.begin(115200);
}
void loop() {    
    float value;
    value = ubidots.getValueWithDatasource(DATA_SOURCE_NAME, "Name_Of_Your_Variable");
    Serial.println(value);
    delay(60000);  // Delay of one minute
}

The “value = ubidots.getValueWithDatasource(DATA_SOURCE_NAME, "Name_Of_Your_Variable");” can’t get value from ubitdots, does anyone know what’s the solution to solve this problem??

What version of ubidots library are you using?

Hi! I’m using the library on build.particle.io. Do you know what’s the solution for my problem?

Hi Tony I guess what @Metavix meant was to suggest using the latest version, you can check this by clicking in the info icon:

Then making sure you click/select the latest one:

@aguspg Hi! I’m sure I’m using the latest version particle ubidots library 2.0.5

Here is the screenshot for my code and putty program output is “0.0” for what I get from my “ubidots.getValueWithDatasource(DATA_SOURCE_NAME, "Name_Of_Your_Variable");”

On my ubidot datashouce, I have a value of 5.0 on “onoff” variable, but on the terminal it only display 0.0

not sure, what is the problem?

Please help me out, how to get data value from ubidots.com on particle photon.

Thanks

Fixed, thank you for your patient :smiley:

@Metavix what you mean by fixed? I still didn’t fixed this problem, and still waiting for someone to give me a solution.

Download the lastest version 2.0.6 i fixed that problem in our library, sorry for didn’t explain that :stuck_out_tongue: but you can try with the new library

@Metavix on https://build.particle.io it only has 2.0.5 version of library available, How can I make it to 2.0.6?

Pres the “i” icon, and select 2.0.6 it is behind github icon

@Metavix After change library to 2.0.6, I’m trying to compile the code, But I’m getting the error below:

Also, look like the new library doesn’t support particle photon:

Any idea on how to fix these?

oh give me 1 second i know the problem

Ok upgrade to 2.1.0

@Metavix Ok, Now I can complied the code with version of 2.1.0, but the output value on the putty is still 0.0 below is my screen shot:

Any ways to fix this issues?

mmm so strange give me a minute please

It was my fault, now is corret, try it please again (upgrade to 2.1.1)

@Metavix the problem is still exit even I update library to 2.1.2

Could you do me a favor by give me a sample code that you have?

Thanks

Please be carefull this is your data source tag, are you sure that SWITCH is your data source tag, and the name of variable that you will get is this one


In the second green square you can change variable tag name, with this one you can get the value of your variable

1 Like

Thank you so much @Metavix for your help. I changed the “source name” to “source tag” it work perfectly. I’m getting value 5.0

But, why does it print out "

Client connected
Particle/1.1|LV|4cOonYcioTF2JgwHldR75bfOGYgh9X|36003d000247343339373536:onoff|end
Receiving TCP transaction of 4 bytes.
OK|5End of TCP transaction.End o

"

Can You please fix this in your newest version of library?

Thank you!

The entire data is a debug method to search if any user got a problem, it is better than show nothing. But if you prefer i could change that to show only the float response. Im happy to solve your problem, thank you so much for your patient

1 Like