← Back to Projects
Winds of Change
Timeline: Sep 2026 – Present | Tech: C++, FreeRTOS, ESP32-S3, RS485 Modbus, MQTT, OpenGL
Overview
On the controls team for Winds of Change in Edinburgh, I wrote the embedded C++ firmware that keeps our wind turbine's DC bus safe during high-wind gusts and streams live electrical and aerodynamic telemetry to our ground station. When wind speed spikes, open-circuit turbine voltage can climb past what the grid can tolerate—so the controller has to react in milliseconds while keeping network I/O from blocking the control loop.
How It Works
- Dual-Core FreeRTOS Separation: Split real-time hardware control and Wi-Fi/MQTT networking across separate FreeRTOS tasks on the ESP32-S3 so broker reconnects or packet retries never stall the control loop.
- 100 Hz PID Dump-Load Regulation: Sampled bus voltage and current at 100 Hz and modulated a resistive dump load via PWM whenever bus voltage approached the 58V limit, protecting downstream power electronics without abrupt mechanical braking.
- RS485 Modbus Sensor Polling: Polled PZEM-017 DC power meters and an ultrasonic anemometer over a half-duplex RS485 bus, handling framing timeouts and CRC validation cleanly.
- Thread-Safe Live Tuning & Telemetry: Guarded PID gains, voltage thresholds, and E-stop states with FreeRTOS mutexes so operators can push new parameters over Mosquitto MQTT while the 10 Hz JSON telemetry stream feeds an ImGui/OpenGL dashboard.
- Python Fault Emulator: Built an offline Python MQTT publisher that replays synthetic wind gusts, sensor dropouts, and over-voltage ramps so we can test UI alerts and state transitions without spinning up the physical rig.
Hardware & Control Architecture
End-to-end signal and power flow from the 3-phase generator and rectifier through the 58V PWM dump-load brake, RS485 Modbus sensors, analog voltage divider, and ESP32-S3 telemetry link.