Arduino_libraries/AsyncMQTT_ESP32/docs/5.-Troubleshooting.md

12 lines
436 B
Markdown

# Troubleshooting
* 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:
```cpp
for (size_t i = 0; i < len; ++i) {
Serial.print(payload[i]);
}
```
Further reading: https://en.wikipedia.org/wiki/C_string_handling