Maximum Demand Electrical -

Maximum Demand Electrical -

// POST /api/max_demand/config

For kVA demand (common for utilities), measure voltage and current, then:

"limit_kw": 160.0, "warning_threshold_pct": 85, "window_minutes": 15, "auto_reset_peak_on": "monthly" maximum demand electrical

+---------------------+------------------+ | Period | Peak Demand (kW) | +---------------------+------------------+ | 2026-04-01 to 07 | 142.3 | | 2026-03-25 to 31 | 138.9 | +---------------------+------------------+ | Condition | Handling | |-----------|----------| | Power loss | Persist buffer & peak to EEPROM. On restart, wait for full window before reliable demand. | | Incomplete window at startup | Use partial window average with a flag. | | Meter rollover | Detect by comparing readings; adjust delta with max meter reading. | | Communication delay | Timestamp each reading; interpolate if needed. | 9. Sample API / Interface (for system integration) // GET /api/max_demand/current

CREATE TABLE md_log ( id INTEGER PRIMARY KEY, timestamp DATETIME, demand_kw REAL, peak_flag BOOLEAN ); CREATE TABLE md_config ( param TEXT PRIMARY KEY, value REAL ); -- e.g., ('limit_kw', 150.0), ('warning_pct', 80.0), ('window_min', 15) // POST /api/max_demand/config For kVA demand (common for

# Store in circular buffer self.buffer[self.index] = delta_kwh self.index = (self.index + 1) % self.num_blocks

Demand = (kWh_last_15min) / 0.25 To avoid storing raw energy every second, break window into N sub‑intervals. | | Meter rollover | Detect by comparing

return demand_kw When demand approaches limit, shed non‑critical loads.