Hydrothermal reaction of the multidentate N-donor ligand 1-((1H-1,2,4-triazol-1-yl)methyl)-3-(4-pyridyl)-5-(2-pyridyl)-1,2,4-triazole (2,4′-tmbpt), 5-hydroxy-1,3-benzenedicarboxylic acid (5-OH-H2bdc), and Cd(CH3COO)2·2H2O in the presence of NaOH afforded a coordination polymer [Cd(2,4′-tmbpt)2(5-OH-bdc)]·5H2O (1), which exhibits a 1D→2D→3D supramolecular architecture. The photoluminescent spectra of the compound in different aqueous solutions in the pH range of 1–14 have been investigated. The results indicate that compound 1 can be used as an efficient pH fluorescent sensor and molecular logic gate. The pH sensing mechanism of the compound has been discussed and proved by the UV–Vis spectra.