SPST — Solar Panel Sun Tracker
FreeRTOS-driven dual-axis sun tracking firmware on ATmega32 with sensor fault protection

- ▹ADC (10-bit differential sampling for LDRs)
- ▹Timer1 (16-bit Fast PWM for Servo control)
- ▹USART (System telemetry and state logging)
- ▹GPIO (Status LEDs and limit feedback)
Technical Overview
Engineering Decisions & Rationale
Why the system is structured this way rather than standard simplifications.
1.Layered MCAL and HAL Abstraction
Register writes to ADMUX, ADCSRA, and TCCR1A are encapsulated inside MCAL drivers. High-level tracking logic operates purely on abstract sensor lux readings and degree angles, allowing the firmware to be ported or simulated without changing business logic.
2.Hysteresis Deadbands & Cloud Hold Logic
Small illumination fluctuations often cause continuous servo jitter, wearing out mechanical actuators. SPST enforces a configurable ADC deadband and detects cloud cover (diffuse light where both LDRs drop below a threshold), freezing servo orientation until direct sunlight returns.
3.Fault Tolerant State Machine
If either LDR produces an out-of-bounds voltage (indicating a broken wire or shorted sensor), the system triggers a fault state, illuminates a diagnostic LED, logs the anomaly over UART, and locks the panel in a safe position.
Key Technical Highlights
- Layered MCAL (Microcontroller Abstraction Layer) and HAL (Hardware Abstraction Layer) architecture
- Differential dual-LDR light tracking with hysteresis deadbands to eliminate servo jitter
- Autonomous night parking: parks the solar panel at east-facing baseline upon prolonged darkness
- Cloud detection and hold behavior to avoid erratic hunting under overcast skies
- Sensor fault diagnosis detecting disconnected or shorted LDRs with safe fallback states
- UART diagnostic telemetry streaming real-time tracking states at 9600 baud (8N1)