Ubidots Community

GET REQUEST ERROR with ARDUINO UNO + ETHERNET

Hi, I am using Arduino Uno + Ethernet Shield

#include <Ethernet.h>
#include <SPI.h>
#include <UbidotsEthernet.h>

#define echoPin 8
#define trigPin 9
//#define buzzer 7
//#define ledPin 10

char const * TOKEN = "BBFF****************************"; // Input your Ubidots Token here
char const * DEVICE_LABEL = "arduino-ethernet";
char const * VARIABLE_LABEL_1 = "distance";
const char * VARIABLE_LABEL_2 = "sensor-calibration";
const char * VARIABLE_LABEL_3 = "water-level";

int safeDis;
long duration; 
float value;
float distance;
float level;

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; 
Ubidots client(TOKEN);

void setup() {
  Serial.begin(115200);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  //pinMode(buzzer, OUTPUT);
  //pinMode(ledPin, OUTPUT);
  client.setDebug(true);
  Serial.print(F("Starting ethernet..."));
  if (!Ethernet.begin(mac)) {
    Serial.println(F("failed"));
  } else {
    Serial.println(Ethernet.localIP());
  }
  delay(2000);
  Serial.println(F("Ready"));
}

void loop() {

  Ethernet.maintain();
  //alarm();
  
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration*0.0343/2;
  value = client.getValue(DEVICE_LABEL, VARIABLE_LABEL_2);
  level = value - distance;
  
  client.add(VARIABLE_LABEL_1, distance);
  client.add(VARIABLE_LABEL_3, level);
  client.sendAll();
  Serial.print(distance);
  Serial.println();
  delay(5000);
  
}

Here is my code. But I am getting an error when trying to Request GET value. Here is the error message:

I hope someone could help me. Thank you.

Good day @itschristianjay,

Thank you for sharing your question with the community.

A 404 Not Found response means that the URL wasn’t possible to find. This might be due to a wrong device or variable label, or simply a typo in the URL of the request. Having said that, can you please verify the label and print in the serial monitor the request so we can investigate what could be happening?

Additionally, we recommend you to first try the example of getting a value without sending values to ensure the issue is no related with the GET request.

All the best,
-Isabel