Background: Atrial fibrillation is a type of persistent arrhythmia that can lead to serious complications. Therefore, accurate and quick detection of atrial fibrillation by surface electrocardiogram has great importance on further treatment. The practical electrocardiogram signals contain various interferences in different frequencies, such as myoelectricity interference, power interference and so on. Detection speed and accuracy largely depend on the atrial fibrillation signal features extracted by the algorithm. But some of the discovered atrial fibrillation features are not well distinguishable, resulting in poor classification effect. Methods: This paper proposed a high distinguishable frequency feature - the frequency corresponding to the maximum amplitude in the frequency spectrum. We used the R-R interval detection method optimized with the mathematical morphology method and combined with the wavelet transform method for analysis. According to the two features - the maximum amplitude in the frequency spectrum and R-R interval irregular, we could recognize atrial fibrillation signals in electrocardiogram signals by decision tree classification algorithm. Results: The data used in the experiment come from the MIT-BIH database, which is publicly accessible via the web and with ethical approval and consent. Based on the input of time-domain and frequency-domain features, we classified sinus rhythm signals and AF signals using the decision tree generated by classification and regression tree (CART) algorithm. From the confusion matrix, we got the accuracy was 98.9%, sensitivity was 97.93% and specificity was 99.63%. Conclusions: The experimental results can prove the validity of the maximum amplitude in the frequency spectrum and the practicability and accuracy of the detection method, which applied this frequency-domain feature. Through the detection method, we obtained good accuracy of classifying sinus rhythm signals and atrial fibrillation signals. And the sensitivity and specificity of our method were pretty good by comparison with other studies.