Virtual batteries composed of aggregated thermostatically controlled loads are able to provide real-time frequency regulation to electrical grids. Load flexibility management can be helpful in solving the problem of balancing generation and demand, which is becoming more complex due to the variability of renewable energies. A real-time virtual battery control system is presented in this paper. As an example, a virtual battery of 1000 thermostatically controlled loads is operated. In order to quantify the potential of virtual batteries, a study focused on residential thermostatically controlled loads in Spain is reported.