- The payload of incoming messages contains raw data. You cannot just print out the data without formatting. This is because Arduino's
print
functions expect a C-string as input and a MQTT payload is not. A simple solution is to print each character of the payload:
for (size_t i = 0; i < len; ++i) {
Serial.print(payload[i]);
}
Further reading: https://en.wikipedia.org/wiki/C_string_handling