Add wiki second brain and root CLAUDE.md; retire .docs

- New wiki/ (Obsidian vault) following the LLM Wiki pattern: schema, index, log,
  entity page for the board, concept pages for the A->B link, wired+wireless
  redundancy, and Patrol gauge outputs, open questions, two sources
- New CLAUDE.md distilled from the surviving .docs content: verified pins,
  brightness/receiver/debug APIs, SquareLine rules, CH343 serial notes,
  gear-enum drift warning, Waveshare demo and schematic URLs
- Delete .docs/ (14 files): stale pin-hunting and troubleshooting guides,
  wrong header table, finished phase roadmap, duplicate UART spec (now in the
  5B repo at docs/UART_PROTOCOL.md)
- README.md repointed to CLAUDE.md and wiki/

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-09-21 10:57:05 +02:00
parent b6fb01ba73
commit 3613387d41
31 changed files with 869 additions and 3965 deletions
+1
View File
@@ -0,0 +1 @@
{}
+1
View File
@@ -0,0 +1 @@
{}
+33
View File
@@ -0,0 +1,33 @@
{
"file-explorer": true,
"global-search": true,
"switcher": true,
"graph": true,
"backlink": true,
"canvas": true,
"outgoing-link": true,
"tag-pane": true,
"footnotes": false,
"properties": true,
"page-preview": true,
"daily-notes": true,
"templates": true,
"note-composer": true,
"command-palette": true,
"slash-command": false,
"editor-status": true,
"bookmarks": true,
"markdown-importer": false,
"zk-prefixer": false,
"random-note": false,
"outline": true,
"word-count": true,
"slides": false,
"audio-recorder": false,
"workspaces": false,
"file-recovery": true,
"publish": false,
"sync": true,
"bases": true,
"webviewer": false
}
+22
View File
@@ -0,0 +1,22 @@
{
"collapse-filter": true,
"search": "",
"showTags": false,
"showAttachments": false,
"hideUnresolved": false,
"showOrphans": true,
"collapse-color-groups": true,
"colorGroups": [],
"collapse-display": true,
"showArrow": false,
"textFadeMultiplier": 0,
"nodeSizeMultiplier": 1,
"lineSizeMultiplier": 1,
"collapse-forces": true,
"centerStrength": 0.518713248970312,
"repelStrength": 10,
"linkStrength": 1,
"linkDistance": 250,
"scale": 1,
"close": true
}
+226
View File
@@ -0,0 +1,226 @@
{
"main": {
"id": "774c780921b53def",
"type": "split",
"children": [
{
"id": "954c43c42df8cdd2",
"type": "tabs",
"children": [
{
"id": "414d380b45e2466d",
"type": "leaf",
"state": {
"type": "empty",
"state": {},
"icon": "lucide-file",
"title": "New tab"
}
}
]
},
{
"id": "363779a2b8b90c3d",
"type": "tabs",
"children": [
{
"id": "0a7c7593372ec79f",
"type": "leaf",
"state": {
"type": "graph",
"state": {},
"icon": "lucide-git-fork",
"title": "Graph view"
}
}
]
}
],
"direction": "vertical"
},
"left": {
"id": "d8898dd3bdf58935",
"type": "split",
"children": [
{
"id": "7321f47172a21ff0",
"type": "tabs",
"children": [
{
"id": "d1e54c160baeb57c",
"type": "leaf",
"state": {
"type": "file-explorer",
"state": {
"sortOrder": "alphabetical",
"autoReveal": false,
"showSearch": false,
"searchQuery": ""
},
"icon": "lucide-folder-closed",
"title": "Files"
}
},
{
"id": "2ee3f5593994553a",
"type": "leaf",
"state": {
"type": "search",
"state": {
"query": "",
"matchingCase": false,
"explainSearch": false,
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical"
},
"icon": "lucide-search",
"title": "Search"
}
},
{
"id": "40c96343377ed0ae",
"type": "leaf",
"state": {
"type": "bookmarks",
"state": {
"showSearch": false,
"searchQuery": ""
},
"icon": "lucide-bookmark",
"title": "Bookmarks"
}
}
]
}
],
"direction": "horizontal",
"width": 300
},
"right": {
"id": "06f3bf565487158d",
"type": "split",
"children": [
{
"id": "c0093cbf91c471d6",
"type": "tabs",
"children": [
{
"id": "8ccd82c42c14581d",
"type": "leaf",
"state": {
"type": "backlink",
"state": {
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical",
"showSearch": false,
"searchQuery": "",
"backlinkCollapsed": false,
"unlinkedCollapsed": true
},
"icon": "links-coming-in",
"title": "Backlinks"
}
},
{
"id": "8b68e6490707c94f",
"type": "leaf",
"state": {
"type": "outgoing-link",
"state": {
"linksCollapsed": false,
"unlinkedCollapsed": true
},
"icon": "links-going-out",
"title": "Outgoing links"
}
},
{
"id": "950d623f020ec709",
"type": "leaf",
"state": {
"type": "tag",
"state": {
"sortOrder": "frequency",
"useHierarchy": true,
"showSearch": false,
"searchQuery": ""
},
"icon": "lucide-tags",
"title": "Tags"
}
},
{
"id": "666c9e1cc6cc3dbc",
"type": "leaf",
"state": {
"type": "all-properties",
"state": {
"sortOrder": "frequency",
"showSearch": false,
"searchQuery": ""
},
"icon": "lucide-archive",
"title": "All properties"
}
},
{
"id": "0acd0e2cf0259623",
"type": "leaf",
"state": {
"type": "outline",
"state": {
"followCursor": false,
"showSearch": false,
"searchQuery": ""
},
"icon": "lucide-list",
"title": "Outline"
}
}
]
}
],
"direction": "horizontal",
"width": 300,
"collapsed": true
},
"left-ribbon": {
"hiddenItems": {
"switcher:Open quick switcher": false,
"graph:Open graph view": false,
"canvas:Create new canvas": false,
"daily-notes:Open today's daily note": false,
"templates:Insert template": false,
"command-palette:Open command palette": false,
"bases:Create new base": false
}
},
"active": "414d380b45e2466d",
"lastOpenFiles": [
"pages/sedyhRU0S",
"pages/sedIT5Pq3",
"sources/sedWvixlJ",
"pages/sedybYBYo",
"pages/sedqYSTHS",
"sedvhzw6Z",
"Welcome.md",
"log.md",
"log.md.tmp.8664.194cf365eeff",
"index.md",
"index.md.tmp.8664.f6325122b3bb",
"sources/pinout-photo-details-7.md",
"sources/pinout-photo-details-7.md.tmp.8664.84fea9960617",
"sources/waveshare-wiki-esp32-s3-lcd-1-3.md",
"sources/waveshare-wiki-esp32-s3-lcd-1-3.md.tmp.8664.230b4837adb6",
"pages/open-questions.md",
"pages/open-questions.md.tmp.8664.fdfb3a9afb71",
"pages/patrol-gauge-outputs.md",
"pages/link-redundancy.md",
"pages/controller-link.md",
"pages/esp32-s3-lcd-1-3.md",
"CLAUDE.md",
"raw/ESP32-S3-LCD-1.3-details-7.jpg"
]
}
+79
View File
@@ -0,0 +1,79 @@
# Wiki Schema
This directory is a **personal knowledge wiki** for the ESP32-S3-LCD-1.3 project — Controller B, the slave/extension unit of the BMW M57N → Nissan Patrol swap display system. It is maintained by the LLM agent; the human curates sources and asks questions. Read this file before doing anything in `wiki/`.
It is the sibling of the wiki in `../../ESP32-S3-Touch-LCD-5B/wiki/` (Controller A). The two repos are separate git repositories with separate remotes. **Never create or edit files outside this repo's directory.** Cross-references into the sibling wiki are plain text, not `[[wikilinks]]` (Obsidian vaults do not link across vaults) — write them as `(sibling: 5B wiki → page-name)`.
## What this wiki is for
Domain knowledge that is NOT derivable from the firmware repo:
- Waveshare ESP32-S3-LCD-1.3 hardware: pinout, free GPIO, peripherals, power, quirks, gotchas
- The link between Controller A and Controller B: physical layer, packet contract, timing, failure modes, and the wired + BLE redundancy design
- Controller B's outputs into the Nissan Patrol: driving the cluster's RPM and coolant-temperature gauges, driver electronics, cluster behaviour
- Design decisions and their rationale; what was tried and why it was rejected
- Findings from datasheets, forum posts, Waveshare docs, bench measurements, scope traces
What does NOT belong here: code structure, build commands, firmware implementation details. The repo (its root `CLAUDE.md` and `README.md`) is the source of truth for those. The wiki may *reference* firmware facts when they matter for domain reasoning (e.g. "firmware currently times out after 1 s without a packet"), always marked `(repo)`.
Division of labour with the sibling wiki: **CAN bus decoding, the BMW engine, the donor vehicle and the swap itself live in the 5B wiki.** This wiki only records what Controller B needs from that work (which signals it consumes, which packet fields carry them). Do not duplicate CAN ID tables here — point at the sibling.
## Layout
```
wiki/
CLAUDE.md # this schema — co-evolves with the workflow
index.md # catalog of all pages, by category — update on EVERY change
log.md # append-only chronological record of ingests/queries/lints
raw/ # immutable source documents (web clips, PDFs, photos, scope captures, logs) — NEVER edit
sources/ # one summary page per raw source
pages/ # entity & concept pages (the heart of the wiki)
```
## Page conventions
- Filenames: kebab-case, e.g. `esp32-s3-lcd-1-3.md`.
- Every page starts with YAML frontmatter:
```yaml
---
type: entity | concept | source | synthesis
tags: [hardware, link, gauges, ble, ...]
updated: 2026-09-21
---
```
- Link liberally with `[[wikilinks]]`. A link to a not-yet-existing page marks future work, not an error.
- **Confidence labels are mandatory for factual claims** — this unit drives real gauges in a real vehicle:
- `(verified)` — confirmed on real hardware / with a meter or scope by the user
- `(source: X)` — from an ingested source in `raw/` (summarised in `sources/`)
- `(repo)` — what the firmware currently does (not necessarily correct!)
- `(sibling: 5B wiki → page)` — established in the Controller A wiki; check there before relying on it
- `(unverified)` — LLM prior knowledge, forum lore, or a design proposal; treat as a hypothesis
- Contradictions between sources — including between the two repos' copies of the shared protocol header — get flagged inline with a `> [!warning]` callout, not silently resolved.
## Workflows
### Ingest
1. User drops a file into `raw/` and asks to process it.
2. Read it fully. Discuss key takeaways with the user if interactive.
3. Write `sources/<name>.md`: frontmatter, 1-paragraph summary, key facts as bullets, relevance to open questions.
4. Update every affected page in `pages/` — integrate, don't append blindly. Flag contradictions.
5. Update `index.md`, append to `log.md`.
### Query
1. Read `index.md` first, then drill into relevant pages. If the question touches CAN decoding or the vehicle, also read the sibling wiki's `index.md`.
2. Synthesize an answer with citations (page links + confidence labels).
3. If the answer is durable (a comparison, an analysis, a decision), file it as a new page and index it.
### Lint (periodic, on request)
Check for: contradictions, stale claims, orphan pages, `[[links]]` to pages worth creating, unverified claims that could now be verified, drift between this repo's and the sibling repo's protocol header, gaps worth a web search. Report findings; fix with user's blessing.
## Log format
Append-only. Each entry starts with `## [YYYY-MM-DD] <op> | <title>` where `<op>` is `ingest`, `query`, `lint`, `update`, or `setup`. Greppable with `grep "^## \[" log.md`.
## Prime directives
1. `raw/` is immutable.
2. Never let an `(unverified)` claim silently upgrade itself — only real-world verification by the user promotes a claim to `(verified)`.
3. Keep `index.md` and `log.md` current on every operation; a stale index is worse than no index.
4. Nothing outside this repo directory is ever written by work on this wiki.
+27
View File
@@ -0,0 +1,27 @@
---
type: index
updated: 2026-09-21
---
# Index
Catalog of every page in the wiki. Read this first when answering questions. Keep current on every change. For CAN decoding, the BMW engine and the vehicle swap, read the sibling wiki at `../../ESP32-S3-Touch-LCD-5B/wiki/index.md` instead of duplicating here.
## Entities
- [[esp32-s3-lcd-1-3]] — Waveshare 1.3" round-display board (Controller B): specs, the **verified 16-pin header pinout** (IO1–5, IO7–14 all free-function), GPIO budget (10 clean spares), CH343 console on UART0, BLE 5
## Concepts
- [[controller-link]] — the A → B link: 23-byte UART packet @ 5 Hz, what each field really carries (oil temp is dead, RPM missing), pins (A TX = GPIO 44, B RX = IO1), the **RS485-vs-TTL physical-layer question**, and the **gear-enum drift** between the two repos
- [[link-redundancy]] — design space for wired + wireless redundancy: RS485 vs TTL, BLE GATT vs ESP-NOW, failover policy on B, and why A must always transmit on both paths
- [[patrol-gauge-outputs]] — driving the Patrol cluster's tachometer (variable frequency) and coolant gauge (variable duty) from B's LEDC on IO7/IO8; the external driver stage; what must be measured on the cluster first
## Synthesis
- [[open-questions]] — the research frontier: how the wire is really connected, which gear enum is right, which Patrol cluster, RPM field, BLE vs ESP-NOW, gauge behaviour on link loss, vehicle power, missing environmental specs
## Sources
- [[waveshare-wiki-esp32-s3-lcd-1-3]] — Waveshare product wiki (condensed fetch 2026-09-21, not a verbatim clip); core spec, CH343, PL4054/ME6217 power, BLE 5; silent on pins and environmental limits
- [[pinout-photo-details-7]] — Waveshare annotated header photo (`raw/ESP32-S3-LCD-1.3-details-7.jpg`); the authoritative pinout, contradicts the repo's wiring guide
+19
View File
@@ -0,0 +1,19 @@
# Log
Append-only. `grep "^## \[" log.md | tail -5` for recent activity.
## [2026-09-21] setup | Wiki instantiated
Created schema (`CLAUDE.md`, modelled on the sibling 5B wiki with a sibling-reference convention and a no-files-outside-this-repo directive), `index.md`, `log.md`, and four seed pages from repo knowledge plus the day's investigation: [[esp32-s3-lcd-1-3]], [[controller-link]], [[link-redundancy]], [[patrol-gauge-outputs]], [[open-questions]]. Two sources: [[pinout-photo-details-7]] (photo copied from `.docs/` into `raw/`) and [[waveshare-wiki-esp32-s3-lcd-1-3]] (condensed web fetch, flagged for a verbatim re-clip). Deleted Obsidian's default `Welcome.md`.
Findings recorded during setup:
- Header pinout verified from the photo: IO1–5 and IO7–14, 13 free-function GPIOs; the wiring guide's IO35–42 table is wrong.
- Controller A cannot drive the Patrol gauges (no free native GPIO; DO terminals are I2C-expander + optocoupler). B can, via LEDC on IO7/IO8 — proposal only.
- A transmits on GPIO 44 (code), not 43 (two stale docs). GPIO 44 leaves the 5B only as an RS485 A/B pair — how that reaches B's IO1 is unknown and is now open question #1.
- The two repos' `gear_position_t` enums have drifted (Sport/Manual vs M1–M6 at values 4+). Open question #2.
- The packet has no RPM field; A has RPM verified from CAN 0x0AA. `engine_oil_temp` has no real source on this engine.
- Redundancy design space captured (RS485 / BLE GATT / ESP-NOW; failover on B; A transmits on both paths always). Nothing decided.
## [2026-09-21] update | .docs folder retired; root CLAUDE.md created
The repo's `.docs/` folder (14 files) was deleted (user decision). Its still-true content — verified display pins, brightness API, SquareLine export rules, CH343 serial notes, link facts — was distilled into a new root `CLAUDE.md`; the stale parts (backlight on GPIO 2/15, SPI on 10/11, native USB-CDC, the IO35–IO42 header table, the phase roadmap, the pin-hunting guides) were dropped. `UART_PROTOCOL.md` now exists only in the 5B repo at `docs/UART_PROTOCOL.md`. `README.md` repointed to `CLAUDE.md` and `wiki/`. Wiki citations that named `.docs/` files were reworded to "former … (deleted 2026-09-21)"; [[open-questions]] wishlist gained the Waveshare schematic and demo-zip URLs recovered from the old troubleshooting doc. No page content changed otherwise.
+64
View File
@@ -0,0 +1,64 @@
---
type: concept
tags: [link, uart, protocol, architecture]
updated: 2026-09-21
---
# Controller Link (A → B)
The system is two ESP32-S3 boards. Controller A (Waveshare ESP32-S3-Touch-LCD-5B, sibling repo) reads the BMW PT-CAN bus and owns all decoding; Controller B ([[esp32-s3-lcd-1-3]], this repo) is a **slave / extension**: it consumes a compact packet, displays it, and will drive the Patrol gauges from it ([[patrol-gauge-outputs]]).
```
BMW PT-CAN ──▶ Controller A (5B) ──UART 5 Hz──▶ Controller B (1.3)
╰── BLE (planned, redundant) ──╯ → [[link-redundancy]]
```
Architecture rule: **B never touches CAN.** Anything B needs must be put into the packet by A. See `(sibling: 5B wiki → dual-controller-architecture)` for A's view of the same link.
## Wire-level contract (repo, both repos' `include/protocol/automotive_data.h` and `docs/UART_PROTOCOL.md` (5B repo))
- 115200 8N1, 3.3 V TTL, one direction A → B, 5 Hz (every 200 ms)
- Frame: `0xAA` · version `0x01` · length `0x12` · 18-byte payload · XOR checksum · `0x55` = **23 bytes**
- Payload (little-endian): `packet_id` u8 · `timestamp_ms` u32 · `gear_position` u8 · `gearbox_oil_temp` i16 (0.1 °C) · `engine_oil_temp` i16 (0.1 °C) · `coolant_temp` i16 (0.1 °C) · `battery_voltage` u16 (0.01 V) · `fault_codes` u16 bitmap · `valid_flags` u8 · `debug_enabled` u8
- B declares the link **lost after 1000 ms** without a valid packet and shows a no-data state `(repo)`; A only transmits while its CAN task is running (CAN toggle ON → UART auto-starts) `(repo)`
### What each field actually carries today (sibling: 5B wiki → can-id-candidates)
| Field | Source on A | Status |
|---|---|---|
| `coolant_temp` | CAN 0x1D0 byte 0, raw − 48 | verified live |
| `gearbox_oil_temp` | CAN 0x0B5 byte 7, raw − 40 | verified live |
| `engine_oil_temp` | CAN 0x1D0 byte 1 | **dead — sensor not fitted on this M57N, reads 0xFF**; B will never get a real value |
| `gear_position` | CAN 0x1D2 lever/mode + 0x0BA target gear | verified live |
| `battery_voltage` | CAN 0x3B4, 12-bit × 0.015 V | verified live |
| `fault_codes` | A's own derived faults (bit 0 = lever vs gearbox mismatch), **not** DDE DTCs | `(repo)` |
| RPM | **not in the packet** — A has it verified from CAN 0x0AA but the protocol has no field | needed by [[patrol-gauge-outputs]] |
## Pins
- A transmits on **GPIO 44** (`uart_manager.cpp`, `UART_TX_PIN 44`) `(repo)`; RX 43 unused
- B receives on **IO1** (left header, pin 4), TX IO2 unused `(repo)`
> [!warning] Two docs said A transmits on GPIO 43 (both fixed or deleted 2026-09-21)
> The 5B repo's root `CLAUDE.md` (corrected 2026-09-21) and this repo's former `.docs/UART_WIRING_GUIDE.md` (deleted 2026-09-21) both said "GPIO 43 TX". The 5B firmware and `docs/UART_PROTOCOL.md` (5B repo) say **44**. The code wins `(repo)`.
> [!warning] GPIO 44 on the 5B is not a bare pin — it feeds an RS485 transceiver
> On the 5B schematic, IO44 is the `RS485_TXD` net into an SP3485 with automatic direction control, and only the differential **A/B pair** reaches the terminal block `(sibling: 5B wiki → esp32-s3-touch-lcd-5b)`. Both wiring guides describe a direct "GPIO 44 → IO1 + GND" TTL wire, which the 5B does not physically expose. So either (a) the RS485 A line is being fed straight into B's TTL input and happens to work, (b) there is an RS485→TTL module on the B side that the docs don't mention, or (c) the wire is soldered to the module pin. **Which one is true is unknown** `(unverified)` and it decides how robust the wired link is in the car → [[open-questions]] #1, [[link-redundancy]].
## Protocol drift between the two repos
> [!warning] The `gear_position_t` enums differ `(repo, 2026-09-21)`
> - **B's header** (matches `docs/UART_PROTOCOL.md` (5B repo)): 0 P · 1 R · 2 N · 3 D · **4 Sport · 5 Manual** · 6–13 M1–M8 · 14 Error
> - **A's header** (rewritten during CAN decoding): 0 P · 1 R · 2 N · 3 D · **4–9 M1–M6** · 0xFF Unknown
>
> Same byte on the wire, different meanings: a value of 4 is "Sport" to B and "1st gear" to A. One side must be changed and `PACKET_VERSION` bumped. Which side is correct depends on what A's CAN parser actually emits now — check its `can_driver.cpp` before touching B.
Also note A's protocol header now says all CAN IDs are 11-bit and the old placeholder map is dead; B's copy of the header still carries the placeholder CAN section. Harmless (B never parses CAN) but confusing — strip it when the enums are reconciled.
## Change discipline
Any new signal (RPM first) means, in order: add the field and a `valid_flags` bit on A → bump `PACKET_VERSION` → copy the header to B → B rejects packets with an unexpected version → B's UI/gauge code consumes the field. The version byte exists precisely so a stale B fails loudly instead of misreading bytes.
## Related
[[esp32-s3-lcd-1-3]] · [[link-redundancy]] · [[patrol-gauge-outputs]] · [[open-questions]]
+76
View File
@@ -0,0 +1,76 @@
---
type: entity
tags: [hardware, waveshare, display, gpio]
updated: 2026-09-21
---
# Waveshare ESP32-S3-LCD-1.3
Controller B of the [[controller-link]] — the compact secondary unit. Receives the sensor stream from Controller A, shows it on a 1.3" round-masked display, and is the board chosen to drive the Patrol cluster gauges ([[patrol-gauge-outputs]]) because it is the only one of the two with free hardware-PWM pins on a header.
## Specs (source: waveshare-wiki-esp32-s3-lcd-1-3)
- ESP32-S3R8: Xtensa LX7 dual-core @ 240 MHz, 512 KB SRAM, 384 KB ROM
- 16 MB external flash, 8 MB PSRAM (firmware builds with `qio_opi` memory type `(repo)`)
- 1.3" IPS LCD, 240×240, 262K colour, ST7789VW over SPI; the "round" look is a software circular mask `(repo)`
- QMI8658 six-axis IMU (accelerometer + gyro) on I2C — pins not stated by the wiki; unused by firmware `(repo)`
- TF card slot — pins not stated by the wiki; unused by firmware `(repo)`
- 2.4 GHz Wi-Fi 802.11 b/g/n + **Bluetooth 5 (BLE)**, onboard ceramic patch antenna — the basis of the BLE half of [[link-redundancy]]
- USB Type-C with a **CH343 USB-serial bridge** (WCH-CH343DS1), not native USB-CDC. Debug `Serial` therefore rides UART0 `(repo)`
- Power: 5 V over USB-C; MX1.25 single-cell LiPo connector with PL4054 charger and charge LED; ME6217C33M5G 3.3 V LDO rated 800 mA max
- "16PIN GPIO lead-out" = the two 8-pin headers below
- Operating temperature, power draw, dimensions and weight: **not stated** on the product wiki `(source: waveshare-wiki-esp32-s3-lcd-1-3)` → [[open-questions]]
## Header pinout (verified from the Waveshare pinout photo, [[pinout-photo-details-7]])
Two 8-pin 2.54 mm headers, one per side, viewed with the USB-C at the top:
| Left header (top→bottom) | Right header (top→bottom) |
|---|---|
| 5V | IO14 |
| GND | IO13 |
| 3V3 (OUT) | IO12 |
| IO1 | IO11 |
| IO2 | IO10 |
| IO3 | IO9 |
| IO4 | IO8 |
| IO5 | IO7 |
Waveshare marks every one of the 13 GPIOs as UART / PWM / I2S / ADC / I2C / SPI capable — i.e. plain ESP32-S3 pins routed through the GPIO matrix, no fixed function.
> [!warning] The former `.docs/UART_WIRING_GUIDE.md` (deleted 2026-09-21) listed a 13-pin header carrying IO35–IO42 `(repo)`. That is wrong: IO38–IO42 are the display's SPI lines and never reach a header, and IO35–37 are the OPI PSRAM bus. The photo is the authoritative pinout.
## GPIO budget
Internally committed `(repo)`:
| GPIO | Function |
|---|---|
| 40 / 41 | LCD SCLK / MOSI |
| 38 / 39 / 42 | LCD DC / CS / RST |
| 20 | LCD backlight, LEDC PWM 0–255 (default 128) |
| 43 / 44 | UART0 to the CH343 USB bridge = debug console `(unverified — inferred from the CH343 being on UART0)` |
| 35–37 | OPI PSRAM `(unverified — standard for R8 modules)` |
Header GPIOs and their current use `(repo)`:
| GPIO | Use today | Note |
|---|---|---|
| IO1 | UART1 RX from Controller A | keep |
| IO2 | UART1 TX (link is receive-only, so idle) | effectively free |
| IO3 | free | S3 strapping pin (JTAG select) — avoid |
| IO4, IO5 | free | |
| IO7–IO14 | free | proposed home of the gauge outputs → [[patrol-gauge-outputs]] |
Net: **10 clean, unconstrained GPIOs** (IO4, IO5, IO7–IO14) plus IO2 and IO3 with caveats.
## Firmware-side facts worth knowing (repo)
- Display driven by LovyanGFX 1.1 + LVGL 8.4.0, 80 MHz SPI write; LVGL task on Core 1, UART receiver on Core 0
- Warning thresholds baked in: coolant 110 °C, engine oil 130 °C, gearbox oil 130 °C, battery below 11.0 V
- Link considered lost after 1000 ms without a valid packet → [[controller-link]]
- Original implementation guide proposed the link on GPIO 43/44, which would have collided with the CH343 console; the shipped firmware moved it to IO1 `(repo)`
## Related
[[controller-link]] · [[link-redundancy]] · [[patrol-gauge-outputs]] · [[waveshare-wiki-esp32-s3-lcd-1-3]] · [[pinout-photo-details-7]] · [[open-questions]]
+42
View File
@@ -0,0 +1,42 @@
---
type: concept
tags: [link, ble, redundancy, design, esp-now]
updated: 2026-09-21
---
# Link Redundancy: wired + wireless
Stated goal (user, 2026-09-21): connect B to A "through some serial or BLE, or maybe a combination of both as redundant in case the wired connection is lost." This page is the design space. **Nothing here is decided or verified** — every item is `(unverified)` unless labelled otherwise.
## Why redundancy matters more once B drives gauges
Today a lost link only blanks a secondary display. Once B drives the cluster's tachometer and coolant gauge ([[patrol-gauge-outputs]]), a lost link means the driver's primary instruments go dead or, worse, freeze at the last value. The failover policy on B must therefore also define what the gauges do during an outage (drop to zero, hold with a warning, or sweep to a "no data" position).
## Transport options
| Transport | Pros | Cons | Notes |
|---|---|---|---|
| **UART TTL, direct wire** (today) | trivial, 23 bytes @ 5 Hz is nothing | 3.3 V single-ended over a car harness is noise-prone and has no ground-offset tolerance | Fine on the bench; questionable in a vehicle over more than a few cm |
| **RS485 pair** | differential, automotive-grade noise immunity, tens of metres; **A already has an SP3485 on its terminal block** | B has no transceiver — needs a 3.3 V MAX3485/SP3485 module on IO1 (+ a free GPIO if the module lacks auto-direction) | This may already be what is wired — see the physical-layer question in [[controller-link]] |
| **BLE 5 GATT** (A = peripheral notifying, B = central) | both boards have BLE 5 `(source: waveshare-wiki-esp32-s3-lcd-1-3)`; connection-oriented, so B gets an explicit disconnect event; notify payload of 23 bytes fits one packet | connection setup/reconnect takes hundreds of ms to seconds; BLE stack costs RAM on both ends (NimBLE is the lighter choice on Arduino-ESP32); A's Core 0 already runs Wi-Fi scanning + CAN + UART, and Wi-Fi/BLE coexistence on one radio can add jitter | The user's stated candidate |
| **ESP-NOW** | connectionless, ~ms latency, no pairing state, trivially broadcast the same 23-byte frame; both are ESP32-S3 so it is a one-call API | Wi-Fi-based, so it shares the radio with A's Wi-Fi scanning; no link-layer "disconnected" event — liveness must come from the existing 1 s timeout | Worth benchmarking against BLE before committing; simpler failover semantics |
## Failover design sketch
1. B keeps **one** packet consumer. Every transport (UART, BLE/ESP-NOW) feeds validated `automotive_data_t` frames into the same queue, tagged with a source id.
2. Deduplicate on `packet_id` + `timestamp_ms` (both already in the payload) so a frame arriving on both paths is applied once.
3. **Prefer wired** when both are alive; fall to wireless when the wired path has been silent > N ms (N smaller than the display's 1000 ms lost-link threshold, e.g. 400 ms = two missed frames).
4. Show the active source on the display (small glyph) so a silently degraded wire is noticed on the bench, not in traffic.
5. Gauge behaviour during a total outage is a separate decision → [[open-questions]].
A-side implication: A must transmit on both paths simultaneously, always — not "switch to BLE when UART fails", because A cannot tell that B stopped hearing it (the link is one-way). Simultaneous transmit is cheap at 5 Hz.
## Open decisions
- BLE vs ESP-NOW for the wireless leg (latency, reconnect behaviour, RAM on A).
- Whether the wired leg becomes RS485 end-to-end (probably yes if the run is longer than a dash-panel jumper).
- Whether B should ever talk back (ACK/heartbeat) — would let A alarm on a dead B, at the cost of the current one-way simplicity.
## Related
[[controller-link]] · [[patrol-gauge-outputs]] · [[esp32-s3-lcd-1-3]] · [[open-questions]]
+45
View File
@@ -0,0 +1,45 @@
---
type: synthesis
tags: [meta, todo]
updated: 2026-09-21
---
# Open Questions
The research frontier for Controller B. Answering any of these should trigger updates across the wiki. Ordered roughly by how much they block progress.
## Blocking
1. **How is the wired link physically connected today?** The 5B's GPIO 44 only leaves the board as an RS485 A/B pair through an SP3485, yet both wiring guides describe a direct TTL wire into IO1. Is the RS485 A line going straight into IO1, is there an RS485→TTL module on B, or is it soldered to the module? Decides whether the wired leg is trustworthy in the car and what [[link-redundancy]] has to cover. → [[controller-link]]
2. **Which `gear_position_t` enum is correct?** A's and B's protocol headers disagree on values 4–13 (Sport/Manual vs M1–M6). Check what A's CAN parser emits, fix the other side, bump `PACKET_VERSION`. → [[controller-link]]
3. **Which Nissan Patrol cluster, and what does its tach input expect** (signal source, pulses per rev, pull-up voltage)? Fixes the frequency range for the tachometer output. → [[patrol-gauge-outputs]]
## Active
4. **Add `engine_rpm` to the packet.** A has RPM verified from CAN 0x0AA `(sibling: 5B wiki → can-id-candidates)` but the protocol carries no RPM field. Needed before the tachometer can be driven. → [[controller-link]]
5. **BLE GATT or ESP-NOW for the wireless leg?** Benchmark reconnect time, latency and RAM cost on A (whose Core 0 already runs Wi-Fi + CAN + UART). → [[link-redundancy]]
6. **Gauge behaviour on link loss** — zero, hold + warn, or sweep to a "no data" mark? A safety/UX decision the user must make. → [[link-redundancy]]
7. **Temp sender resistance curve** as seen by the gauge, for the °C → duty lookup. → [[patrol-gauge-outputs]]
8. **Does `engine_oil_temp` stay in the packet?** Its CAN source reads 0xFF on this engine (sensor not fitted). B currently reserves screen space and a warning threshold for it `(repo)`. Drop it, or repurpose the slot.
## Hardware
9. **Operating temperature and power draw are not on Waveshare's product wiki** for this board `(source: waveshare-wiki-esp32-s3-lcd-1-3)`. The 5B's spec is 0–65 °C; assume similar until a datasheet says otherwise. Dashboard mounting in a Patrol will see both extremes.
10. **Vehicle power for B.** The board takes 5 V USB or a LiPo — no wide-input regulator like the 5B has. Needs an automotive 12 V → 5 V buck with transient protection, or a 5 V feed from A `(unverified)`.
11. **IMU and TF-card GPIOs** are not stated on the product wiki. Irrelevant unless a future feature wants them, but they might share pins with the header (unlikely — the header GPIOs are IO1–5, IO7–14).
12. **Is IO3 safe to use as an output?** It is a strapping pin on the S3; avoided for now.
## Answered
- ~~Does the 1.3 have free PWM-capable GPIO?~~ → **Yes, 13 on the headers** (IO1–5, IO7–14), 10 fully free today. (verified from pinout photo, 2026-09-21) → [[esp32-s3-lcd-1-3]]
- ~~Could the 5B drive the gauges itself?~~ → **No.** All native GPIO consumed; its DO terminals go through an I2C expander + optocoupler and cannot carry hardware PWM. (schematic reviewed 2026-09-21) → [[patrol-gauge-outputs]]
- ~~Which GPIO does A transmit on?~~ → **GPIO 44** per A's firmware; the "43" in two docs is stale. `(repo)` → [[controller-link]]
- ~~Is the header IO35–IO42 as the wiring guide says?~~ → **No**, that table is wrong; see the photo. (verified, 2026-09-21)
## Sourcing wishlist
- Waveshare **schematic PDF** for ESP32-S3-LCD-1.3 (`https://files.waveshare.com/wiki/ESP32-S3-LCD-1.3/ESP32S3_1.3inch.pdf`; demo code zip `https://files.waveshare.com/wiki/ESP32-S3-LCD-1.3/ESP32-S3-LCD-1.3-Demo.zip`) — would settle the IMU/TF pins, confirm the CH343 on UART0, and show the backlight and battery circuits
- A **verbatim Obsidian web clip** of the Waveshare product wiki into `raw/` (the current source page is from a condensed fetch, not a full clip)
- Nissan Patrol **cluster wiring diagram** for the target generation — tach input and temp sender pins
- Scope capture of the original Patrol tach signal at idle and a known RPM, if the original engine's cluster wiring still exists
- Datasheet or Waveshare note on the board's operating temperature range
+49
View File
@@ -0,0 +1,49 @@
---
type: concept
tags: [gauges, pwm, ledc, nissan-patrol, hardware, design]
updated: 2026-09-21
---
# Driving the Patrol Cluster Gauges
Goal (user, 2026-09-21): generate signals from Controller B to drive the Nissan Patrol instrument cluster's **RPM (tachometer)** and **engine coolant temperature** gauges, fed by the BMW data that arrives over the [[controller-link]].
## Why B and not A
Controller A (5B) has no free native GPIO on any header: the RGB LCD, I2C, CAN, RS485, USB and PSRAM consume every pin, and its two "DO" terminals are optocoupled outputs driven through a CH422G I2C expander — no hardware timer can reach them `(sibling: 5B wiki → esp32-s3-touch-lcd-5b; schematic reviewed 2026-09-21)`. B exposes 13 free GPIOs on headers ([[esp32-s3-lcd-1-3]]), all usable by the ESP32-S3 LEDC peripheral.
## Two very different signals
| Gauge | What the cluster expects | What B must generate | Status |
|---|---|---|---|
| Tachometer | a pulse train whose **frequency** tracks engine speed; the source and pulses-per-revolution depend on the cluster variant | variable-frequency square wave at ~50 % duty, on one LEDC channel with its **own timer** | source data (RPM from CAN 0x0AA) verified on A `(sibling: 5B wiki → can-id-candidates)`; **not yet in the packet** |
| Coolant temp | a moving-coil/bimetal gauge that reads the **resistance to ground** of the sender | fixed-frequency PWM with variable **duty** into a low-side switch, so the gauge integrates it as an average resistance | coolant already in the packet as 0.1 °C |
The two need separate LEDC timers because one varies frequency and the other varies duty. ESP32-S3 LEDC has 8 channels on 4 timers `(unverified — datasheet figure from memory, confirm)`.
## Proposed pin assignment (unverified — proposal only)
- **IO7** → tachometer pulse output
- **IO8** → coolant gauge PWM output
Both on the right header, adjacent to GND-free pins, so add a ground wire from the left header. IO3 deliberately avoided (strapping pin). IO1 stays the UART RX.
## Electrical interface — mandatory external stage (unverified)
3.3 V logic drives neither gauge directly.
- **Tach input**: Patrol clusters expect roughly 12 V-level pulses (ignition-coil negative or ECU tach output, open-collector with the cluster's internal pull-up). Use an NPN or logic-level N-MOSFET as an open-collector pulling the tach wire to ground; if the cluster has no internal pull-up, add one to +12 V (a few kΩ). Never feed 12 V back into IO7.
- **Temp gauge**: sender wire goes to ground through the sender's thermistor. Emulate it with a logic-level N-MOSFET (or NPN) pulling the sender wire to ground under PWM, plus a series resistor sized so 100 % duty corresponds to the hottest resistance you want to show. The gauge's thermal/mechanical lag averages the PWM; use a few hundred Hz to 1 kHz so nothing flickers. Calibration is a lookup table from °C → duty, built empirically against the needle.
- Optocouplers between B and the 12 V cluster side are cheap insurance; the 5B's own DO stage (PC817 → transistor) is a reasonable pattern to copy.
## What must be established before any of this is wired
1. **Which Patrol cluster** (Y60/Y61, petrol vs diesel). Diesel clusters were fed from the alternator W-terminal at a much higher frequency and often have a calibration trimmer; petrol clusters expect ~3 pulses/rev for a 6-cylinder from the ignition system `(unverified)`. This fixes the frequency range and therefore the LEDC resolution/prescaler. → [[open-questions]]
2. Whether the cluster's tach input has an internal pull-up, and to what voltage (meter it).
3. The temp sender's resistance-vs-temperature curve as the gauge sees it (meter the original sender at cold/hot, or sweep a pot until the needle sits at known marks).
4. Protocol change: add `engine_rpm` (u16, 1/min) and a `valid_flags` bit to the packet; bump the version on both repos → [[controller-link]].
5. The outage policy: what the needles do when the link is lost → [[link-redundancy]].
## Related
[[esp32-s3-lcd-1-3]] · [[controller-link]] · [[link-redundancy]] · [[open-questions]]
Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB

+30
View File
@@ -0,0 +1,30 @@
---
type: source
tags: [hardware, waveshare, pinout, gpio]
updated: 2026-09-21
raw: raw/ESP32-S3-LCD-1.3-details-7.jpg
---
# Waveshare pinout photo (details-7)
`raw/ESP32-S3-LCD-1.3-details-7.jpg` — Waveshare's annotated product photo of the board's two side headers, copied from this repo's former `.docs/` (deleted 2026-09-21) on 2026-09-21. Original URL: `https://www.waveshare.com/img/devkit/ESP32-S3-LCD-1.3/ESP32-S3-LCD-1.3-details-7.jpg`.
## What it shows (verified by reading the image, 2026-09-21)
Board viewed with the USB-C connector at the top. Two 8-pin headers:
- **Left, top→bottom:** 5V · GND · 3V3(OUT) · IO1 · IO2 · IO3 · IO4 · IO5
- **Right, top→bottom:** IO14 · IO13 · IO12 · IO11 · IO10 · IO9 · IO8 · IO7
Each GPIO is tagged with the capability badges UART · PWM · I2S · ADC · I2C · SPI — i.e. no pin on the headers has a fixed function.
Also visible: the ESP32-S3 module, a Winbond flash chip, the TF card slot on the front face, and a battery/charge connector at the top.
## Relevance
- The authoritative header pinout; it **contradicts** the IO35–IO42 table in the former `.docs/UART_WIRING_GUIDE.md` `(repo)` → [[esp32-s3-lcd-1-3]]
- Proves there are 13 free-function GPIOs, which is what makes B the gauge driver → [[patrol-gauge-outputs]]
## Related
[[esp32-s3-lcd-1-3]] · [[waveshare-wiki-esp32-s3-lcd-1-3]]
@@ -0,0 +1,39 @@
---
type: source
tags: [hardware, waveshare, datasheet]
updated: 2026-09-21
url: https://www.waveshare.com/wiki/ESP32-S3-LCD-1.3
---
# Waveshare product wiki — ESP32-S3-LCD-1.3
> [!note] Not a verbatim clip
> This page was produced from a condensed web fetch on 2026-09-21, not from a full Obsidian web clip in `raw/`. Numbers below are as quoted by the fetch. The product wiki's tables (pin definitions, dimensions, demo pin maps) were **not** captured — re-clip the page verbatim into `raw/` to complete the ingest. → [[open-questions]] sourcing wishlist.
Official Waveshare page for the board. Confirms the core spec, the CH343 USB bridge, the battery circuit, BLE 5, and the "16-pin GPIO" lead-out, but is silent on almost every pin assignment and on environmental limits.
## Key facts
- MCU: ESP32-S3R8, Xtensa LX7 dual-core up to 240 MHz; 512 KB SRAM, 384 KB ROM
- 16 MB flash, 8 MB PSRAM
- 1.3" LCD 240×240, 262K colour, ST7789VW; backlight controllable
- QMI8658 six-axis IMU — I2C pins **not stated**
- TF card slot — pins **not stated**
- RGB LED mentioned — pin **not stated**
- USB-serial bridge: WCH CH343 (CH343DS1_V16), Type-C "USB & UART"; automatic download circuit
- Power: MX1.25 LiPo connector, PL4054 charger with charge LED, 3.7–4.2 V cells; ME6217C33M5G LDO, 800 mA max
- Wireless: 2.4 GHz Wi-Fi b/g/n + Bluetooth 5 (BLE), onboard ceramic patch antenna
- "Lead out the 16PIN GPIO pin" — consistent with the two 8-pin headers in [[pinout-photo-details-7]] (3 power pins + 13 GPIO)
- Reset button on board; boot-mode entry **not stated**
- Operating temperature, power draw, dimensions, weight: **not stated**
- Sold as bare board, with plastic case, or with case + prism cube
## Relevance
- Establishes BLE 5 on B, the wireless half of [[link-redundancy]]
- Establishes CH343 on UART0 as the reason the link cannot use GPIO 43/44 on B → [[esp32-s3-lcd-1-3]]
- Raises the missing-environmental-spec and vehicle-power questions → [[open-questions]] #9, #10
## Related
[[esp32-s3-lcd-1-3]] · [[pinout-photo-details-7]]