how to convert String to const char* ?

Thanks works, but unfortunally only for the first call :frowning: after that, the char content is corrupted??

  char msg[50];
  char topic[50];

  char* MQTT_ROOT = "/home/dg/";
  const char* MQTT_GetTemperature = "temperature/get/value";
  const String MQTT_GetPressure = "pressure/get/value";
  const String MQTT_GetHumidity = "humidity/get/value";


  snprintf (msg, sizeof(msg), "%.1f", bme.readTemperature());
  snprintf (topic, sizeof(topic), "%s%s", MQTT_ROOT, MQTT_GetTemperature);

  Serial.print("Topic: ");
  Serial.println(topic);
  Serial.print("Message: ");
  Serial.println(msg);

  snprintf (msg, sizeof(msg), "%.1f", bme.readHumidity());
  snprintf (topic, sizeof(topic), "%s%s", MQTT_ROOT, MQTT_GetHumidity);
  
  Serial.print("Topic: ");
  Serial.println(topic);
  Serial.print("Message: ");
  Serial.println(msg);
  
  snprintf (msg, sizeof(msg), "%.1f", bme.readPressure() / 100.0F);
//  snprintf (topic, sizeof(topic), "%s%s", MQTT_ROOT, MQTT_GetPressure);
  
  Serial.print("Topic: ");
  Serial.println(topic);
  Serial.print("Message: ");
  Serial.println(msg);

Result:

Topic: /home/dg/temperature/get/value
Message: 23.2
Topic: /home/dg/ô‹ü?
Message: 57.6
Topic: /home/dg/ô‹ü?
Message: 1010.4

Edit: sorry, reason found by myself during reading my written post :frowning:

Changing the other Strings to char* and all works well :slight_smile:

const char* MQTT_GetPressure = "pressure/get/value";
const char* MQTT_GetHumidity = "humidity/get/value";