This paper proposed a novel real-time algorithm for electrocardiogram (ECG) signal analysis using the first derivative and automatic threshold to locate the R-peaks. First, the ECG signals are filtered by Butterworth low pass filter to reduce the high frequency noise. Then, the first 10[Formula: see text]s datasets of the first derivative of ECG signal are analyzed to search the maximum value. Three process thresholds are computed using this maximum value, which is used to avoid the missed and false peak detections. Thus, a threshold is automatically calculated using these searched maximum values, and divide the differentiated ECG to obtain two intersection points. Recording the time of these two intersection points, a time interval is formed for the differentiated ECG. Delaying this time interval for specific sampling periods, a new time interval is acquired for the corresponding ECG cycle. Finally, the local maximum in an ECG cycle is narrowed down in this new time interval such that the R-peak can be located. The MIT-BIH Arrhythmia Database of 48 ECG recordings is used to verify the proposed algorithm. On this dataset, the proposed algorithm yielded mean sensitivity of 99.17%, positive predictivity of 97.37% and average time error of 1.01[Formula: see text]ms.