This work presents and discusses the features of a monolithic Programmable Micro Diffractive Grating (PMDG) fabricated over a lithium niobate substrate, which can be used to synthetize the visible and near-infrared spectra of important analytes, including dangerous materials (chemically aggressive, toxic or explosive gases). The functional core of the device consists of a periodic arrangement (array) of ridge waveguides whose optical delay (phase shift) is controlled electrically via the linear electro-optical (Pockels) effect. By distinctly polarizing every waveguide composing the comb with a suitable voltage, the collective transparency of the grating can be tailored so that the output far-field, at a predetermined diffraction angle, may reproduce a spectral distribution of interest. Therefore, this device can serve as universal reference cell in a correlation spectroscopy set-up, with particular interest for safety and security applications, as it could avoid the direct manipulation of dangerous or explosive materials. Moreover, by using a dual colour InGaAs detector, the sensing system can process optical spectra covering an extremely wide wavelength band, from the near UV, (~380 nm), to the MIR (~2.5 μm). In the present article, a schematic description of the sensing system, together with a detailed description of the PMDG device and its programming, will be provided and compared with some experimental data and the corresponding generated synthetic spectra. Examples of simulation of synthetic spectra generation in the case of some gases of interest for safety and security, together with the modelling of the device performances, as a function of the design parameters will also be discussed.