ESP-IDF for Arduino Users, Tutorials Part 1: Logging
1 min readDec 30, 2020
This is the first part of a series of ESP-IDF tutorials that I will complete as I learn stuff.
Consider the following Arduino code:
Serial.println(“begining”);
I call this the “Arduino debugger”. It’s a joke. Arduino has no debugger — don’t be silly, Ali! It’s not really debugging, it’s logging.
How do we do logging on ESP-IDF? Well, it’s remarkably easy. Let’s look at it and then you should read the documentation.
My notes
- The logging macros are in “esp_log.h”
#include "esp_log.h"
- Set the logging level in menuconfig.
$ idf.py menuconfig
- Navigate to: Components -> Log Output -> Default log verbosity
- Define a TAG, e.g.
static const char* TAG = “FruityModule”;
- Call the log methods
ESP_LOGD(TAG, “I am a banana”);
- Look, printf style is available too
ESP_LOGD(TAG, “I am a banana and I am %d years old”, age);
- Multiple levels of the macros are available
ESP_LOGE — error (lowest)ESP_LOGW — warningESP_LOGI — infoESP_LOGD — debugESP_LOGV — verbose (highest)
Complete example
#include "esp_log.h"static const char* TAG = "main-main";void app_main(void)
{
ESP_LOGD(TAG, "begin");
}
This tutorial is part of a series. Read the next part: Delay.