ESP32-S3 no longer executing code

Hi All,
I have a ESP32-S3 with 16MB Flash and 8MP PSRAM.
All was going well with basic Arduino sketches and then I added a encoder to GPIO pins 38,37,36 and then it stopped responding to my code. I used Arduino initially because of all the sample projects. I have done quite a few projects in PIO so not overly a newbie in this area.

Platformio.ini

[env:esp32]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
; Specify velocity of serial monitor
monitor_speed = 115200
; Specify the frequency of the CPU
board_build.f_cpu = 240000000L
; Specify the frequency of the FLASH
board_build.f_flash = 80000000L
; FLASH Partition table designated as 16MB
board_build.arduino.partitions = default_16MB.csv
; Specify the operating mode of FLASH and PSRAM
board_build.arduino.memory_type = qio_opi
; Predefined macro, enabling PSRAM
build_flags = -DBOARD_HAS_PSRAM
; Specify a FLASH capacity of 16MB
board_upload.flash_size = 16MB

main.cpp

#include <Arduino.h>

void setup() {
  Serial.begin(115200);
  Serial.println('Setup - Start');
  // Stuff
  Serial.println('Setup - Complete');
}

void loop() {
  // put your main code here, to run repeatedly:
  log_d("Total heap: %d", ESP.getHeapSize());
  log_d("Free heap: %d", ESP.getFreeHeap());
  log_d("Total PSRAM: %d", ESP.getPsramSize());
  log_d("Free PSRAM: %d", ESP.getFreePsram());
  delay(1000);
}

Terminal Output

ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1     
load:0x3fce3808,len:0x44c 
load:0x403c9700,len:0xbd8 
load:0x403cc700,len:0x2a80
entry 0x403c98d0
*** 1952543348
1818588261

Any ideas on how to get it going again?

Thanks,
Neil.

If the problem is not with the encoder but with the board:
Try my board manifest: esp32-s3-devkitc1-n16r8.json.

You’ll find a description in README.md where to put the .json file.

Then in your platformio.ini all you need is
board = esp32-s3-devkitc1-n16r8

1 Like

Slightly different result.

ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x44c
load:0x403c9700,len:0xbd8
load:0x403cc700,len:0x2a80
entry 0x403c98d0
1952543348
1818588261

I don’t quite understand the problem yet. The output does not match the code and what does the rotary encoder have to do with it? Is the output correct if the encoder is not connected? If so, what does the output look like?

Oh, all you need to do is set the correct debug level in platformio.ini for log_d to work:

build_flags = 
  -DCORE_DEBUG_LEVEL=5
1 Like

Serial.setDebugOutput(true) is missing.

Hi All,
Sorry for the delay in coming back to this topic. Family issues.
The USB Uart is UART0.

If I use log_d(“Test”); it outputs.
If I use Serial.println(“fred”); it doesn’t.

If I use Serial.setDebugOutput(true); I get NO logging outputs. If I comment out this line, I get logging outputs. I can handle this idiosyncrasy.

Why does Serial.println(“fred”); not work??

This is in my main loop with a 1500mS delay
log_d(“Test”);
Serial.println(“fred”);

This is what I get on the monitor.
[474117][D][main.cpp:118] loop(): Test
[475617][D][main.cpp:118] loop(): Test
[477117][D][main.cpp:118] loop(): Test

No “fred”'s.

Depending on the compiler flag ARDUINO_USB_CDC_ON_BOOT you must use either Serial or Serial0 to output via UART 0 (RX/TX pins / onboard Serial to USB chip).

ARDUINO_USB_CDC_ON_BOOT UART 0
(RX / TX)
OTG
(native USB)
0 Serial USBSerial
1 Serial0 Serial

If ARDUINO_USB_DCD_ON_BOOT = 0

  • Serial is routed to UART and
  • USBSerial is routed to the OTG port.

If ARDUINO_USB_DCD_ON_BOOT = 1

  • Serial0 is routed to UART
  • Serial is routed to the OTG port.
1 Like

Many thanks, perfect