Background: Cardiovascular diseases (CVDs) are common diseases that pose significant threats to human health. Statistics have demonstrated that a large number of individuals die unexpectedly from sudden CVDs. Therefore, real-time monitoring and diagnosis of abnormal changes in cardiac activity are critical, as they can help the elderly and patients handle emergencies in a timely manner. To this end, a round-the-clock electrocardiogram (ECG) monitoring system can be developed with the quick detection of an ECG signal, segmentation of the detected ECG signal, and rapid diagnosis of a single segmented ECG beat. In this paper, to achieve the automatic detection and diagnosis of an ECG signal, five common types of ECG signals are used for recognition. For pre-processing the original ECG signal, the dual-slope detection algorithm is proposed and developed. Then, with the pre-processed ECG data, a five-layer one-dimensional convolutional neural network is constructed to classify five categories of heartbeats, namely, a normal heartbeat and four types of abnormal heartbeats. Results: To be able to compare the results of the experiment, the experimental data used in this study are obtained from the open-source MIT-BIH arrhythmia database. This database is authoritative, as each ECG signal cycle is annotated by at least two cardiologists, and abnormal ECG signals are classified into different categories. By comparing the detection and recognition results in this study with the results annotated in the MIT-BIH arrhythmia database, an overall accuracy of 96.20% is achieved in the classification of normal ECG signals and four categories of abnormal ECG signals.Conclusions: This paper provides an accurate method with low computational complexity for 24-hour dynamic monitoring and automated diagnosis of heartbeat conditions. With wearable devices, this method can be used at home for the initial screening of CVDs. In addition, it can perform diagnosis and warning for postoperative patients or patients with chronic CVDs.