Energy detection is an attractive spectrum sensing method for cognitive radio. The design of energy detection relies on two critical assumptions: 1) noise power is perfectly and {\it a prior} known; and 2) the test statistics in energy detection can be accurately modeled as independent and identically distributed (i.i.d.) Gaussian random variables. In practice, noise power varies from time to time. This renders difficulty in estimating noise power and incurs an inaccuracy in modeling the test statistics. This paper studies how to realize energy detection using software-defined radio in a real environment. The noise power variation in a real environment is investigated. A histogram based method is proposed to determine the threshold of energy detection. Our experimental study shows the effectiveness of the histogram based method.