Photovoltaic power generation and charging of electric vehicles each pose a burden to distribution grids. Controlled charging of electric vehicles can mitigate the fluctuations of photovoltaics and ensure smoother grid operation. This paper presents an optimisation method to adjust the charging power of electric buses to respond to fluctuations from photovoltaic generation. In a case study, the method is applied to electric buses in Singapore using solar irradiance data and operation data of the whole public bus fleet, both in high resolution. Results show that optimal charging of electric public buses considerably smooths the grid load, while leading only to a minor cost increase.