Skip to content

Fix LD2450 buffer overflow during initialization#42

Merged
TrevorSchirmer merged 1 commit intoApolloAutomation:betafrom
bharvey88:fix-ld2450-buffer-overflow
Feb 14, 2026
Merged

Fix LD2450 buffer overflow during initialization#42
TrevorSchirmer merged 1 commit intoApolloAutomation:betafrom
bharvey88:fix-ld2450-buffer-overflow

Conversation

@bharvey88
Copy link
Contributor

@bharvey88 bharvey88 commented Feb 13, 2026

Summary

Adds rx_buffer_size: 1024 to the uart_ld2450 configuration to prevent buffer overflow during device initialization.

Problem

The LD2450 sensor randomly stops detecting after several hours of operation. Root cause analysis (esphome/esphome#13956) revealed:

  • Default 256-byte UART buffer overflows during boot
  • ~750 bytes accumulate during 2-second dump_config() block
  • Overflow corrupts initialization commands
  • Sensor enters broken state causing detection failures

Solution

Increase rx_buffer_size to 1024 bytes to accommodate data accumulation during boot sequence.

Testing

  • Compile and flash to R_PRO-1 device
  • Verify LD2450 sensor initializes correctly
  • Confirm detection remains stable over extended period (24+ hours)
  • No factory resets should be required

Fixes esphome/esphome#13956

Summary by CodeRabbit

  • Chores
    • Optimized UART receiver buffer configuration for improved device communication stability.

@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

Walkthrough

Increases the UART receiver buffer size for the LD2450 sensor integration from its default to 1024 bytes in the ESPHome core configuration file, addressing a data reception issue causing detection drops.

Changes

Cohort / File(s) Summary
LD2450 UART Configuration
Integrations/ESPHome/Core.yaml
Added rx_buffer_size: 1024 to uart_ld2450 configuration to expand receiver buffer capacity.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

bugfix

Suggested reviewers

  • TrevorSchirmer

Poem

🐰 A tiny tweak, a buffer grows,
One-zero-two-four, the data flows,
LD2450 shall not slip away,
Detection stays throughout the day! ✨

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix LD2450 buffer overflow during initialization' directly and specifically describes the main change: adding rx_buffer_size to prevent UART buffer overflow during device initialization.
Linked Issues check ✅ Passed The PR addresses the root cause identified in #13956 by increasing the UART RX buffer size from 256 to 1024 bytes to accommodate the ~750-byte data burst during initialization, preventing buffer overflow that corrupted initialization commands.
Out of Scope Changes check ✅ Passed The change is narrowly scoped to the uart_ld2450 configuration, adding only the rx_buffer_size parameter without any extraneous modifications unrelated to fixing the buffer overflow issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into beta

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

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


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.

Increase UART rx_buffer_size from 256 to 1024 bytes to prevent
buffer overflow during boot sequence. The LD2450 sends ~750 bytes
during the 2-second dump_config() block, which overflows the default
256-byte buffer and corrupts initialization commands.

Fixes random detection failures reported in esphome/esphome#13956
@bharvey88 bharvey88 force-pushed the fix-ld2450-buffer-overflow branch from b3bed43 to 515f5a3 Compare February 13, 2026 19:45
@TrevorSchirmer TrevorSchirmer merged commit eec54f5 into ApolloAutomation:beta Feb 14, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments