Skip to content

Commit 29ebac7

Browse files
author
Ravi Singh
committed
refactor: v6.x single-sensor pivot — drop mesh + topology + LD2410 family
PCB-lock prep. v6.0 shipped a dual-device ESP-NOW master/slave architecture; bench testing on real U-shape and L-shape installs showed ESP-NOW jitter (5-100 ms with retries) added visible LED lag, and the LD2450's (x, y, speed) target stream from a single sensor at the inside corner of the LED run already covers both arms inside its 60° cone — making the second sensor redundant for the geometries users actually install. Removed: - firmware/components/mesh, firmware/components/topology - radar_ld2410.c (and ld2410/ld2412/ld2420 registry entries) - /api/mesh, /api/mesh/identify, /api/topology endpoints - ScreenMesh + TopologyDiagram + Mesh tab + peer fields in UI - mesh + topo NVS namespaces (orphan keys on upgraded units are ignored) - STATUS_LED_PAIRING / STATUS_LED_IDENTIFY patterns - Button long-press → mesh_open_pairing wiring (now no-op, reserved for v6.1 factory reset) Locked: ld2450 + sim only in radar registry. Builds: - firmware: ambisense.bin 0x11aa70 / 0x160000 partition (20% free) - frontend: dist/index.html 85.4 kB / 25.2 kB gzipped Docs (V6-ARCHITECTURE, V6-ROADMAP, HARDWARE, README) rewritten to reflect single-sensor architecture and PCB-rev power-rail recommendations (discrete AP2112K-3.3 / MIC5219 LDO feeding both C3 3V3 and LD2450, star-grounded LED return).
1 parent a4376c4 commit 29ebac7

28 files changed

Lines changed: 340 additions & 1569 deletions

File tree

README.md

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,44 @@
33
<img src="https://raw.githubusercontent.com/Techposts/AmbiSense/refs/heads/main/Assets/AmbiSense.webp" width="300" alt="AmbiSense Logo">
44
</p>
55

6-
> ### 🚀 v6.0.0 shipped — full ESP-IDF + FreeRTOS rewrite
6+
> ### 🚀 v6.x — single-sensor PCB rev (in development on `v6-idf-rewrite`)
77
>
8-
> v6 is a ground-up rewrite from Arduino onto **ESP-IDF + FreeRTOS**: independent
9-
> FreeRTOS tasks for radar read, motion smoothing, LED rendering, web serving,
10-
> and ESP-NOW peer-mesh — no more cooperative `loop()` starving the LED
11-
> render under HTTP load. v6 ships with **LD2450 multi-target tracking**, a
12-
> **modular radar driver layer** (LD2410 / LD2412 / LD2420 / LD2450 / sim —
13-
> swap via web UI without reflashing), a **board picker with editable pin map**
14-
> (ESP32-C3 / ESP32 / S3 / C6), a **peer mesh** for U/L/asymmetric stairs
15-
> (every device runs identical code; lowest-MAC wins coordinator),
16-
> **asymmetric pairing** (click Pair on either device → both join), a
17-
> **Kalman-based motion filter** (3 user knobs instead of v5's 5 cryptic
18-
> gains), **OTA with rollback**, **captive portal**, **PBKDF2-SHA256 auth**,
19-
> and a **fully responsive Preact web UI** (sidebar on desktop, bottom-tab
20-
> nav on mobile).
8+
> v6.0.0 shipped a dual-device ESP-NOW master/slave architecture. Bench
9+
> testing on real U-shape and L-shape installs surfaced two structural
10+
> problems with that approach: (1) ESP-NOW round-trip jitter (5–100 ms
11+
> with retries) added visible LED lag, and (2) the LD2450's `(x, y, speed)`
12+
> target stream from a single sensor at the inside corner already covers
13+
> both arms inside its 60° cone — making the second sensor redundant.
14+
> v6.x **drops the dual-device architecture entirely** and locks the
15+
> firmware to **one ESP32-C3 + one LD2450 per install**, in preparation
16+
> for a custom PCB.
2117
>
22-
> **Recommended hardware: ESP32-S3 (DevKitC-1 or S3-Zero).** ESP32-C3 SuperMini
23-
> is supported for single-strip installs. See
24-
> [docs/HARDWARE.md](docs/HARDWARE.md) for the full board recommendation
25-
> table and known issues.
18+
> Kept from v6.0: ESP-IDF + FreeRTOS task model, OTA with rollback,
19+
> captive portal, PBKDF2-SHA256 auth, Kalman motion filter, the full
20+
> Preact web UI (now six screens — Live, LEDs, Motion, Hardware,
21+
> Network, System), and the runtime board picker.
22+
>
23+
> Removed in v6.x: the Mesh tab, ESP-NOW peer broadcast, pairing window,
24+
> coordinator election, fusion-priority modes, topology gossip, and the
25+
> LD2410-family radar drivers (LD2450 only on shipping hardware; the
26+
> `sim` driver remains for desk testing).
27+
>
28+
> **Hardware: ESP32-C3 SuperMini + LD2450.** Single-core C3 is sufficient
29+
> now that there's no peer broadcast / no coordinator state / no second
30+
> sensor to fuse with. See [docs/HARDWARE.md](docs/HARDWARE.md) for
31+
> wiring and the PCB-rev power-rail recommendations.
2632
>
2733
> | Branch / tag | Purpose |
2834
> |---|---|
29-
> | `main` | v6.0.0 — current canonical firmware (this branch) |
30-
> | `v6-idf-rewrite` | active dev branch for v6.x work (encrypted ESP-NOW, S3 dual-core, auto-topology) |
35+
> | `main` | v6.0.0 — last dual-device firmware (this branch through v6.0.0; v6.x lands on top) |
36+
> | `v6-idf-rewrite` | active dev branch — single-sensor PCB rev |
3137
> | `legacy/v5-arduino` | frozen archive of the v5.x Arduino line — reference only |
32-
> | tag `v6.0.0` | shipped release with prebuilt C3 binaries on the release page |
38+
> | tag `v6.0.0` | shipped release with prebuilt C3 binaries on the release page (last dual-device) |
3339
> | tag `v5.1.1` | last Arduino-era release |
40+
>
41+
> ⚠️ The "Multi-Sensor Networks" / "Master / Slave" / "Network Topology"
42+
> sections further down this README describe v5 + v6.0 behaviour and are
43+
> retained as historical reference. They no longer apply to v6.x.
3444
3545
If you cloned this repo before v6.0.0 landed and your local `main` still
3646
reflects the old Arduino tree, run `git fetch && git reset --hard origin/main`
@@ -69,9 +79,10 @@ your phone — the captive portal pops at `http://192.168.4.1/`. Enter
6979
home Wi-Fi creds; the device joins and is reachable as
7080
`http://ambisense-XXXX.local/`.
7181

72-
**Recommended hardware**: ESP32-S3 DevKitC-1 or S3-Zero (dual-core,
73-
native USB). **Supported**: ESP32-C3 SuperMini for single-strip installs.
74-
See [docs/HARDWARE.md](docs/HARDWARE.md) for the full table and known
82+
**Hardware**: v6.x ships on the ESP32-C3 SuperMini + LD2450. The C3 is
83+
single-core but with no peer broadcast / no second sensor it has plenty
84+
of headroom for radar UART + Kalman + WS + LED render. See
85+
[docs/HARDWARE.md](docs/HARDWARE.md) for the PCB-rev wiring and known
7586
issues.
7687

7788
VSCode users: install Espressif's ESP-IDF extension to get IntelliSense
@@ -83,7 +94,7 @@ correctly via `idf.py`.
8394

8495
| Document | Read when |
8596
|---|---|
86-
| [docs/V6-ARCHITECTURE.md](docs/V6-ARCHITECTURE.md) | Picking up the v6 rewrite cold — this captures the locked architectural decisions (peer mesh, modular radar drivers, NVS schema, board profiles). Read first before proposing any structural change. |
97+
| [docs/V6-ARCHITECTURE.md](docs/V6-ARCHITECTURE.md) | Picking up the v6 rewrite cold — captures the locked architectural decisions (single-sensor LD2450, NVS schema, board profiles). Read first before proposing any structural change. |
8798
| [docs/V6-ROADMAP.md](docs/V6-ROADMAP.md) | Planning what to build next — the 5-PR plan with status per PR and the tag/release cadence. |
8899
| [docs/HARDWARE.md](docs/HARDWARE.md) | Building or debugging hardware — reference wiring for C3 SuperMini, board profiles, sensor pinouts, and a flash-fails-to-connect troubleshooting ladder. |
89100

docs/HARDWARE.md

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,20 @@ For locked architectural decisions about which boards/sensors are
44
supported, see [`V6-ARCHITECTURE.md`](V6-ARCHITECTURE.md). This file
55
covers the practical "I have hardware in front of me" stuff.
66

7-
## Board recommendation (read this first)
7+
## Board recommendation (v6.x)
88

99
| Tier | Board | Why |
1010
| ---- | ----- | --- |
11-
| **Recommended** | **ESP32-S3 DevKitC-1** *or* **ESP32-S3-Zero** | Dual-core LX7 @ 240 MHz, native USB-OTG (no CH340 driver fights), 512 KB SRAM. Wi-Fi/HTTP can be pinned to core 0 and radar+LED+motion to core 1 — slider floods can't starve the render loop. Headroom for v6.1 features (auto-topology, encrypted ESP-NOW, larger strips). Best choice for a stairwell with mesh peers. |
12-
| **Supported** | **ESP32-C3 SuperMini** | Single-core RISC-V @ 160 MHz. The validated v6.0 reference build. Fine for **single-strip, single-device** installs. The 300 ms client-side debounced-save shipped with v6.0 prevents HTTP saturation under slider drag. Stops being the right choice the moment you want >2 mesh peers or >300 LEDs. |
13-
| **Deprecated** | ESP32 classic (WROOM-32) | Older silicon, no native USB, no advantage over S3. Profile still builds; not recommended for new installs. |
11+
| **Recommended (v6.x PCB target)** | **ESP32-C3 SuperMini** | Single-core RISC-V @ 160 MHz. With v6.x's single-sensor architecture (no peer broadcast, no second sensor to fuse) the C3 has plenty of headroom for radar UART + Kalman + LED render + Wi-Fi/HTTP on one core. The 300 ms client-side debounced-save handles slider-drag flood without saturating httpd. **This is the target board for the v6.x kit PCB.** |
12+
| **Supported** | ESP32-S3 DevKitC-1 / S3-Zero | Dual-core LX7 @ 240 MHz, native USB-OTG. Overkill for a single-sensor install but profile still builds and validates. Use if you already own one or if you want to drive >300 LEDs from a single device. |
13+
| **Deprecated** | ESP32 classic (WROOM-32) | Older silicon, no native USB, no advantage. Profile still builds. |
1414
| **Avoid** | ESP32-C6 | Single-core, *less* SRAM than C3, and Wi-Fi 6 / Thread don't help AmbiSense. |
1515

16-
If you're starting from scratch and asked us "which board do I buy" → **S3-Zero**. If you already have a C3 SuperMini on the bench → it works.
16+
**v6.0 vs v6.x recommendation:** v6.0 recommended S3 because dual-device
17+
peer mesh + per-peer fusion + ESP-NOW broadcast on a single C3 core ran
18+
hot under load. v6.x removes all of that, so the C3 — with its smaller
19+
package, native USB-Serial-JTAG, and ~$3 BOM cost — becomes the right
20+
default for a kit product.
1721

1822
## Reference wiring (ESP32-C3 SuperMini)
1923

@@ -45,21 +49,47 @@ strapping/USB-JTAG/flash pins (GPIOs 9, 11–19 on C3).
4549
- **Common ground**: tie the LED PSU's GND to the C3's GND so the
4650
data signal references correctly.
4751

48-
## Sensor reference wiring
52+
## Sensor reference wiring (LD2450 only)
4953

50-
Both LD2410 and LD2450 use 256000 baud UART, 5 V VCC, identical pinout:
54+
LD2450 uses 256000 baud UART, 5 V VCC, 3.3 V logic on TX/RX (direct
55+
connect to ESP32-C3, no level shifter needed):
5156

5257
```
53-
Sensor MCU (C3 SuperMini)
58+
LD2450 MCU (C3 SuperMini)
5459
------ ------------------
5560
TX → GPIO 20 (radar_rx)
5661
RX ← GPIO 21 (radar_tx)
5762
VCC ← 5V
5863
GND ↔ GND
64+
OUT unconnected (firmware reads everything via UART)
5965
```
6066

61-
LD2450 adds OUT pin (digital presence indicator) — leave unconnected
62-
for v6, the firmware reads everything via UART.
67+
**Sensor draw**: ~80 mA continuous on the 3.3 V logic side, with brief
68+
peaks during radar transmit bursts. The C3 SuperMini's onboard LDO can
69+
deliver this for a breadboard prototype but tends to run warm under
70+
sustained load.
71+
72+
### PCB rev: discrete LDO recommendation
73+
74+
For the v6.x custom PCB, do not feed the LD2450 from the C3's onboard
75+
3V3 pin. Use a discrete 3.3 V LDO sized for the combined C3 + radar
76+
load, feeding both rails:
77+
78+
- **AP2112K-3.3** (600 mA, $0.10) or **MIC5219-3.3** (500 mA, $0.20).
79+
- Decoupling: 10 µF ceramic on input, 10 µF + 100 nF on output, placed
80+
close to the LDO and the LD2450 VCC pin.
81+
- Star-ground the LED strip's GND return directly to the PSU (not
82+
through the PCB ground plane) — strip current can otherwise inject
83+
noise into the radar's reference.
84+
85+
### Mounting constraint (single-sensor architecture)
86+
87+
The LD2450 must have line-of-sight to **both arms** of the LED run.
88+
For an L-shape stair, mount at the inside corner. For a U-shape
89+
hallway, mount at the centre-back. The 60° horizontal cone, ~6 m
90+
range covers most residential geometries from a single sensor. For
91+
arms longer than 5 m, range-test at the far end before locking your
92+
kit configuration.
6393

6494
## Supported boards (v6.0)
6595

@@ -80,19 +110,19 @@ Profiles defined in
80110
Adding a new board = +1 entry there + a build target in
81111
`.github/workflows/firmware.yml`.
82112

83-
## Supported sensors (v6.0)
113+
## Supported sensors (v6.x)
84114

85115
| Driver id | Sensor | Targets | x/y? |
86116
| ---------- | --------------- | ------- | ---- |
87-
| `ld2410` | HiLink LD2410(B/C) | 1 | no |
88-
| `ld2412` | HiLink LD2412 | 1 | no |
89-
| `ld2420` | HiLink LD2420 | 1 (presence only) | no |
90-
| `ld2450` | HiLink LD2450 | up to 3 | yes (LD2450 only) |
91-
| `sim` | Synthetic | scripted | optional |
92-
93-
Switch sensors at runtime via the web UI without reflashing — the
94-
driver registry compiles every driver in and selects one from NVS at
95-
boot.
117+
| `ld2450` | HiLink LD2450 | up to 3 | yes |
118+
| `sim` | Synthetic | scripted | yes |
119+
120+
The v6.0 LD2410-family drivers (`ld2410`, `ld2412`, `ld2420`) were
121+
removed in v6.x — they only emit single-target distance and were
122+
intended for the dual-device fusion model that v6.x dropped. The
123+
LD2450's (x, y, speed) target stream from a single sensor at the
124+
inside corner of the LED run covers L-shape and U-shape geometries
125+
without needing a second sensor.
96126

97127
## Troubleshooting
98128

0 commit comments

Comments
 (0)