Debug Utils with Arduino on ESP32-C3

Updated on 13 November 2023
dev board ESP32-C3-DevKitM-1
chip ESP32-C3-MINI-1-N4
features debug utils print error warning info esp32c3

Before starting

Dependancies

Ensure the following dependancies are downloaded and available:

Pre-requisites

Try these simpler or similar examples:

Buy the components

Code

Download code debugutils-arduino-esp32c3.ino
#include "Arduino_DebugUtils.h"

int i = 0;

void setup() {
  Serial.begin(115200);
  while (!Serial) { }

  // DBG_NONE, DBG_ERROR, DBG_WARNING,
  // DBG_INFO (default), DBG_DEBUG, and DBG_VERBOSE
  Debug.setDebugLevel(DBG_NONE);  // Try out one by one
  Debug.timestampOn();
}

void loop() {
  DEBUG_ERROR("Error i = %d", i);
  DEBUG_WARNING("Warning i = %d", i);
  DEBUG_INFO("INFO i = %d", i);
  DEBUG_DEBUG("DEBUG i = %d", i);
  DEBUG_VERBOSE("Verbose i = %d", i);
  i++;
  delay(1000);
}

Makefile

BOARD?=esp32:esp32:esp32c3
PORT?=/dev/cu.usbserial-*
BUILD=build

.PHONY: default lint compile upload clean

default: clean lint compile upload clean

lint:
	cpplint --extensions=ino --filter=-legal/copyright *.ino

compile: clean lint
	arduino-cli compile --fqbn $(BOARD) --output-dir $(BUILD) ./

upload:
	arduino-cli upload --fqbn $(BOARD) --port $(PORT) --input-dir $(BUILD)

clean:
	rm -rf build

Prototype

A photo of the actual setup.

Debug Utils with Arduino on ESP32-C3 prototype

Description

With the Arduino library DebugUtils, display various levels of print statements.

  1. When it is Debug.setDebugLevel(DBG_NONE);
  2. When it is Debug.setDebugLevel(DBG_ERROR);
  3. When it is Debug.setDebugLevel(DBG_WARNING);
  4. When it is Debug.setDebugLevel(DBG_INFO);
  5. When it is Debug.setDebugLevel(DBG_DEBUG);
  6. When it is Debug.setDebugLevel(DBG_VERBOSE);

References