Two new MOFs, namely, [Pb2(2-CPP)2(H2N-bpdc)]n (1) and [Cd(3-CPP)2]n (2), have been prepared by using N- and O-donor ligands and metal ions Pb2+, Cd2+ under hydrothermal conditions. The single-crystal X-ray diffraction analysis was used to measure the crystal structure. The complex 1 is one-dimensional chain structures, and it can further form two-dimensional and three-dimensional supramolecular structures through π-π stacking. The complex 2 is a two-dimensional layered structure, which can form three-dimensional supramolecular structure through π-π interaction. The synthesized MOFs exhibit ligand-based luminescence, which can be attributed to the coordination effect. Due to its excellent fluorescence properties, complex 2 can be used for selective and sensitive detection of nitro aromatic compounds (NAC) and metal ions. The results show that the complex 2 could quickly detect Cr2O72−, nitrobenzene and Fe3+ by fluorescence quenching, and had good anti-interference and cycle stability, so it was a potential chemical fluorescence sensing material. The identification mechanism of 2 is discussed by electron transfer analysis method and density functional theory (DFT) calculation.