Machine-to-machine communication has emerged as a new communication paradigm to support a variety of applications of Internet of Things (IoT). Meanwhile, energy harvesting (EH) is an increasingly attractive source of power for green networks. In this paper, we study an online strategy of adaptive traffic offloading and bandwidth allocation for EH IoT networks, where machines are powered by grid and green energy jointly. First, we study the energy-aware and adaptive traffic offloading strategy to adaptively balance the non-uniform renewable energy arriving, with the purpose of minimizing the average on-grid energy consumption. Furthermore, the bandwidth allocation strategy to maximize the average sum-rate is proposed. Finally, we validate this paper by simulations and show that the proposed strategy can achieve 55% reduction of the average on-grid energy consumption and over 100% increase of the average sum-rate.