[SOLVED] Adding context while publish

Hello, I am establishing an MQTT connection and publishing it to the Ubidots dashboard. I want to just add the Context like “Motion Detected” while publishing.

And I am using this code in Arduino IDE with ESP32:

  reconnect();
  }
  sprintf(topic, "%s%s", "/v1.6/devices/", DEVICE_LABEL);
  sprintf(payload, "%s", ""); // Cleans the payload
  sprintf(payload, "{\"%s\":", VARIABLE_LABEL); // Adds the variable label
  
  float sensor = analogRead(sensor);
  dtostrf(sensor, 4, 2, str_sensor);
  sprintf(payload, "%s {\"value\": %s}}", payload, str_sensor); // Adds the value
  Serial.println("Publishing data to Ubidots Cloud");
  client.publish(topic, payload);
  client.loop();
  delay(1000);

In Dashboard, I am getting ----- line in place of context.
So what changes I have to make in the above code? Please help me out.

Hi there, you may refer to the GPS tracker example here.

All the best

Sorry for late response, and Thank you so much for the help. And now I am able to do what I wanted. Thanks again