We present a MEMS infrared spectrometer for selective and quantitative chemical gas analysis. It contains a tunable optical filter of porous silicon that allows to measure the infrared absorption of a gas mixture at different wavelengths serially with only one single thermopile detector. This method eliminates drift of the sensor without any reference beam. The filter that measures typically 1.0 x 1.8 mm(2) is tilted by a microactuator to tune it. This wavelength modulation can replace a modulation of the source. Selective sensing of CO2 and CO by their absorption bands at 4.23 mum and 4.65 mum has been shown.