It was a very hot, stormy Fourth of July weekend in much of the country. More than 20 cities hit record highs, many in the triple digits. Philadelphia, for one, hit 101 degrees for three days in a row for the first time since records started being kept in the 1870s. Extreme heat puts pressure on the power grid, but this weekend, it was up to the challenge.Cape Cod in Massachusetts didn’t even get the worst of the heat wave: It only made it into the 90s. Still, Barbara Kates-Garnick, a professor of the practice of energy policy at The Fletcher School at Tufts University, said it was hot. “We had a lot of times when our electricity fluctuated on and off, lights flickered,” Kates-Garnick said. “So, we were very aware that there was an issue with the power grid.”It wasn’t just the Cape. The power kept flickering on and off in other places, too, including Philadelphia and New York.“I think it shows that at the local level, there are a lot of concerns that need to be addressed, because we've come to a time when we're using more electricity,” Kates-Garnick said. “The population is increasing.”And the physical infrastructure that makes up the grid is getting old — much of it was built more than 50 years ago.But for all the strain, “the grid held up pretty well over this long weekend,” said Charles Hua, founder and executive director of PowerLines, a national energy consumer education nonprofit.Hua said despite intense demand and some flickering, lights and air conditioning stayed on for most people. “We're doing a better job of managing and operating the grid,” he said. “And part of what that looks like is directing consumers to be more proactive and adopting certain measures like turning off their lights or conserving energy at different parts of the summer days when the grid is particularly stressed.”The addition of more renewables has also helped relieve stress on the grid. In the Mid-Atlantic — which saw what was likely record demand during the heat wave — Michael Goggin, executive vice president at the consulting firm Grid Strategies, said solar performed well.“The solar output was consistently high every day last week during these high-demand periods,” Goggin said. “So, that really helped keep the lights on.”To help keep the lights on in the future, he said we also need to build more new transmission lines, including between regions.“Expanding transmission is particularly valuable in events like this, because … these [extreme weather] events are not that large,” Goggin said. “And so, if your region is short, you can buy power from your neighbor. And then maybe this winter, it'll be the reverse.”