Highly ordered, anodically grown TiO2 nanotubes on titanium supports were annealed in ammonia atmosphere in order to incorporate nitrogen doping (<= 2 at.%) in the titanium oxide lattice. FESEM micrographs revealed nanotubes with an average outer diameter of 101.5 +/- 1.5 nm and an average wall thickness of about 13 nm. Anatase crystals were formed inside the tubes after annealing in ammonia atmosphere for 30 min. With further annealing, rutile peaks appeared due to the thermal oxidation of the foil and rise as the duration of heat treatment was increased. The concentration and chemical nature of nitrogen in the nanotube arrays can be correlated to the optical response of dry-pressed heterojunctions of doped TiO2/CH3NH3PbI3 single crystals. The N-TiO2/perovskite heterojunction with the highest amount of interstitial nitrogen exhibited an improved photocurrent, indicating the importance of the semiconductor doping-based heterojunction optimization strategies to deliver competitive levels of halide perovskite-based optoelectronic devices to be envisioned for urban infrastructures.