I currently have the same problem to you. Everything works fine, but after about 5-30mins, the connection will be lost and never reconnected automatically, I have to reconnect by press reset on board and then the connection will be established again.
Have you got the solution for your problem yet?
Please share me if you got any solutions.
Thanks.
Hi @Metavix, Here is my code using Arduino Ethernet Shield(board Arduino Mega 2560 - Ethernet Shield compatibale) with Ubidots Library:
#include <Ethernet.h>
#include <SPI.h>
#include <UbidotsEthernet.h>
#include <DS18xx.h>
#define ID "57de408676254229e66e5dd9" // Put here your Ubidots variable ID
#define ID1 "57de514f76254201c5e9aa4c"
#define ID2 "57de541e7625420ea0fad351"
#define TOKEN "oZ6cj8dVfA2ULrevdjkb4pd10bHT3Q" // Put here your Ubidots TOKEN
#define oneWire_pin 3
OneWire oneWire(oneWire_pin);
DS18xx sensors(&oneWire);
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(10, 10, 10, 177);
Ubidots client(TOKEN);
void setup()
{
Serial.begin(115200);
sensors.begin();
if (Ethernet.begin(mac) == 0)
{
Serial.println("Failed to configure Ethernet using DHCP");
Ethernet.begin(mac, ip);
}
delay(3000);
}
void loop()
{
sensors.requestTemperatures();
float ds_value = sensors.getTempCByIndex(0);
client.add(ID, ds_value);
client.sendAll();
int led = client.getValue(ID1);
int pwm = client.getValue(ID2);
Serial.println(led);
Serial.println(pwm);
//client.freeRam();
}
This is just a normal code, nothing is too complex, but the Ethernet Shield will stop working after a short time connected to Ubidots Cloud(5-30 mins as I mentioned in the last comment).
Also, I had edited, exactly commented two of code lines in UbidotsEthernet.cpp", those are:
Serial.println(reply); in float Ubidots::getValue(char* id) into //Serial.println(reply);
Serial.write(c); in bool Ubidots::sendAll() into //Serial.write(c);
That’s it, only these two lines of code, nothing else.
Attached is my dashboard for this code.
hello @chauhuynh i know what was the problem and i fixed it in this new version of the library download it and add it to the arduino IDE, it will work for you. By the way don’t forget to delete the old version of the library
@Metavix I also faced the same problem, but the microcontroller im using is LoPy and the programming language is micropython. i followed this tutorial but i cant send analog data. can you help?