In this work the sensing mechanism of p-type semiconducting NiO thin films under the exposure to formaldehyde is explained. The influence of the sensing layer thickness and annealing treatment on the structural, optical and electrical properties of the samples is studied. The height of the potential barrier is estimated from temperature-stimulated conductance measurements. The potential barrier height is linked to oxygen ionosorption on the semiconductor surface. Furthermore, Fourier transform-IR analysis was carried out in order to determine the chemical reactions that govern the process of gas detection and the temperature range at which they occur. As a result of the study, it is possible to explain how the thickness and annealing treatment affect the sensing mechanism of the samples.