Hello,
I am trying to send data using Mqtt to Ubidots server (30 day trial).
I folowed the steps suggested in the portal for a simple publish example.
But the dashboard only updates once … and after a few samples MQTT connection fails.
Heres is the serial monitor output:
Eventually reconects, but dashboard never updates again.
I also tried a simple example with HTTP with the same result.
Here is the code …
#include "UbidotsESPMQTT.h"
#define TOKEN "here is my token" // Your Ubidots TOKEN
#define WIFINAME "CLAROMEP2" //Your SSID
#define WIFIPASS "55134488" // Your Wifi Pass
Ubidots client(TOKEN);
void callback(char* topic, byte* payload, unsigned int length) {
Serial.print("Message arrived [");
Serial.print(topic);
Serial.print("] ");
for (int i=0;i<length;i++) {
Serial.print((char)payload[i]);
}
Serial.println();
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
client.setDebug(true); // Pass a true or false bool value to activate debug messages
client.wifiConnection(WIFINAME, WIFIPASS);
client.begin(callback);
}
void loop() {
// put your main code here, to run repeatedly:
if(!client.connected()){
client.reconnect();
}
float temp = random(0, 9) * 10;
float hum = random(0, 9) * 10;
client.add("temperatura", temp); //Insert your variable Labels and the value to be sent
client.ubidotsPublish("Secadero_1");
client.add("humedad", hum);
client.ubidotsPublish("Secadero_1");
client.loop();
}
Please let me know how to troubleshoot/analyze this issue.
Best Regards,
Patricio Lllovera