System Requirements Specification
Document ID: SRS-ESP32-DISTANCE
Version: 1.0
Date: 2025-07-24
Author: ESP32 Distance Project Team
Document Purpose
This document specifies the high-level system requirements for the ESP32 Distance Sensor project, following OpenFastTrack (OFT) methodology for requirements engineering and traceability.
System Overview
The ESP32 Distance Sensor system is an IoT device that:
- Measures distance using HC-SR04 ultrasonic sensor
- Displays distance on WS2812 LED strip
- Provides WiFi connectivity and web interface
- Supports runtime configuration and monitoring
Requirements Traceability
Requirement ID | Design Reference | Priority |
---|---|---|
REQ-SYS-1 | DSN-SYS-1 | Mandatory |
REQ-SYS-2 | DSN-SYS-2 | Mandatory |
REQ-SYS-3 | DSN-SYS-3 | Mandatory |
REQ-SYS-4 | DSN-SYS-4 | Mandatory |
REQ-SYS-5 | DSN-SYS-5 | Mandatory |
REQ-SYS-6 | DSN-SYS-6 | Mandatory |
REQ-SYS-7 | DSN-SYS-7 | Mandatory |
REQ-SYS-8 | DSN-SYS-8 | Mandatory |
REQ-SYS-SIM-1 | DSN-SIM-LED-01, DSN-SIM-SNS-01 | Mandatory |
Requirement Categories
Requirements are categorized using the following prefixes:
REQ-SYS
: System-level requirementsREQ-CFG
: Configuration management requirementsREQ-SEN
: Sensor requirementsREQ-LED
: LED display requirementsREQ-NET
: Network and connectivity requirementsREQ-WEB
: Web interface requirements
System Requirements
REQ-SYS-1: ESP32 Hardware Platform
Type: System
Priority: Mandatory
Description: The system SHALL operate on ESP32 WROOM-32F microcontroller with 4MB flash memory.
Rationale: ESP32 provides WiFi connectivity, sufficient processing power, and adequate flash memory for the application.
Acceptance Criteria:
- AC-1: System boots successfully on ESP32 WROOM-32F
- AC-2: Flash usage does not exceed 90% of available 4MB
- AC-3: System operates within ESP32 memory constraints
REQ-SYS-2: Real-time Distance Measurement
Type: Functional
Priority: Mandatory
Description: The system SHALL continuously measure distance and update LED display in real-time.
Rationale: Core functionality for distance visualization and monitoring.
Acceptance Criteria:
- AC-1: Distance measurements updated at minimum 10Hz frequency
- AC-2: LED display reflects distance changes within 100ms
- AC-3: System maintains real-time performance under all operating conditions
REQ-SYS-3: WiFi Connectivity
Type: Functional
Priority: Mandatory
Description: The system SHALL provide WiFi connectivity in both Access Point (AP) and Station (STA) modes.
Rationale: Enables web interface access and network configuration.
Acceptance Criteria:
- AC-1: System creates WiFi Access Point for initial configuration
- AC-2: System connects to existing WiFi networks as station
- AC-3: Automatic fallback to AP mode if STA connection fails
REQ-SYS-4: Web-based Configuration
Type: Functional
Priority: Mandatory
Description: The system SHALL provide web interface for configuration and monitoring.
Rationale: User-friendly interface for system setup and operation.
Acceptance Criteria:
- AC-1: Web interface accessible via HTTP
- AC-2: Configuration changes applied without firmware recompilation
- AC-3: Real-time monitoring of system status and sensor data
REQ-SYS-5: Non-volatile Configuration Storage
Type: Functional
Priority: Mandatory
Description: The system SHALL persist configuration settings across power cycles.
Rationale: Maintains user settings and system configuration permanently.
Acceptance Criteria:
- AC-1: Configuration survives device reset and power loss
- AC-2: Factory reset capability restores default settings
- AC-3: Configuration corruption detection and recovery
REQ-SYS-6: Component-based Architecture
Type: Design
Priority: Mandatory
Description: The system SHALL implement modular component-based architecture.
Rationale: Enables maintainability, testability, and reusability.
Acceptance Criteria:
- AC-1: Distance sensor implemented as independent component
- AC-2: LED controller implemented as independent component
- AC-3: Components provide well-defined APIs
- AC-4: Main application coordinates components without tight coupling
REQ-SYS-7: Error Handling and Recovery
Type: Reliability
Priority: Mandatory
Description: The system SHALL handle errors gracefully and attempt recovery.
Rationale: Ensures system reliability and user experience.
Acceptance Criteria:
- AC-1: Sensor timeouts handled without system crash
- AC-2: WiFi connection failures trigger automatic retry
- AC-3: System logs errors for diagnostics
- AC-4: Watchdog timer prevents system hang
REQ-SYS-8: Memory Management
Type: Performance
Priority: Mandatory
Description: The system SHALL manage memory efficiently within ESP32 constraints.
Rationale: Prevents memory leaks and ensures stable operation.
Acceptance Criteria:
- AC-1: Heap usage monitored and bounded
- AC-2: No memory leaks during normal operation
- AC-3: Stack overflow protection for all tasks
- AC-4: Dynamic allocation minimized in time-critical paths
REQ-SYS-SIM-1: Emulator / Simulator Build Support
Type: Design / Testability
Priority: Mandatory
Description: The system SHALL provide a build-time selectable emulator/simulator mode that replaces hardware-near modules with simulator implementations while preserving the public component APIs and runtime behavior seen by higher-level modules. Simulator implementations MUST be selectable without modifying header files or higher-level application code.
Rationale: Enables development and testing on host environments (QEMU) without physical hardware, improves reproducibility and CI test coverage, and enforces clean module boundaries that encapsulate hardware dependencies.
Acceptance Criteria:
- AC-1: A Kconfig option
CONFIG_TARGET_EMULATOR
(or equivalent) exists to enable emulator builds viamenuconfig
oridf.py -DCONFIG_TARGET_EMULATOR=1 build
. - AC-2: Simulator implementations are selected by the buildsystem (CMake) and compiled in place of hardware implementations (example:
distance_sensor_sim.c
vsdistance_sensor.c
) without requiring changes to header files or higher-layer code. - AC-3: Simulator components MUST implement the complete public API of their hardware counterparts and return identical error codes and semantics for consumers (blocking queue semantics, return values, state queries).
- AC-4: The distance sensor simulator SHALL produce deterministic measurements performing a linear sweep from 5cm to 60cm and back with 1mm resolution, advancing once per second; measurements are published on the processed measurement queue using the same
distance_measurement_t
structure and status codes. - AC-5: The LED controller simulator SHALL maintain the same in-RAM buffer semantics and
led_show()
API; physical transmission is replaced by a rate-limited terminal visualization (≈1Hz) using unobtrusive symbols (emoji or ASCII) to reflect per-pixel state. - AC-6: The web server and WiFi manager MAY be left unchanged in emulator builds; lack of real WiFi events is acceptable and must not cause crashes. The emulator requirement does not mandate network stack simulation in the first iteration.
- AC-7: The emulator build SHALL be runnable under QEMU (or a documented emulator) and produce observable LED visualization and distance measurement output in the serial console.
- AC-8: Documentation in
docs/design/
anddocs/requirements/
updated to reference simulator design artifacts and provide build/run verification steps.
Compliance and Validation
Traceability
All requirements SHALL be traceable to:
- Design specifications in
docs/design/
- Implementation in
main/
andcomponents/
- Test cases in
docs/test/
Validation Method
- Inspection: Code review and documentation review
- Testing: Unit tests, integration tests, system tests
- Analysis: Static analysis and memory profiling
- Demonstration: Live system demonstration
Change Management
- Requirements changes tracked through Git version control
- Impact analysis performed for all requirement modifications
- Traceability updated when requirements change
- Approval required for mandatory requirement changes
This document follows OpenFastTrack methodology for requirements engineering and traceability.