Sometimes, for various reasons, cellular network devices in an area may stop working. This leads to a complete or partial interruption of communications. Here the need arises for the use of unmanned aerial vehicles or UAVs that can provide limited communications coverage. Since these UAVs rely mainly on the energy stored in the internal batteries to provide coverage, we must reduce energy consumption as much as possible. In this paper, we will use the firefly algorithm to determine the best location for the UAVs so that we skip the energy needed to find the best place for coverage, which leads to an increase in the period of providing communications coverage.