The Internet of things (IoT) is hailed as the next big phase in the evolution of the Internet. IoT devices are rapidly proliferating, owing to widespread adoption by industries in various sectors. Unlike security and privacy concerns, the energy consumption of the IoT and its applications has received little attention by the research community. This paper explores different options for deploying energy-efficient IoT applications. Specifically, we evaluate the use of a combination of Fog computing and microgrids for reducing the energy consumption of IoT applications. First, we study the energy consumption of different types of IoT applications (such as IoT applications with differing traffic generation or computation) running from both Fog and Cloud computing. Next, we consider the role of local renewable energy provided by microgrids, and local weather forecasting, along with Fog computing. To evaluate our proposal, energy consumption modeling, practical experiments and measurements were performed. The results indicate that the type of IoT application, the availability of local renewable energy, and weather forecasting all influence how a system makes dynamic decisions in terms of saving energy.