The analysis of cardiac activity is one of the most common elements for evaluating the state of a subject, either to control possible health risks, sports performance, stress levels, etc. This activity can be recorded using different techniques, with electrocardiogram and photoplethysmogram being the most common. Both techniques make significantly different waveforms, however the first derivative of the photoplethysmographic data produces a signal structurally similar to the electrocardiogram, so any technique focusing on detecting QRS complexes, and thus heartbeats in electrocardiogram, is potentially applicable to photoplethysmogram. In this paper, we develop a technique based on the wavelet transform and envelopes to detect heartbeats in both electrocardiogram and photoplethysmogram. The wavelet transform is used to enhance QRS complexes with respect to other signal elements, while the envelopes are used as an adaptive threshold to determine their temporal location. We compared our approach with three other techniques using electrocardiogram signals from the Physionet database and photoplethysmographic signals from the DEAP database. Our proposal showed better performances when compared to others. When the electrocardiographic signal was considered, the method had an accuracy greater than 99.94%, a true positive rate of 99.96%, and positive prediction value of 99.76%. When photoplethysmographic signals were investigated, an accuracy greater than 99.27%, a true positive rate of 99.98% and positive prediction value of 99.50% were obtained. These results indicate that our proposal can be adapted better to the recording technology.