Skip to content

fix for serial port on esp32 (#5501)#5503

Open
RobertoD91 wants to merge 1 commit intowled:mainfrom
RobertoD91:main
Open

fix for serial port on esp32 (#5501)#5503
RobertoD91 wants to merge 1 commit intowled:mainfrom
RobertoD91:main

Conversation

@RobertoD91
Copy link
Copy Markdown

@RobertoD91 RobertoD91 commented Apr 13, 2026

Possible fix for #5501
Tested on a real ESP32, and CI passes. It has not been tested on a real ESP8266.

This is my first pull request, so please feel free to reject it if anything is wrong.

Summary by CodeRabbit

  • Chores
    • Refined ESP32 serial communication initialization during startup for improved stability and hardware compatibility.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 13, 2026

Walkthrough

The RX pin initialization on ESP32 is refactored to use the GPIO driver's gpio_pulldown_en() function instead of Arduino's pinMode(), placed after Serial.begin() to avoid UART IOMUX interference. This requires adding driver/gpio.h.

Changes

Cohort / File(s) Summary
ESP32 RX Pin Initialization
wled00/wled.cpp
Replaced pinMode(hardwareRX, INPUT_PULLDOWN) with direct GPIO driver call gpio_pulldown_en() invoked after serial initialization, including driver/gpio.h header to prevent UART IOMUX conflicts on ESP32.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing serial port initialization on ESP32 by replacing pinMode() with gpio_pulldown_en().

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@wled00/wled.cpp`:
- Around line 378-383: The serial RX timeout is too long on ESP32 causing
Serial.available() to miss short commands; after the existing
Serial.begin(115200) call add a guarded call to Serial.setRxTimeout(1) inside
the preprocessor check for ARDUINO_ARCH_ESP32 and excluding
ARDUINO_USB_CDC_ON_BOOT (i.e. wrap the setRxTimeout call with `#if`
defined(ARDUINO_ARCH_ESP32) && !ARDUINO_USB_CDC_ON_BOOT ... `#endif`) so the IDF
idle-timeout mechanism triggers for short packets without using setRxFIFOFull();
keep the existing gpio_pulldown_en((gpio_num_t)hardwareRX) code as-is.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 86d25caf-0e0d-43d3-a53d-58111982b7fc

📥 Commits

Reviewing files that changed from the base of the PR and between 9651061 and 1cce33e.

📒 Files selected for processing (1)
  • wled00/wled.cpp

// Pull down RX pin to suppress noise when floating, without breaking UART0 IOMUX mapping.
// pinMode() routes GPIO through the GPIO matrix and detaches UART0 RX - use gpio_pulldown_en() instead.
// See issue #3128.
gpio_pulldown_en((gpio_num_t)hardwareRX);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all that is needed is to replace pinMode(hardwareRX, INPUT_PULLDOWN); with this line, nothing else.

@softhack007 softhack007 linked an issue Apr 13, 2026 that may be closed by this pull request
1 task
@softhack007

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No ADAlight response on esp32 with wled 16 or 17

3 participants