SummaryThis work proposes a real‐time and online energy scheduling optimization algorithm for nanosatellites operating with a direct energy transfer (DET) architecture. The goal of the algorithm is to optimize energy utilization by maximizing energy harvesting, meeting task deadlines and priorities, and ensuring a minimum quality of service (QoS) for the system. The algorithm is composed of a modified perturb and observe algorithm to reach the best energy efficiency point of the solar panels, a task prioritization algorithm to guarantee their times and minimum QoS, and a backpack optimization problem to maximize the energy efficiency of the satellite. To demonstrate the effectiveness of the proposed algorithm, simulations of a nanosatellite operating in a given orbit, attitude, and thermal parameters were conducted and compared to other task scheduling strategies. The results showed that the proposed energy scheduling algorithm had the best performance in terms of energy balance and average power consumption, with an energy balance up to 16% higher compared to the other tested strategies. This demonstrates the ability of the proposed algorithm to optimize power consumption and energy utilization, as well as efficiently schedule tasks to maximize energy harvesting. The proposed energy scheduling optimization algorithm has the potential to be a useful tool for the design and optimization of future satellite missions and could potentially guide the design of electrical power systems for new CubeSat missions operating with a DET architecture. The algorithm's ability to optimize energy utilization and ensure a minimum QoS for the system could improve the overall efficiency and performance of the satellite.