Hi, I’m new using Ubidots and I need some help, I don’t know what I’m doing wrong or what is happening, I’m using the WEMOS D1 R2 that has the ESP-8266 built in, I was asked to use the MQTT protocol in order to send all data to Ubidots, everything work just fine, however when I try to include something in the context or the timestamp fields the data shown on Ubidots stop refreshing, but if I don’t use those fields it works perfectly again.
On the other hand if I delete the corresponding data source a new one is correctly created when the next data is supposed to be recieved,I don’t really know why is this happening, at the moment I’m using the ubidots-mqtt-esp-master library along with the pubsubclient-master library, it’s important to mention that I took the publish example and made just one modification in order test it, I’ll left the code bellow, I would really appreciate it if anyone could help me to solve this problem.
/****************************************
- Include Libraries
****************************************/
#include “UbidotsESPMQTT.h”
/****************************************
- Define Constants
****************************************/
#define TOKEN “xC9mjEL33lmTKt1x6OwwrRQ6eTr0HH” // Your Ubidots TOKEN
#define WIFINAME “I modified this” //Your SSID
#define WIFIPASS “I modified this” // Your Wifi Pass
#define MQTTCLIENTNAME “diestrassen185” // Your MQTT Client Name, it must be unique so we recommend to choose a random ASCCI name
int v=0;
char cad[5]=“hola”;
Ubidots client(TOKEN, MQTTCLIENTNAME);
/****************************************
- Auxiliar Functions
****************************************/
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();
}
/****************************************
- Main Functions
****************************************/
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
client.wifiConnection(WIFINAME, WIFIPASS);
client.begin(callback);
}
void loop() {
// put your main code here, to run repeatedly:
if(!client.connected()){
client.reconnect();
}
// Publish values to 2 different data sources
client.add(“stuff1”,v,cad); //Insert your variable Labels and the value to be sent
client.ubidotsPublish(“source1”);
client.loop();
v++;
delay(1000);
}