Skip to content

ESP32S2 could not reassign Serial pins #9363

Closed
@dzungpv

Description

@dzungpv

Board

Lolin S2 Mini

Device Description

Lolin S2 Mini

Hardware Configuration

GPIO 9 and 11 as UART pins

Version

v2.0.14

IDE Name

Arduino, IDF 4.4.6

Operating System

Macos 13, Windows 10

Flash frequency

40Mhz

PSRAM enabled

yes

Upload speed

115200

Description

I use Serial1.begin(9600, SERIAL_8E1, 11, 9) it work but not with
Serial.begin(9600, SERIAL_8E1, 11, 9)

Sketch

Serial.begin(9600, SERIAL_8E1, 11, 9)

Debug Message

No debug

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Activity

self-assigned this
on Mar 12, 2024
SuGlider

SuGlider commented on Mar 13, 2024

@SuGlider
Collaborator

@dzungpv - The Lolin S2 Mini has an USB port in the board that is actually the USB OTG CDC peripheral.
When this board is selected in the Arduino IDE, it will automatically enable the "CDC on Boot", therefore, Serial will be actually the USB CDC Serial.

In order to use UART0, please use Serial0 instead of Serial (USB CDC).
Serial will be the USB CDC port.
Serial0 will be the UART0 port.
Serial1 will be the UART1 port.

dzungpv

dzungpv commented on Mar 13, 2024

@dzungpv
Author

@SuGlider as mention in in #9326 I still could not enable USB CDC on ESP EDF, so it only have Serial and Serial1. the S2 too limit compare to ESP32 and ESP32S3.
So this is a bug of the Core 2.0.

SuGlider

SuGlider commented on Mar 14, 2024

@SuGlider
Collaborator

Are you using the Arduino IDE?

SuGlider

SuGlider commented on Mar 14, 2024

@SuGlider
Collaborator

It works fine with the Arduino IDE, but enabling "USB CDC on Boot" in the tools menu.

If you need to use Arduino as IDF Component, please follow the instructions in #9326 (comment)

dzungpv

dzungpv commented on Mar 14, 2024

@dzungpv
Author

It works fine with the Arduino IDE, but enabling "USB CDC on Boot" in the tools menu.

If you need to use Arduino as IDF Component, please follow the instructions in #9326 (comment)

So as you say I must enable USB CDC on Boot to use UART0 on the ESP32S2 with Arduino? I mean I can assign other pin for it? I use ESP IDF with Arduino component.

SuGlider

SuGlider commented on Mar 14, 2024

@SuGlider
Collaborator

So as you say I must enable USB CDC on Boot to use UART0 on the ESP32S2 with Arduino? I mean I can assign other pin for it? I use ESP IDF with Arduino component.

No, ESP32-S2 Arduino has 2 possible configurations:

  1. USB CDC on Boot is Enabled:
  • Serial is the USB CDC port and the pins can't be changed.
  • UART0 is Serial0 and UART1 is Serial1. The pins can be changed for both.
  1. USB CDC on Boot is Disabled:
  • UART0 is the Serial and UART1 is Serial1. The pins can be changed for both.
dzungpv

dzungpv commented on Mar 14, 2024

@dzungpv
Author

So as you say I must enable USB CDC on Boot to use UART0 on the ESP32S2 with Arduino? I mean I can assign other pin for it? I use ESP IDF with Arduino component.

No, ESP32-S2 Arduino has 2 possible configurations:

1. USB CDC on Boot is **Enabled**:


* `Serial` is the USB CDC port and the pins can't be changed.

* UART0 is `Serial0` and UART1 is `Serial1`. The pins can be changed for both.


2. USB CDC on Boot is **Disabled**:


* UART0 is the  `Serial` and UART1 is `Serial1`. The pins can be changed for both.

Yes, but my problem: could not re-assign UART0 Pin with Arduino, I test with Arduino and ESP IDF with Kaluga dev board and Lolin S2 mini. So it is impossible running 2 UART at same time, My previous design running ESP32 without any problem because it has three UART

dzungpv

dzungpv commented on Mar 14, 2024

@dzungpv
Author

I try with this sample for UART0 https://github.com/ncmreynolds/ld2410/blob/main/examples/basicSensor/basicSensor.ino
But I change it to use Serial when USB CDC on Boot is Disabled:

    #elif CONFIG_IDF_TARGET_ESP32S2
      #define MONITOR_SERIAL Serial1
      #define RADAR_SERIAL Serial
      #define RADAR_RX_PIN 11
      #define RADAR_TX_PIN 9
SuGlider

SuGlider commented on Mar 14, 2024

@SuGlider
Collaborator

Ok, the issue is about reassigning UART0 pins using Arduino Core 2.0.14.
There is an improvement/fix in the PR #9176 about pin attachment.

Could you please apply this PR or just replace all 4 files: HardwareSerial.cpp, HardwareSerial.h, esp32-hal-uart.c and esp32-hal-uart.h within your Arduino Core installation?

I think that it will solve the issue. This shall be released soon within the Arduino Core 2.0.15.
Please let me know.

dzungpv

dzungpv commented on Mar 14, 2024

@dzungpv
Author

Ok, the issue is about reassigning UART0 pins using Arduino Core 2.0.14. There is an improvement/fix in the PR #9176 about pin attachment.

Could you please apply this PR or just replace all 4 files: HardwareSerial.cpp, HardwareSerial.h, esp32-hal-uart.c and esp32-hal-uart.h within your Arduino Core installation?

I think that it will solve the issue. This shall be released soon within the Arduino Core 2.0.15. Please let me know.

I will pull this branch and it will be OK: https://github.com/espressif/arduino-esp32/tree/release/v2.x

12 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    ESP32S2 could not reassign Serial pins · Issue #9363 · espressif/arduino-esp32