Summer season in Barcelona is about six months long. The hottest and the driest months are July and August. At that time the temperature is stable, about 28–29 °C. There can be occasional heatwaves but temperatures above 34 °C are rare.
In May and June Barcelona enjoys long sunny days with 15 hours of daylight. It can rain for just two days per month. But thunderstorms are common from mid-July until November.
In September it starts raining more often, but the temperature is still quite high. October is the wettest month in Barcelona with six rainy days. That means your chances to get soaked are still not that high. Seawater stays above 20 °C from June until the end of September. The warmest month for swimming is August.