This paper presents an algorithm to optimize the deployment of hubs for smart energy metering based on the Internet of Things. A georeferenced scenario is proposed in which each user must connect to a concentrator, either directly or through another user, minimizing the resources required to achieve connectivity. Consequently, to carry out the optimization, the minimum spanning tree between devices is found, in which the maximum connection distance and the capacity of the hubs are limited. Additionally, this work seeks to achieve a scalable algorithm applicable to any georeferenced scenario to be simulated. The main contribution of this work is an IoT-based smart metering architecture that optimizes resources and adapts to a scenario that changes or integrates more users to the energy metering network without losing the connectivity of the initial users. As a result of the application of the algorithm, a scenario route map is generated. The scenario’s parameters include the number of hops in the network, the optimal number of concentrators and their geographical location, the average number of hops, and the total distance of the path, among others. In this project, a georeferenced urban scenario was considered in which residential areas coexist with intelligent buildings. The scenario has growth stages in which the algorithm is applied, and in each one, the optimal route map is generated.