A method of calibrating a sensor comprising performing a first calibration cycle comprising: measuring a first sensor response to exposure to a first calibration fluid having a first concentration at a first temperature measuring a second sensor response to a second calibration fluid having a second concentrations at a second temperature determining a temperature dependence in the sensitivity of the sensor from the first and second response and performing a second calibration cycle by repeating the first calibration cycle after a time interval deriving a temperature dependent drift function for the sensor from the difference in the temperature dependence determined in the first and second calibration cycles and generating a calibration curve including the temperature dependent drift function. Also claimed is an apparatus for monitoring an analyte concentration in a bodily fluid comprising: a sample chamber comprising a sensor a fluid line connected to the sample chamber a temperature control element a signal processor coupled to the sensor and a computer program for implementing the method of the invention. Preferably the apparatus is a cardiopulmonary bypass apparatus.