Here we report the utilization of p-p isotype heterojunctions for improving the CO2 gas sensing performance of polyaniline (Pani)/hierarchical mesoporous LaFeO3 (LFO) at room temperature and high humidity (~90%). Our findings show that the partial protonated of Pani and different wt% of LFO have a significant effect on CO2 gas sensing. The Pani/LFO nanocomposite (PLFO) gas sensor with 10 wt% LFO exhibited 13.20 times higher gas sensitivity to 20,000 ppm of CO2 compared to pure Pani gas sensor. All of the sensors had a dynamic response to 5000, 10,000 and 20,000 ppm of CO2 gas at ~90% humidity. The good long-term stability after one year is observed for the sensor based on PLFO. Moreover, CO2 gas mechanism of the PLFO sensors were studied in details. The advantages of p-p heterojunctions could provide a new perspective for CO2 gas sensing applications.