Ubidots Community

I can't receive data

Hi, I am using the example code from the ubidots library for the arduino IDE, I use an esp8266 board, I want to take the value of a variable from a device and it gives me an error when receiving the variable. Do you need more information, the sketch or photos of the ubidot variables? If you need them, let me know. I’m kind of new to this, thanks for your help

Please attach the section the code to be able to test, the post and get method of the documentation works for me.

Hello, thanks for answering. I attach the code. I don’t know what you mean by the post.
The library downloads it from the ubidots docs.
greetings and thanks.

       indent preformatted text by 4 spaces
// This example retrieves last value of a variable from the Ubidots API

// using HTTP protocol.

/****************************************

  • Include Libraries
    ****************************************/

#include “Ubidots.h”

/****************************************

  • Define Constants
    ****************************************/

const char* UBIDOTS_TOKEN = “”; // Put here your Ubidots TOKEN
const char* WIFI_SSID = “n”; // Put here your Wi-Fi SSID
const char* WIFI_PASS = “”; // Put here your Wi-Fi password
const char* DEVICE_LABEL_TO_RETRIEVE_VALUES_FROM = “dispo1”; // Replace with your device label
const char* VARIABLE_LABEL_TO_RETRIEVE_VALUES_FROM = “light”; // Replace with your variable label

Ubidots ubidots(UBIDOTS_TOKEN, UBI_HTTP);

/****************************************

  • Auxiliar Functions
    ****************************************/

// Put here your auxiliar functions

/****************************************

  • Main Functions
    ****************************************/

void setup() {
Serial.begin(115200);
ubidots.wifiConnect(WIFI_SSID, WIFI_PASS);
// ubidots.setDebug(true); //Uncomment this line for printing debug messages
}

void loop() {
/* Obtain last value from a variable as float using HTTP */
float value = ubidots.get(DEVICE_LABEL_TO_RETRIEVE_VALUES_FROM, VARIABLE_LABEL_TO_RETRIEVE_VALUES_FROM);

// Evaluates the results obtained
if (value != ERROR_VALUE) {
Serial.print(“Value:”);
Serial.println(value);
}
delay(5000);
}