Sleep-related issues are common in today's fast-paced society. Traditional sleep analysis methods require complex measurements using electroencephalograms (EEG), electromyograms (EMG), and electrooculograms (EOG). This study develops an automated analysis system using Python programming language combined with deep learning and ensemble voting of machine learning, which analyzes sleep stages solely through electrocardiogram (ECG) signals. By integrating sleep assessment standards, a quantifiable sleep quality evaluation form is established to provide indicators for clinicians to interpret sleep quality. The strength of this research lies in its ability to accurately, objectively, and quickly analyze sleep quality using just one signal, and it features an easy-to-use interface. The results show that the identification accuracy for wake and sleep states is approximately 90%, which is 10-17% higher than similar sleep quality analysis studies. Overall, the accuracy of sleep stage analysis reaches 87%. The methods developed in this study could be applied in clinical medicine to assist physicians in making precise sleep-quality diagnoses for patients.