One of the important problems in the environment is heavy metal pollution, and fluorescence is one of the best methods for their detection due to its sensitivity, selectivity, and relatively rapid and easy operation. In this study, 1,8-diaminonaphthalene functionalized super-stable mesoporous silica (DAN-LUS-1) was synthesized and used as a fluorescence probe to identify Hg2+ and Fe3+ in food samples. The TGA and FT-IR spectra illustrated that 1,8-diaminonaphthalene was grafted into LUS-1. XRD patterns verified that the LUS-1 and functionalized mesoporous silica have a hexagonal symmetrical array of nano-channels. SEM images showed that the rod-like morphology of LUS-1 was preserved in DAN-LUS-1. Also, surface area and pore diameter decreased from 824 m2 g⁻1 and 3.61 nm for the pure LUS-1 to 748 m2 g⁻1 and 3.43 nm for the DAN-LUS-1, as determined by N₂ adsorption–desorption isotherms. This reduction demonstrated that 1,8-diaminonaphthalene immobilized into the pore of LUS-1. The DAN-LUS-1 fluorescence properties as a chemical sensor were studied with a 340/407 nm excitation/emission wavelength that was quenched by Hg2+ and Fe3+ ions. Hg2+ and Fe3+ were quantified using the fluorescence response in the working range 8.25–13.79 × 10–6 and 3.84–10.71 × 10–6 mol/L, with detection limits of 8.5 × 10–8 M and 1.3 × 10–7 M, respectively. Hg2+ and Fe3+ were measured in vetiver grass and spinach. Since the Fe3+ quenching can move in the opposite direction with sodium hexametaphosphate (SHMP) as a hiding compound for Fe3+, consequently, the circuit logic system was established with Fe3+, Hg2+, and SHMP as inputs and the fluorescent quench as the output.