Atrial fibrillation is one of the most common arrhythmias in clinics, which has a great impact on people's physical and mental health. Electrocardiogram (ECG) based arrhythmia detection is widely used in early atrial fibrillation detection. However, ECG needs to be manually checked in clinical practice, which is time-consuming and labor-consuming. It is necessary to develop an automatic atrial fibrillation detection system. Recent research has demonstrated that deep learning technology can help to improve the performance of the automatic classification model of ECG signals. To this end, this work proposes effective deep learning based technology to automatically detect atrial fibrillation. First, novel preprocessing algorithms of wavelet transform and sliding window filtering (SWF) are introduced to reduce the noise of the ECG signal and to filter high-frequency components in the ECG signal, respectively. Then, a robust R-wave detection algorithm is developed, which achieves 99.22% detection sensitivity, 98.55% positive recognition rate, and 2.25% deviance on the MIT-BIH arrhythmia database. In addition, we propose a feedforward neural network (FNN) to detect atrial fibrillation based on ECG records. Experiments verified by a 10-fold cross-validation strategy show that the proposed model achieves competitive detection performance and can be applied to wearable detection devices. The proposed atrial fibrillation detection model achieves an accuracy of 84.00%, the detection sensitivity of 84.26%, the specificity of 93.23%, and the area under the receiver working curve of 89.40% on the mixed dataset composed of Challenge2017 database and MIT-BIH arrhythmia database.