Nickel oxide (NiO) doped polypyrrole (PPy) was encapsulated in mesoporous SBA-15. All of the synthesized samples were characterized by infrared spectroscopy, X-ray diffraction, and scanning electron microscopy. They were investigated as humidity-sensor materials at room temperature. The sensor showed excellent humidity sensitivity in the relative humidity range 11–95%. The humidity-sensing properties were very much improved by encapsulation of the NiO-doped PPy into mesoporous silica SBA-15. Finally, the sensitivity mechanism was investigated by direct-current (dc) and alternating-current (ac) analysis. The dc circuit with the instantaneous polarity reversion method was designed by us to study the dc response in different humidity environments. The conductive mechanism was established through the dc and ac investigation, and the conductive particles were identified as ions and electrons. © 2009 Wiley Periodicals, Inc. J Appl Polym Sci, 2010