A method and an electronic device for detecting a heart
rhythm are provided. The method comprises: acquiring a first PPG
signal in a first preset time length; determining a plurality of
heart rate values based on the first PPG
signal; determining a difference value of each two adjacent heart rates based on the plurality of
heart rate values, the difference value of each two adjacent heart rates being used to generate a
heart rate difference value trajectory graph; acquiring parameters of a heart
rate difference value trajectory based on the heart
rate difference value trajectory graph, the parameters of the heart
rate difference value trajectory comprising one or more of the following parameters: an angle, a number, an angle standard deviation, a distance standard deviation; determining a heart
rhythm type of the first PPG
signal according to the parameters of the heart rate difference value trajectory, the heart
rhythm type comprising any one of the following: a premature beat, an
atrial fibrillation, a
sinus rhythm, a
ventricular tachycardia, a bigeminy, a trigeminy; and displaying the heart rhythm type of the first PPG signal, which can improve the accuracy of identifying a premature beat or an
atrial fibrillation, reduce the probability of identifying a premature beat as an
atrial fibrillation, and improve user experience.