A new energy management system (EMS) is presented for small scale microgrids (MGs). The proposed EMS focuses on minimizing the daily cost of the energy drawn by the MG from the main electrical grid and increasing the self-consumption of local renewable energy resources (RES). This is achieved by determining the appropriate reference value for the power drawn from the main grid and forcing the MG to accurately follow this value by controlling a battery energy storage system. A mixed integer linear programming algorithm determines this reference value considering a time-of-use tariff and short-term forecasting of generation and consumption. A real-time predictive controller is used to control the battery energy storage system to follow this reference value. The results obtained show the capability of the proposed EMS to lower the daily operating costs for the MG customers. Experimental studies on a laboratory-based MG have been implemented to demonstrate that the proposed EMS can be implemented in a realistic environment.Energies 2019, 12, 2712 2 of 26 these ESS into small-scale MG architectures. The electrical load profiles of small scale MGs, particularly residential communities, can vary considerably with time: periods of house inoccupancy (e.g., during vacation) and the addition of new equipment (e.g., electric vehicle charge) or even new houses can have a strong influence on the loading profile [9]. Additionally, these small-scale systems see sharp changes in load over a short period of time as single loads (shower, cooker) can be significant considering the size of the MG. For these reasons, EMS used for small scale MGs must have a short control sample time to observe and respond to fast changes in the load and generation throughout the day [9,10]. Also, energy forecasting techniques must be adaptive and also have a short sample time if they are to help the EMS achieve good results for this type of grid.Small-scale MGs should preferably operate as a single controllable unit that imports/exports power from/to the main grid following a predictable shape [11]. In this way, the energy community works for the benefit of the whole grid and not just the small scale MG [12]. To achieve this, a real-time controller is required that allows the small-scale MG to accurately follow a reference value for the power drawn from the main electric grid, where this reference is created by a higher level controller which considers both local and system wide factors.Alternatively, large scale energy storage systems (ESS) (>1 MWh) will play a key role in solving problems such as intermittency of supply and loss of inertia which are challenging electricity grid operation [13], and many grid operators are encouraging the use of ESS to address, for example, increasing demand peaks and network congestion [14].Much of the existing research focusing on microgrid energy management (MGEM) is oriented towards determining the best operating scenario for the MG [15][16][17]. In [18], Carlos et al. introduce a new iterative algorithm that mana...