The rapid growth of equipment tasks in 5G large-scale machine-type communication scenarios presents challenges due to user equipment’s (UE) limited computing power and power constraints. To address these limitations, task offloading to unmanned aerial vehicles (UAVs) has gained attention. However, traditional cloud computing centres far from the UE fail to meet latency requirements. Mobile Edge Computing (MEC) emerges as a solution by deploying computing servers at the edge of the cellular network to enhance service responsiveness. However, traditional MEC solutions need more flexibility. This paper explores the advantages of UAVs, including flexibility and rapid deployment, and considers UAV power constraints. It proposes a joint optimization approach for user offloading strategies and UAV trajectories to minimize the overall energy consumption of UE. By leveraging the benefits of UAVs and MEC, the proposed method aims to improve task execution efficiency in energy-constrained 5G machine-type communication scenarios.