Self-powered sensors are receiving increasing attention for their environmental friendliness and energy efficiency. In this work, self-powered polyaniline/zinc oxide (PANI/ZnO) heterostructure-based ammonia (NH3) sensor was driven by polytetrafluoroethylene (PTFE)-polyvinylidene fluoride/Ti3C2Tx (PVDF/MXene) piezo-tribo hybrid nanogenerator (PTNG) at room temperature. PVDF/MXene nanofiber membranes were prepared using electrospinning technology to construct a PTFE-PVDF/MXene PTNG. This enhances the effective contact area and dielectric properties of the composite film, thereby increasing the surface charge density. Additionally, the synergy between the triboelectric and piezoelectric effects significantly improves the output performance of the PTNG, effectively enabling energy harvesting for wearable devices. In addition, ZnO/PANI composite materials with a large specific surface area and high active sites were prepared, and a self-powered ammonia sensor was constructed based on the impedance matching effect. Furthermore, by constructing a PANI/ZnO p-n heterojunction, the number of active sites has been increased, significantly enhancing the sensing performance. The sensor has a minimum detection limit of 0.1 ppm, and at an NH3 concentration of 10 ppm, the response rate reaches 96.1 %. This study provides insights for the development of self-powered gas detection systems and holds significant research and practical value in enhancing the performance of NH3 sensors.