Hi @Laszlo Frank The encoding is done as the message gets send to the IoT Hub, which is the PubSubClient step in this case. To overcome this, we need to specify the Content Type and Encoding Type before sending the message.
Since we are publishing the data using MQTT topic name, we can set these parameters at the end as follows.
doc["Temp"] = "25";
doc["Hum"] = "46";
doc["Battery"] = "Full";
char strJSON[255] = {0};
//JsonObject jobject = doc.to<JsonObject>();
serializeJson(doc, strJSON);
char topic[] = "devices/<IoTDevice>/messages/events/$.ct=application%2Fjson%3Bcharset%3Dutf-8";
mqtt_client.publish(topic, strJSON, false);
//mqtt_client.beginMessage(telemetry_topic);
//mqttClient.print(strJSON);
Serial.println("OK");
delay(2000);
digitalWrite(LED_PIN, LOW);
Please note to replace the Topic with the appropriate device to which you would like to send the data. Once you set the parameters, you can view the message in the correct format. Please refer the below image for reference.
Here is the documentation on MQTT provided on IoT Hub that provides this explanation https://video2.skills-academy.com/en-us/azure/iot-hub/iot-hub-mqtt-support#sending-device-to-cloud-messages
Kindly note that, the message format you see when you monitor the built in event end point in Azure cloud shell is not accurate depiction of the data received by the IoT Hub. If you route the data to blob container, you would see the message would still be in base64 format.
Hope this addresses the issue you are facing. Please let us know if you still need any further clarification on this.
If this answers your query, do click Accept Answer as helpful. And, if you have any further query do let us know by commenting in the below section. Happy to help!