We present in this work an energy detection algorithm, based on spectral power estimation, in the context of cognitive radio. The algorithm is based on the Neyman-Pearson test where the robustness of the appropriate spectral bands identification, is based, at one hand, on the ‘judicious’ choice of the probability of detection (PD) and false alarm probability (PF). First, we accomplish a comparative study between two techniques for estimation of PSD (Power Spectral Density): the periodogram and Welch methods. Also, the interest is focused on the choice of the optimal duration of observation where we can state that this latter one should be inversely proportional to the level of the SNR of the transmitted signal to be sensed. The developed algorithm is applied in the context of cognitive radio. The algorithm aims to identify the free spectral bands representing, reserved for the primary user, of the signal carrying information, issued from an ASCII encoding alphanumeric message and u