I am tasked to control a servo-motor via the Ubidots switch. However, I have no programming background and I need a guide to starting this. I’m currently using a Arduino Uno with an Ethernet Shield. I’ve followed the guide on connecting the Arduino Uno over to Ubidots Education however I’m been getting error about HTTP/1.1 404 Not Found. The code I’m using is directly the sample from UbidotsGetValue, changing my token,device label and variable label accordingly. As for the Device Label, am I suppose to use the API label or the ID provided below? Thank you for your help!
Greetings, a 404 error code means that you are trying to POST/GET data to a wrong endpoint. Can you share the entire code that you are using?
All the best
/********************************
* Libraries included
*******************************/
#include <Ethernet.h>
#include <SPI.h>
#include <UbidotsEthernet.h>
/********************************
* Constants and objects
*******************************/
/* Assigns the Ubidots parameters */
char const * TOKEN = "Assign_your_Ubidots_TOKEN_here"; // Assign your Ubidots TOKEN
char const * DEVICE_LABEL = "Assign_device_label_here"; // Assign the unique device label
char const * VARIABLE_LABEL = "Assign_variable_label_here"; // Assign the unique variable label to get the last value
/* Enter a MAC address for your controller below */
/* Newer Ethernet shields have a MAC address printed on a sticker on the shield */
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
/* initialize the instance */
Ubidots client(TOKEN);
/********************************
* Main Functions
*******************************/
void setup() {
Serial.begin(9600);
//client.setDebug(true);// uncomment this line to visualize the debug message
/* start the Ethernet connection */
Serial.print(F("Starting ethernet..."));
if (!Ethernet.begin(mac)) {
Serial.println(F("failed"));
} else {
Serial.println(Ethernet.localIP());
}
/* Give the Ethernet shield a second to initialize */
delay(2000);
Serial.println(F("Ready"));
}
void loop() {
Ethernet.maintain();
/* Getting the last value from a variable */
float value = client.getValue(DEVICE_LABEL, VARIABLE_LABEL);
/* Print the value obtained */
Serial.print("the value received is: ");
Serial.println(value);
delay(5000);
}
Basically the same sample code I got from Ubidots and I’ve changed the values accordingly to what I written on Ubidots itself.
Do both device label and variable label exist at Ubidots? Please set them without any blank space
So to clarify these are my variable label and device label right? And if I would to change the device label would I need to write the ID or the API label?
You should use iotable as DEVICE_LABEL and table as VARIABLE_LABEL.
Can you add the method setDebug(true);
in your setup() function and share here the serial monitor output?
All the best
These are displayed right now on my serial monitor. I don’t think this is right
Your device should print the GET request entirely, and it is not making that. What is your username at Ubidots so I can make a test at my side?
Good for me : float value = client.getValue(Variable_ID);
Hi! I have a problem i’m making a simulation in proteus, trying to get data from ubidots with an arduino yun. I sent data with out problem , but i cant get it, it just received a 0.0, and i don´t know how solve this HELP!