The growing consumption of electricity as well as the progressive development of new technologies implies that the power system is increasingly automated with the purpose of having a more efficient and economical operation. This development drives the system to a Smart Grid, a large-scale cyber-physical network covering different energy generation technologies, storage and communications enabling real-time information exchange and control. In this work, we present an optimal distributed control based on the consensus+innovation technique, where each agent of the network obtains information from its neighbours. Simulations on a microgrid system based on an IEEE 14-Bus reference system demonstrate the effectiveness of the approach. Convergence is observed in the microgrid system under different scenarios in the physical and communications network.