Stability-enhanced optical sensor