WhatsApp Us
🔋 V2G · Microgrid · Energy Management · MPC · Reinforcement Learning

V2G Microgrid

A V2G microgrid energy management system (EMS) is the controller that decides, minute by minute, how solar, wind, batteries, the main grid and a fleet of bidirectional electric vehicles share the load at the lowest cost while keeping every driver's range promise. This guide covers architecture, control layers, the optimisation maths, EMS strategies, a runnable Python model with real output and project ideas.

3
Control Layers
7
EMS Strategies
12
Project Ideas
PVWindBESSV2G FleetCritical LoadsMain Grid / PCCEMS Controller

What is a V2G Microgrid Energy Management System?

A microgrid is a small electrical network with its own generation, storage and loads that can run connected to the main grid or alone (islanded). The EMS is its brain: it forecasts, schedules and commands every controllable asset. In a V2G microgrid, parked electric vehicles become one more flexible asset that can both absorb surplus power and return it.

Why add EVs to a microgrid EMS?

A campus, factory, apartment complex or village often has an idle fleet whose combined battery is larger than the stationary battery it could afford. Using it can shave demand peaks, absorb midday solar, and give resilience during outages without buying new storage.

What the EMS must decide

  • When each EV charges or discharges
  • How much the stationary battery cycles
  • When to import from or export to the grid
  • Whether to curtail PV or shed loads
  • How to hold voltage and frequency when islanded
  • How to guarantee departure SOC for every driver

Unlike a plain V2G scheduler

A single-vehicle V2G scheduler chases price. A microgrid EMS must also balance power every instant, respect transformer and feeder limits, and coordinate several sources, so it is a joint optimisation problem rather than a price-following one.

Microgrid Architecture with a V2G Fleet

Every source and sink connects to a common bus, and the EMS sits above the local controllers sending set-points and receiving measurements.

☀️ PV Array
+ MPPT
→
💨 Wind / Other
DER
→
🔌 Common AC/DC Bus
(Microgrid)
→
🏭 Loads
(Critical + Flexible)
🔋 Stationary BESS
↔
🚗 Bidirectional EV
Chargers (V2G)
↔
🧮 EMS Controller
(Forecast + Optimise)
↔
🏙️ Main Grid
via PCC + Meter

Typical component sizing (campus example)

  • PV: 150–300 kWp
  • Stationary BESS: 100–500 kWh
  • V2G chargers: 10–20 × 7–11 kW AC or DC units
  • PCC import limit: set by transformer rating
  • Backup generator or none, depending on resilience goal
  • Meters and sensors at PCC, bus, battery and each charger

Sizes are illustrative starting points; always size from your own load and solar data.

Hierarchical Control: From Milliseconds to a Day

A robust V2G microgrid separates fast stabilising control from slow economic optimisation.

01

Primary Control (ms)

Droop / virtual-synchronous-machine control in each inverter holds voltage and frequency with no communication. In islanded mode the V2G chargers act as grid-forming or grid-supporting units.

02

Secondary Control (s – min)

Restores frequency and voltage to nominal after droop deviation and shares reactive power. Can be centralised or a distributed consensus algorithm.

03

Tertiary / EMS Dispatch (15 min – 24 h)

Economic scheduling: PV forecast, load forecast, tariff, EV availability and battery limits go into an optimiser that sets power set-points for every asset.

04

Protection & Mode Transition

Islanding detection, seamless grid-connected to islanded transfer, black-start and re-synchronisation with the main grid at the point of common coupling (PCC).

05

Forecasting Layer

PV irradiance, load, price and EV arrival/departure/SOC forecasts using LSTM, XGBoost or Prophet. Forecast error is the biggest real-world loss factor.

06

Data & Communication Layer

IEC 61850 / Modbus TCP inside the site, MQTT to the cloud, OCPP 2.x to chargers and ISO 15118-20 to vehicles; cyber-security and latency become design constraints.

The Optimisation Problem Behind the EMS

Day-ahead scheduling over T time steps is usually written as a cost minimisation subject to physical and driver constraints.

minimise Σₜ [ λₜ·Pgrid,in(t) − λfeed·Pgrid,out(t) + c_b·(Pb,ch+Pb,dis)/2 + c_ev·(Pev,ch+Pev,dis)/2 ] + d·max(Pgrid,in)
Power balance: PV(t) − Pcurt(t) + Pgrid,in − Pgrid,out + Pb,dis − Pb,ch + Pev,dis − Pev,ch = Load(t)
BESS energy: SOCb(t+1) = SOCb(t) + (η·Pb,ch − Pb,dis/η)·Δt / Eb
EV fleet energy: SOCev(t+1) = SOCev(t) + (η·Pev,ch − Pev,dis/η)·Δt / Eev (only while plugged in)
Limits: SOCmin ≤ SOC ≤ SOCmax, 0 ≤ P ≤ Pmax, Pgrid ≤ transformer limit
Driver promise: SOCev(departure) ≥ SOCrequired

Reading the model

The first term is energy cost, the second the wear penalty that stops useless cycling, and the last a demand charge on the daily peak. Because charging and discharging both lose energy (η < 1) and cost wear, the optimiser rarely does both at once, so a plain linear programme works for many projects. Switch to MILP when you need on/off charger states, minimum run times or discrete power levels.

EMS Strategies Compared

Pick the method that fits your level, tools and the uncertainty in your data.

StrategyHow it worksStrengthLimitationLevel
Rule-based / HeuristicSimple if-then thresholds on SOC, price and PVEasy to implement, runs on a PLCNot optimal, hard to tune, ignores forecastsBasic
Linear / MILP SchedulingDay-ahead optimisation of dispatch (as in the Python example)Optimal for its model, transparent, fast with HiGHS/GurobiNeeds good forecasts, binary variables raise solve timeIntermediate
Model Predictive Control (MPC)Re-solves a rolling horizon every 5–15 minutes with fresh dataHandles forecast error and EV arrival changesComputation and a good model requiredIntermediate
Stochastic / Robust OptimisationScenario trees or uncertainty sets for PV, load and EV demandSafer decisions under uncertaintyLarger problem, conservative resultsAdvanced
Deep Reinforcement LearningDQN / PPO / SAC agent learns charge-discharge policy from experienceNo explicit model, adapts to dataTraining data and safety constraints are hard; needs a simulatorAdvanced
Distributed / Multi-Agent (ADMM, Consensus)Each EV or building optimises locally and coordinates via messagesScalable, preserves privacy, no single point of failureConvergence tuning, communication delayAdvanced
Game-Theoretic / Peer-to-Peer TradingProsumers and EV owners trade energy in a local marketFair price discovery, incentive designMarket design and regulatory complexityAdvanced

Worked Example: One Day of a Campus V2G Microgrid

A campus has 180 kW of PV at peak, a 200 kWh / 50 kW battery and a 10-vehicle fleet (40 kWh each, 7 kW chargers) plugged in from 10:00 to 20:00. Vehicles arrive at 40% and must leave at 80%. Tariff is a time-of-use price with a demand charge. The script below is a real linear programme solved with SciPy's HiGHS, and the output underneath is what it printed.

microgrid_ems.py — illustrative LP model
import numpy as np
from scipy.optimize import linprog

T = 24                                         # 1-hour steps, day-ahead
load = np.array([60,55,52,50,50,55,70,95,120,135,140,142,140,138,135,130,120,110,105,100,90,80,70,65.])
pv   = 1.5*np.array([0,0,0,0,0,2,15,40,70,95,112,120,118,105,85,55,25,6,0,0,0,0,0,0.])
tou  = np.array([4]*6 + [6]*4 + [7]*8 + [10]*4 + [6]*2, float)   # INR/kWh import
feed = 3.0                                     # INR/kWh export
G, eta = 150., .95                             # grid limit (kW), one-way efficiency
BC, BP = 200., 50.                             # BESS kWh, kW
NEV, EC, EP = 10, 40., 7.                      # EV count, kWh, kW each
ARR, DEP, S0, SREQ = 10, 20, .40, .80          # fleet plugged 10:00-20:00
EE, EPM = NEV*EC, NEV*EP
wear_b, wear_e = 1.5, 2.0                      # INR per kWh throughput
DC = 40.                                       # demand charge, INR per kW of daily peak import

# variables: grid-in, grid-out, BESS ch/dis, EV ch/dis, PV curtail  (7*T) + SOC_b, SOC_ev (T+1 each)
n = 7*T + 2*(T+1) + 1; v = lambda k,t: k*T + t
sb = lambda t: 7*T + t;  se = lambda t: 8*T + 1 + t
PK = n - 1
c = np.zeros(n); c[PK] = DC
for t in range(T):
    c[v(0,t)], c[v(1,t)] = tou[t], -feed
    c[v(2,t)] = c[v(3,t)] = wear_b/2
    c[v(4,t)] = c[v(5,t)] = wear_e/2
A, b = [], []
for t in range(T):
    r = np.zeros(n); r[[v(0,t), v(3,t), v(5,t)]] = 1; r[[v(1,t), v(2,t), v(4,t), v(6,t)]] = -1
    A.append(r); b.append(load[t] - pv[t])                             # power balance
    r = np.zeros(n); r[sb(t+1)], r[sb(t)] = 1, -1; r[v(2,t)], r[v(3,t)] = -eta/BC, 1/(eta*BC)
    A.append(r); b.append(0)                                           # BESS energy
    r = np.zeros(n); r[se(t+1)], r[se(t)] = 1, -1; r[v(4,t)], r[v(5,t)] = -eta/EE, 1/(eta*EE)
    A.append(r); b.append(0)                                           # EV energy
Aub = np.zeros((T,n)); bub = np.zeros(T)
for t in range(T): Aub[t,v(0,t)], Aub[t,PK] = 1, -1              # grid import <= peak variable
bd = [(0,0)]*n; bd[PK] = (0,G)
for t in range(T):
    plug = ARR <= t < DEP
    bd[v(0,t)] = bd[v(1,t)] = (0,G)
    bd[v(2,t)] = bd[v(3,t)] = (0,BP)
    bd[v(4,t)] = bd[v(5,t)] = (0, EPM if plug else 0)
    bd[v(6,t)] = (0, pv[t])
for t in range(T+1):
    bd[sb(t)] = (.2,.9)
    bd[se(t)] = (.2,.95) if ARR <= t <= DEP else (0,1)
bd[sb(0)] = (.5,.5); bd[se(ARR)] = (S0,S0); bd[se(DEP)] = (SREQ,.95)
A.append(np.eye(n)[sb(T)] - np.eye(n)[sb(0)]); b.append(0)             # BESS ends where it started

r = linprog(c, A_ub=Aub, b_ub=bub, A_eq=np.array(A), b_eq=b, bounds=bd, method="highs"); x = r.x
gi, ge, bc, bdis, ec, ed = (x[k*T:(k+1)*T] for k in range(6))
cost = np.sum(tou*gi - feed*ge) + DC*x[PK]
wear = wear_b/2*np.sum(bc+bdis) + wear_e/2*np.sum(ec+ed)

# baseline: no BESS dispatch, EVs charge flat-out on arrival
need, ev0 = (SREQ-S0)*EE/eta, np.zeros(T)
for t in range(ARR, DEP): ev0[t] = min(EPM, need); need -= ev0[t]
net = load + ev0 - pv
base = np.sum(tou*np.maximum(net,0) - feed*np.maximum(-net,0)) + DC*np.maximum(net,0).max()
print(f"Baseline cost        : INR {base:8.1f}   peak import {np.maximum(net,0).max():6.1f} kW")
print(f"Optimised (energy+DC): INR {cost:8.1f}   peak import {gi.max():6.1f} kW")
print(f"Battery wear cost    : INR {wear:8.1f}")
print(f"Net saving           : INR {base-cost-wear:8.1f}  ({100*(base-cost-wear)/base:.1f} %)")
print(f"EV energy exported   : {ed.sum():.0f} kWh   BESS discharged: {bdis.sum():.0f} kWh   PV curtailed: {x[6*T:7*T].sum():.0f} kWh")
output
Baseline cost        : INR  12701.8   peak import  105.0 kW
Optimised (energy+DC): INR  10749.8   peak import   70.1 kW
Battery wear cost    : INR    416.2
Net saving           : INR   1535.7  (12.1 %)
EV energy exported   : 57 kWh   BESS discharged: 81 kWh   PV curtailed: 0 kWh

All profiles and prices are assumed for teaching. The saving comes mostly from the demand charge and from moving EV charging to PV hours; with different tariffs or fleet hours the result will change, and the fleet only discharges when the price spread beats losses and wear.

KPIs to Report in Your Project

Quantify the EMS with metrics that reviewers recognise.

Cost ↓Daily operating cost vs baseline
Peak ↓PCC peak import (kW)
Self-use ↑PV self-consumption %
SOC ✓Departure SOC met for all EVs
WearEquivalent full cycles / day
THD / HzVoltage and frequency quality

Real-World Challenges

A

Uncertain EV Behaviour

Arrival time, departure time and initial SOC are random. Use probabilistic or MPC schemes with a safety SOC margin.

B

Forecast Errors

PV and load forecast errors turn into imbalance. Re-optimise often and hold battery reserve.

C

Battery Ageing

Cycling cost depends on chemistry and depth of discharge, so use a degradation model, not a flat price.

D

Standards & Interoperability

Bidirectional charging needs compatible vehicle, charger and protocol versions (ISO 15118-20, OCPP, IEEE 1547).

E

Cybersecurity

Chargers and cloud links are attack surfaces. Use TLS, certificates and network segmentation.

F

Regulation & Tariffs

Export rules, metering and V2G tariffs vary by region and change quickly. Verify the current local rules.

V2G Microgrid EMS Project Ideas

Topics for BE, M.Tech and PhD scholars with the simulation tools commonly used.

MATLAB / SimulinkPython / PyomoOpenDSSHOMER ProPLECSTyphoon HILGurobi / HiGHSpandapowerGridLAB-DCVXPY
#Project TopicSimulation / ToolsLevel
01V2G-Enabled Microgrid Day-Ahead Scheduling Using MILPPython Pyomo / Gurobi, HOMER Pro⭐ Basic
02MPC-Based Real-Time EMS for PV + BESS + EV Campus MicrogridMATLAB Simulink, YALMIP, CasADi⭐⭐ Intermediate
03Islanded Microgrid Frequency Support Using V2G Droop ControlMATLAB Simscape Electrical, PLECS⭐⭐ Intermediate
04Seamless Grid-Connected to Islanded Mode Transition with EV ChargersSimulink, OPAL-RT / Typhoon HIL⭐⭐⭐ Advanced
05Deep RL Based Energy Management for EV-Integrated MicrogridPython, Stable-Baselines3, Gymnasium⭐⭐⭐ Advanced
06Multi-Agent V2G Coordination Using ADMM Distributed OptimisationPython, CVXPY, OpenDSS⭐⭐⭐ Advanced
07PV Forecasting and Load Forecasting Driven V2G SchedulingPython TensorFlow, Prophet, Pyomo⭐⭐ Intermediate
08Battery Degradation Aware V2G Dispatch with Rainflow CountingMATLAB, Python, PyBaMM⭐⭐⭐ Advanced
09Peer-to-Peer Energy Trading in a Community Microgrid with EV ProsumersPython, Mesa / NetLogo, Hyperledger⭐⭐⭐ Advanced
10Voltage Regulation in an IEEE 33-Bus Microgrid Using EV Reactive PowerOpenDSS, GridLAB-D, pandapower⭐⭐ Intermediate
11Techno-Economic Sizing of PV, BESS and V2G Fleet for a Rural MicrogridHOMER Pro, MATLAB, Python⭐⭐ Intermediate
12Cyber-Secure V2G Microgrid Controller with OCPP and MQTT TestbedPython, Mosquitto, OCPP simulators⭐⭐⭐ Advanced

Frequently Asked Questions

A normal EMS schedules fixed assets such as batteries, generators and loads. A V2G EMS adds a mobile storage fleet whose availability, state of charge and departure time are uncertain and owned by other people, so the optimiser must guarantee the energy each driver needs before discharging.
Yes, if the chargers are bidirectional with grid-forming capability (or a stationary battery forms the grid and EVs follow). In research and demos this is shown with V2B and V2H systems, but the reserve kept for drivers limits how much of the pack can be used.
Use MATLAB/Simulink for converter-level and control-dynamics work (droop, PLL, transitions). Use Python with Pyomo, CVXPY or Gymnasium for scheduling, forecasting and learning-based EMS. Many strong projects combine both through co-simulation.
It is an illustrative linear programme with assumed numbers for load, PV and tariff. It shows the method and the type of result you can expect, but the saving percentage depends entirely on the assumed data, so replace it with measured profiles before quoting any figure.
Extra cycling adds some wear, and the effect depends on depth of discharge, temperature, C-rate and chemistry. That is why the model charges a wear cost per kWh of throughput; real projects should calibrate it with a degradation model.

What You Receive with Our Support

💬