Skip to content

ESP32 Log Format Produces Garbled Output

DodaTech Updated 2026-06-26 1 min read

In this tutorial, you'll learn about ESP32 Log Format Produces Garbled Output. We cover key concepts, practical examples, and best practices.

The Problem

ESP32 log messages have garbled formatting, missing arguments, or incorrect type display.

Quick Fix

Wrong

ESP_LOGI(TAG, "Value: %d
", 22.5);  // Wrong format specifier
Value: 1234567890
(Garbage from format mismatch)
int intVal = 42;
float floatVal = 22.5;
char* strVal = "hello";
ESP_LOGI(TAG, "int=%d float=%.1f str=%s", intVal, floatVal, strVal);
ESP_LOG_BUFFER_HEX(TAG, data, 16);  // Hex dump buffer
I (123) tag: int=42 float=22.5 str=hello
I (124) tag: 7C 9E BD 45 12 78 00 00 00 00 00 00 00 00 00 00

Prevention

Use correct format specifiers: %d for int, %f for float, %s for string, %p for pointer, %x for hex. Use ESP_LOG_BUFFER_HEX for binary data display. Do not add \n at end (added automatically).

DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.

FAQ

### What format specifiers are supported?

Standard printf specifiers: %d, %i, %u, %x, %X, %f, %lf, %s, %c, %p. Limited float support in some configurations.

Why does %f print '?' on ESP32?

Float formatting uses extra flash. Enable CONFIG_LOG_DEFAULT_LEVEL and force CONFIG_NEWLIB_STDOUT_ENABLE_FLOAT_SUPPORT in menuconfig.

Can I log binary data?

Yes. Use ESP_LOG_BUFFER_HEX(tag, data, len) for hex output or ESP_LOG_BUFFER_CHAR for character output.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro