Ubidots Community

[SOLVED] Data won't refresh on Ubidots when using Timestamp and (or) Context fields, ESP-8266, MQTT

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”;



  • Auxiliar Functions

void callback(char* topic, byte* payload, unsigned int length) {
Serial.print(“Message arrived [”);
Serial.print("] ");
for (int i=0;i<length;i++) {


  • Main Functions

void setup() {
// put your setup code here, to run once:
client.wifiConnection(WIFINAME, WIFIPASS);

void loop() {
// put your main code here, to run repeatedly:

// Publish values to 2 different data sources

client.add(“stuff1”,v,cad); //Insert your variable Labels and the value to be sent

Hello, you should be able of sending your timestamp in this way:

client.add(“stuff”, 10.5, “”, “1482155467”); //Insert your variable Labels and the value to be sent

According to Ubidots Github docs: https://github.com/ubidots/ubidots-mqtt-esp, the function add() has as input parameters the variable’s label, its value, its context and its timestamp, so if you want to use a custom timestamp simple send a blank context.


1 Like

Hello, first of all thank you for the reply, I tried that out and it worked, however it is a bit strange because if I include the timestamp like this: client.add(“Sensor1”, 15.8, “”, “1482250072”); the date is displayed on Ubidots as 1970-01-17 21:44:10 -0600, why does this happen?

Thanks again, Regards.

Hello, please send the timestamp on milliseconds, something like this:

client.add(“Sensor1”, 15.8, “”, “1482250072000”);


1 Like

@DieStrassen1 you can use http://www.epochconverter.com/ this page can convert the epoch timestamp to human format or vice versa.

1 Like

Thank you so much s @jotathebest and @woakas for your help, by including
client.add(“Sensor1”, 15.8, “”, “1482250072000”); it and finally worked as expected, now my project is completed, I hope this helps others who are having the same problem.

Happy holidays and regards :slight_smile: .