Adding timestamp to kaaiot

I'm struggling sending the data with timestamp, I've pressed on auto-extraction and changed the format to sec-unix-epoch but I didn't specify a path (I'm not sure what I should write there)

Here is the json I've tried to send


DynamicJsonDocument telemetry(128);
    telemetry.createNestedObject();
    unsigned long timestamp = strtoul("1630992996",NULL,10); //1630992996 = Tuesday, September 7, 2021 5:36:36 AM just for test
    Serial.print("timestamp = ");
    Serial.println(timestamp);
    telemetry[0]["temperature"] = random(18, 23);
    telemetry[0]["timestamp"] =  timestamp;
    //Sending data to the Cloud
    String payload = telemetry.as<String>();
    mqttClient.beginMessage(metricsPublishTopic);
    mqttClient.print(payload.c_str());
    mqttClient.endMessage();
    
    Serial.println("Published on topic: " + metricsPublishTopic);
    Serial.println("payload:  " + payload);

Should I add a path to the json payload? If yes, how? Do you have examples for such problems?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.