The present disclosure relates to an implantable pacemaker (1), for applying electrical pacing pulses to a heart (H) of a patient, comprising: a pulse generator (2) configured to generate electrical pacing pulses comprising an adaptable rate, at least a first light source (10) configured to emit light comprising a first wavelength, at least a second light source (20) configured to emit light comprising a different second wavelength, a light receiving unit (30) arranged such with respect to the light sources (10, 20) that light emitted from the at least one first or the at least one second light source (10, 20) travels through blood (B) of the patient when the pacemaker (1) is implanted in the patient and impinges on the light receiving unit (30), which is configured to measure an intensity of light received from the at least one first or the at least one second light source (10, 20), and a processing unit (40) configured to determine an actual value of the ratio between a first value of an intensity of light emitted by the at least one first light source (10) and received by the light receiving unit (30) and a second value of an intensity of light emitted by the at least one second light source (20) and received by the light receiving unit (30).