Abstract-Microgrids are energy systems that can work independently from the main grid in a stable and self-sustainable way. They rely on energy management systems to schedule optimally the distributed energy resources. Conventionally, the main research in this field is focused on scheduling problems applicable for specific case studies rather than in generic architectures that can deal with the uncertainties of the renewable energy sources. This paper contributes a design and experimental validation of an adaptable energy management system implemented in an online scheme, as well as an evaluation framework for quantitatively assess the enhancement attained by different online energy management strategies. The proposed architecture allows the interaction of measurement, forecasting and optimization modules, in which a generic generation-side mathematical problem is modeled, aiming to minimize operating costs and load disconnections. The whole energy management system has been tested experimentally in a test bench under both grid-connected and islanded mode. Also, its performance has been proved considering severe mismatches in forecast generation and load. Several experimental results have demonstrated the effectiveness of the proposed EMS, assessed by the corresponding average gap with respect to a selected benchmark strategy and ideal boundaries of the best and worst known solutions.