In this way, a microgrid can effectively integrate various sources of distributed generation (DG), especially Renewable Energy Sources (RES) - renewable electricity, and can supply emergency power, changing between island and connected modes.
Control and protection are challenges to microgrids. A very important feature is also to provide multiple end-use needs as heating, cooling, and electricity at the same time since this allows energy carrier substitution and increased energy efficiency due to waste heat utilization for heating, domestic hot water, and cooling purposes (cross sectoral energy usage).
Control and protection are challenges to microgrids. A very important feature is also to provide multiple end-use needs as heating, cooling, and electricity at the same time since this allows energy carrier substitution and increased energy efficiency due to waste heat utilization for heating, domestic hot water, and cooling purposes (cross sectoral energy usage).
Definition
The United States Department of Energy Microgrid Exchange Group
 defines a microgrid as a group of interconnected loads and distributed 
energy resources (DERs) within clearly defined electrical boundaries 
that acts as a single controllable entity with respect to the grid. A 
microgrid can connect and disconnect from the grid to enable it to 
operate in both connected or island-mode. 
The EU research project describes a microgrid as comprising Low-Voltage (LV) distribution systems with distributed energy resources (DERs) (microturbines, fuel cells, photovoltaics (PV), etc.), storage devices (batteries, flywheels)
 energy storage system and flexible loads. 
Such systems can operate either connected or disconnected from the main 
grid. The operation of microsources in the network can provide  benefits
 to the overall system performance, if managed and coordinated 
efficiently.
Types of microgrids
A typical scheme of an electric based microgrid with renewable energy resources in grid-connected mode
Campus Environment/Institutional Microgrids
The focus of campus microgrids is aggregating existing on-site generation with multiple
loads that located in tight geography in which
owner easily manage them.
Community Microgrids
Community
 Microgrids can serve a few up to thousands of customers and support the
 penetration of local energy (electricity, heating, and cooling).
 In a community microgrid, some houses may have some renewable sources 
that can supply their demand as well as that of their neighbors within 
the same community. The community microgrid may also have a centralized 
or several distributed energy storages. Such microgrids can be in the 
form of an ac and dc microgrid coupled together through a bi-directional
 power electronic converter.
Remote Off-grid Microgrids
These microgrids never connect to the Macrogrid
 and instead operate in an island mode
at all times because of economic issues or geographical position. 
Typically, an "off-grid" microgrid is built in areas that are far 
distant from any transmission and distribution infrastructure and, 
therefore, have no connection to the utility grid.
 Studies have demonstrated that operating a remote area or islands' 
off-grid microgrids, that are dominated by renewable sources, will 
reduce the levelized cost of electricity production over the life of 
such microgrid projects.
Large remote areas may be supplied by several independent 
microgrids, each with a different owner (operator). Although such 
microgrids are traditionally designed to be energy self-sufficient, 
intermittent renewable sources and their unexpected and sharp variations
 can cause unexpected power shortfall or excessive generation in those 
microgrids. This will immediately cause unacceptable voltage or 
frequency deviation in the microgrids. To remedy such situations, it is 
possible to interconnect such microgrids provisionally to a suitable 
neighboring microgrid to exchange power and improve the voltage and 
frequency deviations. This can be achieved through a power electronics-based switch after a proper synchronization or a back to back connection of two power electronic converters
 and after confirming the stability of the new system. The determination
 of a need to interconnect neighboring microgrids and finding the 
suitable microgrid to couple with can be achieved through optimization or decision making approaches.
Military Base Microgrids
These microgrids are being actively deployed with focus on both physical and cyber
security for military facilities in order to assure reliable power without relying on the
Macrogrid.
Commercial and Industrial (C&I) Microgrids
These
 types of microgrids are maturing quickly in North America and Asia 
Pacific;
however, the lack of well –known standards for these types of microgrids
 limits them
globally. Main reasons for the installation of an industrial microgrid 
are power supply security and its reliability. There are many 
manufacturing processes in which an interruption of the power supply may
 cause high revenue losses and long start-up time.
Industrial microgrids can be designed to supply circular-economy 
(near-)zero-emission industrial processes, and can integrate combined 
heat and power (CHP) generation, being fed by both renewable sources and
 waste processing; energy storage can be additionally used to optimize 
the operations of these sub-systems. 
Basic components in microgrids
The Solar Settlement, a sustainable housing community project in Freiburg, Germany.
Local generation
A
 microgrid presents various types of generation sources that feed 
electricity, heating, and cooling to user. These sources are divided 
into two major groups – thermal energy sources (e.g,. natural gas or biogas generators or micro combined heat and power) and renewable generation sources (e.g. wind turbines, solar).
Consumption
In
 a microgrid, consumption simply refers to elements that consume 
electricity, heat, and cooling which range from single devices to 
lighting, heating system of buildings, commercial centers, etc. In the 
case of controllable loads, the electricity consumption can be modified in demand of the network.
Energy Storage
In microgrid, energy storage
 is able to perform multiple functions, such as ensuring power quality, 
including frequency and voltage regulation, smoothing the output of 
renewable energy sources, providing backup power for the system and 
playing crucial role in cost optimization. It includes all of 
electrical, pressure, gravitational, flywheel, and heat storage 
technologies. When multiple energy storages with various capacities are 
available in a microgrid, it is preferred to coordinate their charging 
and discharging such that a smaller energy storage does not discharge 
faster than those with larger capacities. Likewise, it is preferred a 
smaller one does not get fully charged before those with larger 
capacities. This can be achieved under a coordinated control of energy 
storage based on their state of charge.
If multiple energy storage systems (possibly working on different 
technologies) are used and they are controlled by a unique supervising 
unit (an Energy Management System - EMS), a hierarchical control based 
on a master/slaves architecture can ensure best operations, particularly
 in the islanded mode. 
Point of common coupling (PCC)
It is the point in the electric circuit where a microgrid is connected to a main grid.
 Microgrids that do not have a PCC are called isolated microgrids which 
are usually presented in the case of remote sites (e.g., remote 
communities
or remote industrial sites) where an interconnection with the main grid 
is not feasible due to either technical or economic constraints.
Advantages and challenges of microgrids
Advantages
A
 microgrid is capable of operating in grid-connected and stand-alone 
modes and of handling the transition between the two. In the 
grid-connected mode, ancillary services can be provided by trading activity between the microgrid and the main grid. Other possible revenue streams exist.
 In the islanded mode, the real and reactive power generated within the 
microgrid, including that provided by the energy storage system, should 
be in balance with the demand of local loads.
A microgrid may transition between these two modes because of 
scheduled maintenance, degraded power quality or a shortage in the host 
grid, faults in the local grid, or for economical reasons.
 By means of modifying energy flow through microgrid components, 
microgrids facilitate the integration of renewable energy generation 
such as photovoltaic, wind and fuel cell generations without requiring 
re-design of the national distribution system.
 Modern optimization methods can also be incorporated into the microgrid
 energy management system to improve efficiency, economics, and 
resiliency.
Challenges
Microgrids,
 and integration of DER units in general, introduce a number of 
operational challenges that need to be addressed in the design of 
control and protection systems in order to ensure that the present 
levels of reliability are not significantly affected and the potential 
benefits of Distributed Generation (DG) units are fully harnessed. Some 
of these challenges arise from invalid assumptions typically applied to 
conventional distribution systems, while others are the result of 
stability issues formerly observed only at a transmission system level.
The most relevant challenges in microgrid protection and control include:
- Bidirectional power flows: The presence of distributed generation (DG) units in the network at low voltage levels can cause reverse power flows that may lead to complications in protection coordination, undesirable power flow patterns, fault current distribution, and voltage control.
 - Stability issues: Interaction of control system of DG units may create local oscillations, requiring a thorough small-disturbance stability analysis. Moreover, transition activities between the grid-connected and islanding (stand-alone) modes of operation in a microgrid can create transient stability. Recent studies have shown that direct-current (DC) microgrid interface can result in significantly simpler control structure, more energy efficient distribution and higher current carrying capacity for the same line ratings.
 - Modeling: Many characteristic in traditional scheme such as prevalence of three-phase balanced conditions, primarily inductive transmission lines, and constant-power loads are not necessarily hold valid for microgrids, and consequently models need to be revised.
 - Low inertia: The microgrid shows low-inertia characteristic that are different to bulk power systems where high number of synchronous generators ensures a relatively large inertia. Especially if there is a significant share of power electronic-interfaced DG units, this phenomenon is more clear. The low inertia in the system can lead to severe frequency deviations in stand-alone operation if a proper control mechanism is not implemented.
 - Uncertainty: The operation of microgrids contain very much uncertainty in which the economical and reliable operation of microgrids rely on. Load profile and weather forecast are two of them that make this coordination becomes more challenging in isolated microgrids, where the critical demand-supply balance and typically higher component failure rates require solving a strongly coupled problem over an extended horizon. This uncertainty is higher than those in bulk power systems, due to the reduced number of loads and highly correlated variations of available energy resources (limited averaging effect).
 
Modelling Tools
To
 plan and install Microgrids correctly, engineering modelling is needed.
 Multiple simulation tools and optimization tools exist to model the 
economic and electric effects of Microgrids. A widely used economic 
optimization tool is the Distributed Energy Resources Customer Adoption Model (DER-CAM) from Lawrence Berkeley National Laboratory. Another frequently used commercial economic modelling tool is Homer Energy, originally designed by the National Renewable Energy Laboratory. There are also some power flow and electrical design tools guiding the Microgrid developers. The Pacific Northwest National Laboratory designed the public available GridLAB-D tool  and  the Electric Power Research Institute (EPRI) designed OpenDSS to simulate the distribution system (for Microgrids).  A professional integrated DER-CAM and OpenDSS version is available via BankableEnergy. A European tool that can be used for electrical, cooling, heating, and process heat demand simulation is EnergyPLAN from the Aalborg University in Denmark.
Microgrid control
Hierarchical Control
In regards to the architecture of microgrid control, or any control 
problem, there are two different approaches that can be identified: 
centralized and decentralized.
 A fully centralized control relies on a large amount of information 
transmittance between involving units and then the decision is made at a
 single point. Hence, it will present a big problem in implementation 
since interconnected power systems usually cover extended geographic 
locations and involves an enormous number of units. On the other hand, 
in a fully decentralized control, each unit is controlled by
its local controller without knowing the situation of others.
 A compromise between those two extreme control schemes can be achieved 
by means of a hierarchical control scheme consisting of three control 
levels: primary, secondary, and tertiary.
Primary control
The primary control is designed to satisfy the following requirements:
- To stabilize the voltage and frequency
 - To offer plug and play capability for DERs and properly share the active and reactive power among them, preferably, without any communication links
 - To mitigate circulating currents that can cause over-current phenomenon in the power electronic devices
 
The primary control provides the setpoints for a lower controller which are the
voltage and current control loops of DERs. These inner control
loops are commonly referred to as zero-level control.
Secondary control
Secondary
 control has typically seconds to minutes sampling time (i.e. slower 
than the previous one) which justifies the decoupled dynamics of the 
primary and the secondary control loops and facilitates their individual
 designs. Setpoint of primary control is given by secondary control in which as a centralized controller, it restores the microgrid voltage and frequency
 and compensates for the deviations caused by variations of loads or 
renewable sources. The secondary control can also be designed to satisfy
 the power quality requirements, e.g., voltage balancing at critical
buses.
Tertiary control
Tertiary control is the last (and the slowest) control level which consider economical concerns in the optimal operation of
the microgrid (sampling time is from minutes to hours), and manages the power flow between microgrid
and main grid.
 This level often involves the prediction of weather, grid tariff, and 
loads in the next hours or day to design a generator dispatch plan that 
achieves economic savings.
 In case of emergency like blackouts, Tertiary control could be utilized
 to manage a group of interconnected microgrids to form what is called 
"microgrid clustering" that could act as a virtual power plant and keep 
supplying at least the critical loads. During this situation the central
 controller should select one of the microgrid to be the slack (i.e. 
master) and the rest as PV  and load buses according to a predefined 
algorithm and the existing conditions of the system (i.e. Demand and 
generation), in this case, the control should be real time or at least 
high sampling rate.
IEEE 2030.7
A less utility influenced controller framework has been designed in the latest Microgrid controller standard from the Institute of Electrical and Electronics Engineers, the IEEE 2030.7.
 That concept relies on 4 blocks: a) Device Level control (e.g. Voltage 
and Frequency Control), b) Local Area Control (e.g. data communication),
 c) Supervisory (software) controller (e.g. forward looking dispatch 
optimization of generation and load resources), and d) Grid Layer (e.g. 
communication with utility).
Elementary control
A wide variety of complex control algorithms exist, making it difficult for small Microgrids and residential Distributed Energy Resource
 (DER) users to implement energy management and control systems. 
Especially, communication upgrades and data information systems can make
 it expensive. Thus, some projects try to simplify the control via 
off-the shelf products and make it usable for the mainstream (e.g. using
 a Raspberry Pi).
Examples
Les Anglais, Haiti
A wirelessly managed microgrid is deployed in rural Les Anglais, Haiti.
 The system consists of a three-tiered architecture with a cloud-based 
monitoring and control service, a local embedded gateway infrastructure 
and a mesh network of wireless smart meters deployed at 52 buildings. 
Non-Technical Loss (NTL) represents a major challenge when 
providing reliable electrical service in developing countries, where it 
often accounts for 11-15% of total generation capacity.
 An extensive data-driven simulation on 72 days of wireless meter data 
from a 430-home microgrid deployed in Les Anglais, Haiti has been 
conducted to investigate how to distinguish NTL from the total power 
losses which helps energy theft detection.
Mpeketoni, Kenya
A
 community-based diesel-powered micro-grid system was set up in rural 
Kenya near Mpeketoni called the Mpeketoni Electricity Project. Due to 
the installment of these microgrids Mpeketoni has seen a large growth in
 its infrastructure. Such growth includes increased productivity per 
worker with an increase of 100% to 200% and an income levels increase of
  20–70% depending on the product.
Stone Edge Farm Winery
A micro-turbine, fuel-cell, multiple batteries, hydrogen electrolyzer, and PV enabled Winery in Sonoma, California.