Abstract In this study, p-type ZnO films with excellent electrical properties were prepared by ultrasonic spray pyrolysis (USP) combining with a N–Al codoping technique. The influence of the substrate temperature and annealing temperature on electrical properties of ZnO films was investigated. The growth and doping process of ZnO films was explored by thermogravimetry, differential scanning calorimetry and mass spectrum (TG–DSC–MS) measurements. It is suggested that the variation of electrical properties of ZnO films with the substrate temperature and annealing temperature results from the removal of H element out of the films.