In this paper, the task processing approach at the edge of the Internet of Things (IoT) network in improving energy consumption was investigated. First, the subject of maximizing the use of energy is defined as the main problem and then based on the state of assignment of task processing from end devices at the edge of the network to smart gateways and local servers at the edge using possible low bandwidth and low battery consumption, the problem is divided into two subject which are obtained independently. After modeling by recombining these two sub-problems, the subject of maximizing the utility gain and battery life of the end devices is solved despite the limitations of processing time and energy resources.Considering that the environment of the problem and how the terminal devices are connected with the edge devices are unknown, a repetitive reinforcement learning algorithm has been used to create an optimal solution to maximize the operational benefit of the energy consumed in edge processing. The results achieved from the simulation show the increase in network load and processing overhead with the increase in the number of active devices. The suggested method, while increasing the edge processing speed, decreases the delay and maximizes the performance gain of the IOT edge system compared to the central cloud system. It should be noted that when the number of active end devices dramatically increases, the energy consumption and bandwidth at the network edge improves, and energy consumption at the network edge decreases lonely by 12.5%.