A gas detector includes a predetermined amount of a sensor material having at least one optical property which changes as a result of reaction with a target gas and a photometric device operable to measure the intensity of said at least one optical property of the sensor material. The TMR element has a tunnel barrier layer formed between a magnetization fixed layer and a magnetization free layer, and a cap layer disposed on the magnetization free layer. In addition, the voltage sense compensator ensures that the SR is turned on as soon as its current starts to flow and is turned off when its current falls to zero.