You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto-generated by opencode agent. Append on each change. Never delete — only append or replace Current State.
Project Overview
Carputer subsystem: an ESP32-WROOM-32 PCB that taps Toyota 5S-FE ECU signals (sensors + DTC diagnostics) and drives body relays (door locks, windows, HVAC, etc.) via 2× ULN2003A. Also houses a Python-based "PCB Designer AI Agent" (pcbai) for automated KiCad footprint generation.
File Manifest
File
Lines
Purpose
src/main.cpp
570
ESP32 firmware: sensor reads, UDP comms, DTC state machine
build_plan.md
139
Active PCB build plan: THT axial, DevKit V1, 160×120mm
PCB_PLAN.md
373
Superseded — original SMD-based PCB design doc
voltage_divider_circuit.txt
202
Circuit description: dividers, senders, doors, DTC, test proc
5SFE_ECU_Pinout.txt
131
Toyota 5S-FE ECU connector pinout + signal mapping
Circuit design (electrical): All 6 voltage dividers, 2 sender pullups, 4 door inputs, DTC transistor base resistors, power supply — unchanged, applicable to both PCB versions
build_plan.md: Active PCB build plan documented — THT axial resistors, DevKit V1 ESP32s, WAGO connectors, external DC-DC module, 160×120mm board
🏗️ In Progress — KiCad PCB (carputermodule.kicad_pcb)
No nets assigned yet (only net 0), no traces, no copper pour
File is being used for the THT build plan (not the old SMD design)
⚠️ File was corrupted by iterative script runs, restored from backup — clean 2387-line base with 7 REF** footprints ready for one-shot generation
📚 Lessons Learned — KiCad s-expression Generation
ALWAYS parse then manipulate then serialize — never generate .kicad_pcb files via string concatenation. Use sexp_parser.py from kicad-happy (/home/devkid/Downloads/kicad-happy-main/skills/kicad/scripts/sexp_parser.py) to build a parse tree, edit it, then write a serializer.
ALL strings must be quoted in canonical KiCad output — "F.Cu", "U2", "*.Cu", "through_hole". Unquoted atoms are parser-dependent and should never be written.
One-shot write() over iterative script — appending to the file corrupts it on re-runs. Write the complete file in one call.
Idempotency via sentinel — if a script must modify an existing file, check for a sentinel string to detect prior runs and skip changes.
🚧 Scaffolded / Not Yet Implemented
pcbai Python package: pyproject.toml exists, tests exist, but src/pcbai/ source directory does not exist.
Missing: src/pcbai/__init__.py, core/config.py, core/logger.py, llm/provider.py, steps/footprint_generator.py, steps/footprint_qfn_qfp.py, pipeline/cli.py, etc.
Tests import from pcbai.steps.footprint_generator and pcbai.steps.footprint_qfn_qfp — these modules must be created to pass tests
Body controller firmware: Referenced (esp32_body_controller) — separate repo
⏸️ Superseded / Deprecated
PCB_PLAN.md: Original SMD-based PCB design (0805 resistors, bare WROOM-32 modules, RPM3.3-3.0 DC-DC) — superseded by build_plan.md. Retained for reference (circuit concepts still valid).
esp32_sensor_module_bom.csv: SMD BOM, superseded by the THT parts list in build_plan.md.
carputermodule.kicad_pcb: Original KiCad PCB (130×80mm SMD layout) — not compatible with new 160×120mm THT build plan.
Decision Log
Date
Decision
Rationale
2026-06-03
Agent memory file created as PROJECT_MEMORY.md in esp32_sensor_module dir
Keeps state co-located with the code it describes; task-level granularity for log entries
PCB state audited: 7 THT footprints placed in carputermodule.kicad_pcb (U2, U3, 3× WAGO, J5, J6). Board outline, resistors, caps, nets all still missing — file is being repurposed from old SMD design to new THT build plan
PROJECT_MEMORY.md (updated)
2026-06-03
generate_pcb.py written to programmatically add remaining components — multiple bugs discovered: q() quoting too permissive, stanza() doesn't handle multi-line children, kv() doesn't quote string values. File corrupted by iterative runs, restored from .corrupted backup 3×