The AI Collision-Avoidance Radar for the Electrical Grid:
Predicting secondary distribution transformer failure and dirty-power degradation 10 to 15 minutes before catastrophic failure using unsupervised edge machine learning.
Across modern distribution grids, neighborhood step-down transformers (stepping 11kV/33kV down to 230V/120V) face unprecedented stress from simultaneous EV fast-charging surges and rooftop solar backfeeding spikes. Traditional utilities operate almost completely blind at this level:
- Residential Smart Meters only transmit billing summaries once every hourβuseless for sub-second electrical fault prevention.
- Substation SCADA sits miles upstream and cannot isolate localized feeder coil thermal runaway.
- Emergency Diesel Generators & UPS Systems are like airbagsβunder NFPA 110, emergency generators take 10 to 15 seconds to crank and accept full load, while inverters cannot mitigate prolonged 190V brownouts and harmonic distortion that trigger catastrophic MRI helium quenches ($80,000+ per event) or robotic surgical crashes.
GrydAI is the collision-avoidance radar. Deployed as a dedicated edge monitor directly at the transformer's low-voltage secondary side, GrydAI ingests 10 Hz high-frequency electrical telemetry. Using an unsupervised Autoencoder, it identifies micro-arcing and insulation breakdown 10β15 minutes early, enabling automated, synchronized closed-transition generator transfers and DSO load shedding before physical equipment explodes.
- Micro-Hardware Edge Node (ESP32): Reads 12-bit analog voltage/current signals at 10 Hz, drives an on-board SSD1306 OLED display, and responds to reverse serial AI commands via physical Green/Yellow/Red indicator LEDs.
-
Unsupervised Autoencoder (
MLPRegressor): Learns healthy resting electrical baseline waveforms ($\mathbf{x} \rightarrow \mathbf{\hat{x}}$ ). Any anomalous sag, harmonic surge, or micro-fluctuation causes Reconstruction Mean Squared Error (MSE) to spike immediately. -
Adaptive 3-Sigma Reconstruction Bounds: Replaces rigid, static trip thresholds with dynamic
$+3\sigma$ confidence bands that automatically adapt to evolving grid loads. - Interactive 3D Hospital Digital Twin: Real-time 3D isometric facility visualization with dynamic color-coded vulnerability auras (Normal Green, Warning Amber, Critical Red) and responsive spatial framing controls.
- Live Feeder Telemetry Cards: Displays real-time feeder voltage, line current, and the 50.0 Hz AC line frequency alongside a dynamic 13-bar harmonic waveform equalizer.
- Sub-10ms Emergency Override: Immediate hardware push-button interrupt bypassing digital filters for instantaneous trip protection upon catastrophic line breaks.
- Anti-Flicker Consensus Filter: Multi-tier rolling consensus buffer preventing ADC thermal jitter at state transition boundaries.
- Live Incident Classification: Automatically records real-time transient sags, surges, and micro-arcing directly from live telemetry with zero synthetic mock dependencies.
flowchart TD
subgraph EdgeHardware ["Physical Edge Node (ESP32)"]
PotV["Voltage Dial (Pin 34)"] --> ADC["12-Bit ADC"]
PotI["Current Dial (Pin 35)"] --> ADC
Btn["Fault Button (Pin 32)"] --> GPIO["Digital GPIO"]
ADC --> ESP32["ESP32 Firmware Loop (10 Hz)"]
GPIO --> ESP32
ESP32 --> OLED["0.96 OLED (SSD1306)"]
ESP32 --> LEDs["Status LEDs (G / Y / R)"]
end
subgraph BackendCore ["Python FastAPI Backend Server"]
SerialThread["PySerial Daemon Thread"] <--> Bridge["SerialTelemetryBridge"]
MockGen["MockGenerator (--mock)"] -.-> Bridge
Bridge --> ML["ML Pipeline (Autoencoder)"]
ML --> StateEngine["Dual-Tier Decision Engine & Z-Score"]
StateEngine --> WSEngine["WebSocket Broadcaster (10 Hz)"]
StateEngine --> ReverseSerial["Contract 3 Serial Command (2 Hz)"]
ReverseSerial --> SerialThread
end
subgraph WebPortal ["React 18 + Vite Command Portal"]
WSClient["WebSocket Client (ws://localhost:8000/ws)"] --> TelemetryState["Telemetry State Store"]
TelemetryState --> Twin3D["3D Isometric Hospital Twin"]
TelemetryState --> FeederCards["Feeder Cards (V, A, 50.0 Hz, Waveform)"]
TelemetryState --> AnalyticsChart["Adaptive 3-Sigma MSE Chart"]
TelemetryState --> IncidentLog["Live Incident Classification Log"]
end
ESP32 -- "Contract 1: USB Serial JSON @ 10 Hz" --> SerialThread
ReverseSerial -- "Contract 3: S:<status>:<score>\n" --> ESP32
WSEngine -- "Contract 2: JSON Payload @ 10 Hz" --> WSClient
The physical prototype simulates the electrical grid safely using 3.3V/5V DC components (no live AC mains):
| Component | ESP32 Pin | Type | Function / Circuit Notes |
|---|---|---|---|
| Grid Voltage Dial | Pin 34 | Analog (ADC1_CH6) | 10 kΞ© Potentiometer (Wiper to Pin 34, outer pins to 3V3 & GND). |
| Line Current Dial | Pin 35 | Analog (ADC1_CH7) | 10 kΞ© Potentiometer (Wiper to Pin 35, outer pins to 3V3 & GND). |
| Solar Irradiance LDR | Pin 33 | Analog (ADC1_CH5) | Photoresistor voltage divider (defaults safely to 100% if unwired). |
| Catastrophic Fault Button | Pin 32 | Digital Input | Tactile Push Button with 390 Ξ© pull-down resistor to GND. |
| Status LED: Green (Normal) | Pin 25 | Digital Output | 5mm LED + 390 Ξ© current-limiting resistor to GND. Active-HIGH. |
| Status LED: Yellow (Warning) | Pin 26 | Digital Output | 5mm LED + 390 Ξ© current-limiting resistor to GND. Active-HIGH. |
| Status LED: Red (Critical) | Pin 27 | Digital Output | 5mm LED + 390 Ξ© current-limiting resistor to GND. Active-HIGH. |
| I2C OLED Display (SSD1306) | SDA: 21, SCL: 22 | I2C Bus | 0.96" 128x64 OLED (VCC to 3V3, GND to GND). Refreshes at 2β3 Hz. |
{
"timestamp": 1726178000,
"v_raw": 2048,
"i_raw": 2048,
"fault_btn": 0,
"solar_ldr": 4095
}{
"timestamp": 1726178000,
"raw": {
"v_raw": 2048,
"i_raw": 2048,
"fault_btn": 0
},
"metrics": {
"voltage_sim": 220.1,
"current_sim": 15.0,
"solar_efficiency": 100.0,
"frequency_sim": 50.0,
"frequency": 50.0,
"current_kw": 3.3,
"energy_percent": 41,
"stability": 98.4,
"waveform": [65, 70, 78, 82, 85, 82, 78, 70, 65, 58, 52, 45, 38]
},
"ai_prediction": {
"anomaly_score": -0.85,
"grid_status": 0,
"message": "System Stable - Normal Feeder Telemetry",
"reconstruction_mse": 0.0024,
"z_score": 0.45,
"adaptive_threshold": 0.89
}
}S:<grid_status>:<anomaly_score>\n
- Example:
S:0:-0.85\n grid_status:0(Normal/Green LED),1(Warning/Yellow LED),2(Critical/Red LED)anomaly_score: Normalized score between -1.00 and 1.00 for local OLED rendering.
- Python: 3.10 or higher
- Node.js: 18.0 or higher (with npm)
- Arduino IDE / PlatformIO: (For flashing ESP32 firmware)
- Open
firmware/smart_grid_node/smart_grid_node.inoin Arduino IDE. - Install required libraries via Library Manager:
Adafruit SSD1306Adafruit GFX LibraryArduinoJson(v6 or v7)
- Select board: ESP32 Dev Module.
- Connect ESP32 via USB and click Upload.
- Navigate to the project root and install Python dependencies:
pip install -r requirements.txt
- Start the backend in Hardware Mode (auto-detects USB serial):
Or specify a custom COM port and baud rate:
python -m backend.main
python -m backend.main --port COM3 --baud 115200
- (Alternative) Run in Mock Simulation Mode (no hardware needed):
python -m backend.main --mock
- Confirm server health at
http://localhost:8000/.
- Navigate to the frontend directory and install dependencies:
cd FrontEnd npm install - Start the development server:
npm run dev
- Open
http://localhost:3000/in your browser. - Click Launch System to open the interactive command portal.
Follow this choreography for live demonstrations to maximize technical impact:
-
[0:00 - 0:45] The Blindspot & Concept:
- "Existing solutions are airbagsβthey only trigger after the transformer explodes. Hourly smart meters and upstream substations are blind to localized neighborhood transformer stress. GrydAI is the radar."
-
[0:45 - 1:15] Baseline Telemetry:
- Point to the live dashboard streaming from Transformer Node #TR-408 at 10 Hz.
- Note the healthy nominal parameters: 220V, 15A, 50.0 Hz AC line frequency, Stability index at 98%, and Green hardware LED lit.
-
[1:15 - 2:00] Simulated EV Overload (Potentiometer Turn):
- Turn the Current dial to simulate neighborhood EV charging surge (
$>18.5\text{A}$ ). - Within 200 ms, show the Reconstruction MSE curve spiking through the adaptive confidence envelope on the Analytics tab.
- The 3D Hospital facility pulses amber warning (Status 1), and the hardware Yellow LED clicks ON.
- Turn the Current dial to simulate neighborhood EV charging surge (
-
[2:00 - 2:30] Catastrophic Line Fault (Button Tap):
- Tap the physical push button simulating an instantaneous line drop.
- In
$< 10\text{ms}$ , the system triggers a Red lockdown (Status 2), firing the hardware Red LED and activating the emergency transfer alert.
-
[2:30 - 3:00] Business & Environmental Impact:
- Highlight the avoided metrics: $48,500 transformer replacement avoided, 42 minutes of surgical downtime prevented, and 2.4 metric tons of peaker plant
$CO_2$ emissions avoided.
- Highlight the avoided metrics: $48,500 transformer replacement avoided, 42 minutes of surgical downtime prevented, and 2.4 metric tons of peaker plant
Why do the telemetry cards show 50.0 Hz when data updates at 10 Hz?
They measure two distinct phenomena that both share the unit Hertz (Hz): 1. 50.0 Hz (Grid AC Line Frequency): The physical alternating current (AC) frequency of the electrical power grid (standard in India, UK, Europe, etc.). 2. 10 Hz (Telemetry Data Rate): How frequently the ESP32 serial bridge and WebSocket emit telemetry JSON packets (10 updates per second / every 100 ms).
Why use an unsupervised Autoencoder instead of strict threshold rules?
Fixed thresholds (e.g.,
voltage < 198V) only catch faults when failure is already imminent. Insulation breakdown, winding thermal stress, and loose connections manifest as high-frequency micro-fluctuations and harmonic distortion within normal voltage bounds. The Autoencoder detects these subtle waveform anomalies 10β15 minutes before thresholds are breached.
Why is the solar irradiance decoupled from the core transformer ML pipeline?
Solar irradiance varies naturally due to cloud cover and nighttime cycles. If solar were part of the transformer health autoencoder vector, normal sunset would trigger false transformer anomaly alarms. Solar is therefore tracked as auxiliary grid context while the core autoencoder focuses strictly on
GrydAI/
βββ README.md # Master repository documentation
βββ requirements.txt # Core Python dependencies
βββ monitor_pot.py # Live CLI debugging tool for hardware ADC
βββ firmware/ # Embedded C++ Firmware
β βββ smart_grid_node/
β βββ smart_grid_node.ino # ESP32 10 Hz non-blocking loop & OLED driver
βββ backend/ # Python Backend Engine
β βββ main.py # FastAPI server, REST routes & WebSocket broadcaster
β βββ serial_reader.py # Background thread for USB serial telemetry
β βββ ml_pipeline.py # Autoencoder, adaptive Z-score & consensus filter
β βββ mock_generator.py # 10 Hz synthetic telemetry generator (--mock)
β βββ verify_fault_detection.py # Automated test suite for fault latency
β βββ requirements.txt # Backend-specific requirements
βββ FrontEnd/ # React 18 + Vite Web Application
β βββ package.json # Frontend dependencies & scripts
β βββ vite.config.js # Dev server configuration (port 3000)
β βββ src/
β βββ App.jsx # Main application state & screen router
β βββ components/
β β βββ LaunchScreen.jsx # High-tech initial launch screen
β β βββ LoadingScreen.jsx # Gateway sequence & branding loader
β β βββ LandingPage.jsx # Primary command portal with WebSocket hook
β β βββ Navbar.jsx # Global status bar & navigation
β β βββ dashboard/
β β βββ IsometricHospitalGrid.jsx # 3D Digital Twin with responsive zoom
β β βββ AnalyticsView.jsx # Adaptive 3-Sigma MSE & incident log
β β βββ VoltageTelemetryCard.jsx # Feeder voltage & 50.0 Hz line frequency
β β βββ CurrentTelemetryCard.jsx # Feeder current & 50.0 Hz line frequency
β β βββ StabilityIndexCard.jsx # ML-driven grid stability index
β β βββ TotalEnergyCard.jsx # Real-time power load & consumption
βββ Guide/ # Detailed technical guides & specifications
βββ architecture.md # Detailed architecture blueprint
βββ context.md # Problem domain & value proposition
βββ requirements.md # System requirements specification (SRS)
βββ plan.md # Development milestones & execution roadmap
This project is licensed under the MIT License β see the LICENSE file for details.