Files
mmWaveESP/platformio.ini
T
mattandClaude 9c1c3fe1e8 Add YD-ESP32-S3 support, boot diagnostics, and hang guards
Board is now selected by `default_envs` in platformio.ini rather than being
hardcoded. Both boards stay supported and both targets build.

- src/board_pins.h holds one block per board plus an ledSet() abstraction, so
  main.cpp has no board-specific code. The C6's active-low LED and the S3's
  WS2812 RGB go through the same call, and the C6 antenna-switch lines are
  behind #if HAS_RF_SWITCH.
- YD-ESP32-S3 env targets esp32-s3-devkitc1-n16r8 (verified against the actual
  part: ESP32-S3 rev v0.2, 16MB quad flash, 8MB octal PSRAM, CH343 bridge).
  Serial is UART0 -> CH343, not USB CDC.

Fixes for hangs that left the board alive on USB but dead on the network:

- The vendor library's UART path has loops with no timeout: sensorStop() is
  while(1) that only exits on a "sensorStop" reply, and the UART branch of
  getStatus() is while(len == 0). Calling either with no sensor attached hung
  setup() permanently. UART is now probed with a raw 1.5s read on Serial1, and
  the library only gets the port once bytes actually arrive. The I2C path is
  bounded, so prefer I2C.
- Floating SDA/SCL can stall Wire.endTransmission() forever. Check both lines
  read high with pull-ups before touching Wire.
- Serial.setTxTimeoutMs(0) is a trap: HWCDC::write seeds a uint32_t from it and
  does a bare tries--, so 0 underflows to 4.29e9 and spins for ~49 days. Use 10,
  and only on USB CDC boards.

Diagnostics, so "did it crash?" is answerable without a serial cable:

- Boot count in RTC memory, esp_reset_reason(), free/min heap and WiFi drop
  count exposed via /api/live and shown as header pills in the UI.
- WiFi auto-reconnect, and retry of station mode from the AP fallback. Without
  it a single dropout left the board unreachable forever, which looks exactly
  like a crash.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-14 11:55:03 -07:00

52 lines
2.1 KiB
INI

; XIAO ESP32-C6 / YD-ESP32-S3 + DFRobot C4001 24GHz mmWave presence sensor
;
; ============================================================================
; TO SWITCH BOARDS: change `default_envs` below to one of the [env:] names.
; yd_esp32_s3 -> YD-ESP32-S3 (ESP32-S3-WROOM-1 N16R8), CH343 COM port
; xiao_esp32c6 -> Seeed XIAO ESP32-C6, native USB Serial/JTAG
; Pin maps for each live in src/board_pins.h.
; Or build one explicitly without editing this file: pio run -e xiao_esp32c6
; ============================================================================
[platformio]
default_envs = yd_esp32_s3
; ---------------------------------------------------------------- shared ----
[env]
framework = arduino
monitor_speed = 115200
monitor_filters = esp32_exception_decoder, time
lib_deps =
; Registry copy lags behind; take it straight from DFRobot.
https://github.com/DFRobot/DFRobot_C4001.git
; ----------------------------------------------------- YD-ESP32-S3 N16R8 ----
; Detected on this machine: ESP32-S3 (QFN56) rev v0.2, 16MB quad flash,
; 8MB octal PSRAM, MAC 24:58:7c:cd:9a:d8, CH343 bridge (1a86:55d3).
;
; The board has two USB-C sockets. This env assumes the one marked COM (the
; CH343 UART bridge). Serial is therefore real UART0, not USB CDC, which also
; sidesteps the CDC-blocking behaviour that bit us on the C6.
[env:yd_esp32_s3]
platform = espressif32
board = esp32-s3-devkitc1-n16r8
build_flags =
-DBOARD_YD_ESP32_S3
-DARDUINO_USB_CDC_ON_BOOT=0 ; Serial -> UART0 -> CH343 -> /dev/ttyACM0
-DCORE_DEBUG_LEVEL=1
; ------------------------------------------------------ Seeed XIAO ESP32-C6 --
; Detected earlier: ESP32-C6FH4 (QFN32) rev v0.1, 4MB flash,
; MAC e4:b3:23:b4:7b:c4, native USB Serial/JTAG (303a:1001).
;
; Needs Arduino-ESP32 core 3.x. The installed platform is the pioarduino fork
; (2026.02.30, core 3.3.7) which has the XIAO_ESP32C6 variant. The old registry
; espressif32 6.x has no C6 support -- don't downgrade.
[env:xiao_esp32c6]
platform = espressif32
board = seeed_xiao_esp32c6
build_flags =
-DBOARD_XIAO_C6
-DARDUINO_USB_CDC_ON_BOOT=1 ; Serial -> native USB CDC
-DCORE_DEBUG_LEVEL=1