In order to take full advantage of distributed generators, an evolution of the classical power system organization and management is also necessary. An aggregator of a residential urban electrical network can be considered by the distribution system operator as a stakeholder, which is able to control a cluster of local generators and loads with technical constraints for the connection with the remaining distribution grid and commercial contracts with outer electrical producers. This paper is focused on the design of the microgrid central energy management system which relies on a day-ahead operational planning and an online adjustment procedure during the operation. A dynamic programming-based algorithm is derived to solve the unit commitment problem with a multiobjective function in order to reduce the economic cost and CO2 equivalent emissions. The proposed energy management system is implemented into a supervisory control and data acquisition (SCADA) and tested by using a hardware-in-the-loop simulation of the urban network. Economic and environmental gains are evaluated.