Arduino Mega send data to ESP8266-01 then ESP forward to RPI (MQTT)

Make the following float because the DHT library returns float.

float hum2;  //Stores humidity value
float temp2; //Stores temperature value

Convert float to C string for MQTT publish.

char c_string[16];
dtostrf(temp2, 4, 2, c_string);
client.publish("temperature", c_string);
dtostrf(hum2, 4, 2, c_string);
client.publish("humidity", c_string);