Commit Graph

1 Commits

Author SHA1 Message Date
David Montero Crespo 3197935461 feat: add ESP32 + ngspice co-simulation E2E tests
Three new end-to-end tests that combine ESP32 QEMU emulation (via backend
WebSocket) with ngspice-WASM analog circuit solving:

1. test_esp32_spice_analog.mjs — voltage divider sweep
   - Compiles a sketch that reads analogRead(34)
   - Solves two voltage dividers with ngspice (R1/R2=10k/10k then 10k/30k)
   - Injects solved V(mid) into ESP32's ADC via esp32_adc_set
   - Verifies Serial output matches within +-50 counts (12-bit ADC)
   - Confirms circuit change is detected (different ADC values)

2. test_esp32_spice_ntc_bridge.mjs — Wheatstone bridge temperature sweep
   - NTC thermistor in a bridge (0C / 25C / 50C)
   - ngspice solves the bridge for each temperature
   - ESP32 reads both legs (ADC34+ADC35), computes R_ntc and T via beta model
   - Verifies temperature within +-5C tolerance across sweep

3. test_esp32_spice_smoke.mjs — ngspice-only smoke test (no backend needed)

Also adds eecircuit-engine to test/backend/e2e/package.json.

Prerequisites: backend on localhost:8001 with esp32 core installed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 23:28:47 -03:00