Printf baud rate?

I have downloaded PlatformIO and have set it up for ESP32.
I loaded hello world and it has compiled and programmed my Sparkfun ESP32-thing board.
The LED is flashing but the serial serial monitor shows nothing but junk.
I tried to connect Teraterm to find the right board rate, but nothing works.

So, I’m in deep water.
Does the printf function use standard Out and is standard Out connected to the serial port ?

How do I change the port number and baud rate, for standardOut ?

The Esp32-Thing uses a 26MHz crystal, while esp-idf by default assumes a 40MHz crystal.
No idea how PlatformIO handles this, but in ESP-IDF you would use ‘make menuconfig’ to select an alternative clock frequency.

Thanks

What code and framework are you using? ESP-IDF? Arduino?

If the platformio.ini has been correctly configured for a SparkFun ESP32 Thing I would have thought it would work fine, but I’m not familiar with the ESP-IDF framework, so that may or may not be the case… I’m sure someone else can help you with that if doesn’t ‘just work’ out of the box.

The framework is ESP-IDF.
I found another post about this same problem, but the things it mentioned were correct.
Does anyone know where the serial port is setup for standardOut ?

I measured the timing of the serial Tx line from the ESP32 processor.
The board rate is 75000 baud.
My Saleae decodes the 75000 baud into the Hello World program text correctly.

The default is a 115200 baud rate but that assumes, as you said, a 40MHz crystal. A 26MHz crystal gives you 26.0 / 40 * 115200 = 74880.0 baud.

As @pfeerick has already said, for the Sparkfun ESP32-thing board you need SparkFun ESP32 Thing — PlatformIO latest documentation. It uses this json file. The crystal frequency is defined via the macro

#define CONFIG_ESP32_XTAL_FREQ 40

in the sdkconfig.h.

So, you just need to go into your project’s sdkconfig.h and change it to 26 and recompile.

1 Like

Editing the sdkconfig.h file did fix the baud rate issue.
The file stated that it is audogenerated.

So the next project I create will need the sdkconfig.h file to be edited to work properly.

Or someone more knowledgeable then I can fix the auto generated file.
Or someone can show me how I can fix the auto generated file.

The PlatformIO code actually just copies it from the first sdkconfig.h in the examples/ folder. The notice “DO NOT EDIT, AUTOGENERATED FILE” is just wrong, PIO will not re-generate the file on every compile once it’s there.

See code here and here.

So there’s also no way to influence the contents of the file. If the sdkconfig.h is not there when compiling the project, it will get the default one, if yes, it will do some deprecation checks and then just use it.

OK, great to hear.
When I create a new project, where does the default version come from, so I can change it.

Thanks

i.e home dir ($HOME / %USERPROFILE%) /.platformio/platforms/espressif32/examples/ and the first example with a sdkconfig.h is currently espidf-blink

So in my case that path is

/home/pfeerick/.platformio/platforms/espressif32/examples/espidf-blink/src/sdkconfig.h