Debugging on ESP32 for Arduino IDE

one standardmethod for debugging is to add serial output to your code.

if you open the serial monitor you can see the printed values and messages.
Best regards Stefan