One of the main reasons of environmental pollution is energy consumption in buildings. Today, the use of renewable energy sources is increasing dramatically. Among these sources, solar energy has favorable costs for various applications. This study examined a commercial building in a hot and humid climate. The findings showed that choosing the optimal angle of solar panels with the goal of optimized energy consumption would be reduced costs and environmental pollutants with the least cost and maximum energy absorption. In this study, to calculate the energy requirements of the building was used DesignBuilder software. To study the solar angles and estimate the energy produced by the solar panels was used Polysun software after simulating the building energy. Energy simulation results showed that the whole building energy consumption is 26604 kWh/year. Finally, the evaluation results of solar panels showed that the energy produced by photovoltaic modules at an optimal angle of 31° would be equal to 26978 kWh/year, which is more than the energy required by the building. This system can prevent 14471 kg of carbon dioxide emissions annually. Sustainable energy criteria show that the studied building can be used photovoltaic modules in energy production to reach a zero-energy system connected to the grid with an annual energy balance.