Closed
Description
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
SuGlider commentedon Mar 13, 2024
@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 ofSerial
(USB CDC).Serial
will be the USB CDC port.Serial0
will be the UART0 port.Serial1
will be the UART1 port.dzungpv commentedon Mar 13, 2024
@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 commentedon Mar 14, 2024
Are you using the Arduino IDE?
SuGlider commentedon Mar 14, 2024
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 commentedon Mar 14, 2024
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 commentedon Mar 14, 2024
No, ESP32-S2 Arduino has 2 possible configurations:
Serial
is the USB CDC port and the pins can't be changed.Serial0
and UART1 isSerial1
. The pins can be changed for both.Serial
and UART1 isSerial1
. The pins can be changed for both.dzungpv commentedon Mar 14, 2024
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 commentedon Mar 14, 2024
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:
SuGlider commentedon Mar 14, 2024
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
andesp32-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 commentedon Mar 14, 2024
I will pull this branch and it will be OK: https://github.com/espressif/arduino-esp32/tree/release/v2.x
12 remaining items