Files
Indiana 6e627bae15 firmware: verify against actual target hardware, fix real conflicts
Researched the exact modules the user is building with and fixed three
concrete issues the earlier speculative firmware got wrong:

1. WiFi: confirmed the target board (Waveshare ESP32-P4-Module-DEV-KIT,
   chip ESP32-P4NRW32) bridges WiFi through an onboard ESP32-C6
   co-processor over a fixed 7-pin SDIO link (CLK18/CMD19/D0-14/D1-15/
   D2-16/D3-17/RESET54, cross-confirmed against Espressif's own
   esp-hosted-mcu docs). wifi_manager.c's esp_wifi_init()/esp_wifi_start()
   calls don't need to change — esp_wifi_remote/esp_hosted provide a
   drop-in-compatible API — but the component manifest (new
   main/idf_component.yml) and sdkconfig.defaults were missing entirely.

2. Real pin conflict: the presence sensor's original UART pins (17/18)
   directly collided with the SDIO CLK/D3 pins above — wiring it there
   would have broken WiFi, the sensor, or both. Moved to GPIO4/5.

3. Swapped placeholder parts for the user's actual hardware:
   - BME280 -> BMP280 (GY-BMP280 module): temp+pressure only, no humidity.
     Rewrote the driver rather than just renaming it — the old code would
     have read nonexistent humidity registers and reported garbage
     forever. 3.3V-only wiring note added (the BME280 assumption of
     5V-tolerant logic doesn't hold for this specific breakout).
   - LD2410 -> RD-03E (Ai-Thinker, not Hi-Link — a different manufacturer
     with a different, incompatible UART protocol). Rewrote the frame
     parser against the RD-03E's actual (if less-documented) 5-byte
     simple-report format. Reports numeric distance instead of a boolean,
     which better fits both the hardware's actual output and the backend's
     statistical anomaly detector.

README, CMakeLists.txt, and all cross-references updated to match.
2026-07-24 21:30:37 +00:00

58 lines
1.9 KiB
C

// Ai-Thinker RD-03E 24GHz mmWave human-movement/gesture radar, over UART.
//
// Confirmed against the actual part in use (not the originally-assumed
// Hi-Link LD2410 — a different manufacturer with a different, incompatible
// UART protocol; do not mix up wiring or frame parsing between the two).
// Reports distance-ranged human presence (not just a boolean, per the
// module's own "Precise Ranging & Positioning" naming) plus a gesture
// code, better suited to a handheld device meant to sense "how close" and
// "what kind of movement" rather than just "something moved."
//
// Implements the sensor_driver_t interface (see sensor_driver.h).
//
// Default wiring — see README.md's wiring section for the full pinout
// table:
// RD-03E OT1 (module's UART TX) -> ESP32 RX (RD03E_UART_RX_GPIO)
// RD-03E RX (module's UART RX) -> ESP32 TX (RD03E_UART_TX_GPIO)
// RD-03E VCC -> 5V (module power; UART logic is 0-3.3V, ESP32-safe)
// RD-03E GND -> GND
// RD-03E OT2 -> not connected (reserved on the module, unused here)
// Default UART settings: 256000 baud, 8N1 (module factory default).
#pragma once
#include "esp_err.h"
#include "sensor_driver.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef RD03E_UART_PORT
#define RD03E_UART_PORT 1
#endif
// GPIO 14-19 and 54 are reserved on the target board (Waveshare
// ESP32-P4-Module-DEV-KIT) for the onboard Wi-Fi co-processor's SDIO link
// — see README.md and sdkconfig.defaults. These pins avoid that range and
// the BMP280's I2C pins (8/9).
#ifndef RD03E_UART_RX_GPIO
#define RD03E_UART_RX_GPIO 4
#endif
#ifndef RD03E_UART_TX_GPIO
#define RD03E_UART_TX_GPIO 5
#endif
#ifndef RD03E_UART_BAUD
#define RD03E_UART_BAUD 256000
#endif
// sensor_driver_t-compatible entry points.
esp_err_t rd03e_init(void);
esp_err_t rd03e_read(sensor_reading_t *out, size_t max_out, size_t *out_count);
#ifdef __cplusplus
}
#endif