Microgrids present the challenge to reach a proper balance between local production and consumption, in order to reduce the usage of energy from external sources. This work presents a data-intensive solution to predict the energy behaviors. Thereby, control actions can be carried out such as decrease heating systems levels and switch of low-priority devices. For this purpose, this work has deployed an Advanced Metering Infrastructure (AMI) based on the Internet of Things (IoT) in the Techno-Pole testbed. This deployment provides the data from energy-related parameters such as load curves of the overall building through Non-Intrusive Load Monitoring (NILM), a wireless network of IoT-based smart meters to measure and control appliances, and finally the generated power curve by 2000 square meters of photovoltaic panels. The prediction model proposed is based on recognition of electrical signatures. These electrical signatures have been used to detect complex usage patterns. The modelled patterns have allowed to identify the work day of the week, and predict the load and generation curves for 15 minutes with accuracy over the 90%. This short-term prediction allows one to carry out the proper actions in order to balance the microgrid status (i.e., get a proper balance between production and consumption with respect to worked requirements).