This paper describes the spectroscopic detection of gases using macroporous silicon photonic crystals as narrow filters. The study begins by demonstrating the feasibility of photoelectrochemical etching to fabricate narrow filters along the mid infrared band. Next, we focus on the filter centered on the carbon dioxide fingerprint. The filter response is described for three different cell lengths and concentrations below 1%. Results show a concordance with the reformulated Beer-Lambert law. This can be used to predict the response of the filter for longer path lengths and higher concentrations, showing broad working ranges and compact sizes for CO 2. In addition, optical robustness to external variations and long-term stability are also reported. Results are extrapolated to other macroporous silicon filters centered on the absorption spectra of N 2 O, OCS, NO 2 and SO 2. Finally, high sensitivity and selectivity is demonstrated by comparing them with some commercial filters.