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 yield reduced costs and less environmental pollutants with the least cost and maximum energy absorption. In this study, to calculate the energy requirements of the building, DesignBuilder software was used. To study the solar angles and estimate the energy produced by the solar panels, Polysun software was used after simulating the building energy. Energy simulation results showed that the whole building energy consumption was 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 showed that for the studied building, photovoltaic modules could be used in energy production to reach a zero-energy system connected to the grid with an annual energy balance