Mobile user equipment relay (UER) has been introduced by 3GPP to enhance communication reliability through device-to-device (D2D) communications. However, as UER needs to use its own power to forward other user's data, D2D communication may be unreasonable to the UER. To overcome this issue, motivated by the recent progress in energy harvesting (EH) techniques, we propose a D2D communication provided EH heterogeneous cellular network (D2D-EHHN), where UERs harvest energy from an access point (AP) and use the harvested energy for D2D communication. We first derive the UER distribution according to the EH parameters, and then propose opportunistic D2D communication scheme to determine the transmission mode based on the best UER location. We then explore the effect of network parameters on the outage probability. Particularly, we show that having a high EH efficiency at user equipments (UEs) does not always improve the performance of D2D-EHHN, especially for dense network, and also how EH parameters affect the optimal offloading bias that minimizes the outage probability of D2D-EHHN.