The determination of buoyancy flux and its contribution to turbulence kinetic energy (TKE) is a fundamental problem in planetary boundary layer (PBL). However, due to the complexity of turbulence, previous studies mainly adopted dimensional analysis and empirical formula to determine TKE budget. This study introduces the endoreversible heat engine model concept to the convective boundary layer (CBL) TKE analysis and establishes a theoretical model based on the first principles. We found that the total contribution of buoyancy to TKE and heat engine efficiency in the boundary layer increase linearly with the boundary layer height. The derived buoyancy flux from our theoretical model is consistent with the results from numerical simulation and dimensional analysis. This heat engine-based theory reveals the physical mechanism of the power of TKE generated by buoyancy. Our theoretical model can replace the empirical value and provide an ideal method for buoyancy flux determination in PBL.