Issues understanding char* and using MQTT


char* temp = "";
temp = dtostrf(bme.readTemperature(), 2, 2, temp);

Here, you have defined a pointer to an empty string, and then you've tried to stuff a non-empty string into the space you didn't reserve.

That's not going to end well.

In addition to writing to memory you don't own (which you don't get to do because the code won't compile), the compiler is also complaining about the arguments you're trying to pass to 'client.publish()'. What data type is 'mqtt_topic'? If you had posted your full code, I would not have had to ask that. What datatypes does 'client.publish()' accept? Have you looked in PubSubClient.h?