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.