An optical sensor comprises a sensing element comprising a
waveguide grating with a response that varies with an effective
modal index experienced by light propagating in the
grating and a sample window for receiving fluid which affects the effective
modal index to modify the response, the sensing element arranged to receive light from a
light source and to output the light after filtering; and an analysing element comprising a second
waveguide grating having a second response, and arranged to receive light output by the sensing element and to output the light after filtering for detection by an
optical power detector. The combination of the two gratings converts changes in the
wavelength of light output by the sensing element in response to the sample of fluid to changes in the amount of light, allowing the fluid index to be deduced from a measurement of
optical power. The two elements may be fabricated on a single substrate to reduce errors from environmental disturbances such as temperature changes.