Everyone hates running out of batteries. The onset of that red, depleted battery icon on your phone or laptop is a continual annoyance. But it's not just electronic gadgets that suffer from battery constraints. Solar energy — one of our most promising energy technologies — may have a battery problem of its own.

There is plenty of reason to be bullish about solar. Solar energy's potential for cheap energy is unmatched. The amount of solar energy that falls on the Earth in a single year vastly outstrips the total amount of non-renewable energy in the Earth's crust.

Furthermore, the world is draining those supplies of fossil fuels, which have to be dug up or drilled out at ever-higher costs. The confluence of rising global energy demand and dwindling resources has caused energy prices to steadily rise for the last two decades. In addition to posing a civilization-saving alternative to catastrophic climate change, solar would help us keep our energy costs low.

But existing battery technology constitutes a major challenge for advances in renewable energy and the widespread adoption of electric vehicles.

The average American home uses 903 kWh of energy per month, or 32.25 kWh per day. That demand for energy could be met by running a 5kW solar system for between six and seven hours per day. And thanks to years of declining solar costs, a 5kW system with a 20-year life expectancy can cost less than $8,000 after subsidies, plus another $3,000 in installation costs if you can't install it yourself.

Not bad for 20 years of household power. Consider that at current electricity costs of $0.12 per kWh (which may rise further in future), 20 years of electricity for the average U.S. household using 903 kWh per month would cost $26,000.

The problem is that a home's demand for electricity does not necessarily occur at the same time that the sun is out. Homes, of course, need power at night and on cloudy days. Solar systems feed excess power back into the electric grid, which allows homes to draw from the grid when the sun isn't shining, but that still entails a reliance on fossil fuels. (One way to mitigate that would be for governments to build significantly more nuclear power stations, but they have been increasingly reluctant to do so in the wake of the nuclear accident in Fukushima.)

The ideal solution is a big battery that can store at least a day's worth of electricity, if not more for the winter months in colder climates. Such batteries already exist. For example, Tesla uses 60 kWh and 85 kWh batteries in its cars, enough for up to 300 miles of driving, and two to three days of power for an average U.S. household.

The trouble is that each kW of storage carries a whopping price tag of $600 for consumers. Adding a 60 kWh battery to a household solar system would tack on $36,000 to the total cost, lifting the price of 20 years of solar power to at least $47,000. That's way too much — especially considering that the battery could need to be replaced long before a solar panel's 20-year lifespan is up.

The good news is that progress in battery technology is expected to bring costs down significantly. Tesla's Elon Musk expects costs to fall to below $100 per kWh by the end of the decade, thanks to advances in mass battery manufacturing being pioneered in Tesla's Gigafactories. Tesla's aim is to increase its cars' driving range and price their cars more competitively. But it also means that that a 60 kWh system might add only $6,000 to a household solar system.

That means that a self-sufficient household solar system with battery storage would cost only $17,000. And that assumes the costs of solar panels and installation won't continue to fall even further. Remember, too, that Musk doesn't expect this to happen 20 or 30 years from now, but by the end of the decade.

If Musk is right, then we could see the beginning of a virtuous cycle in solar energy. The more solar capacity that is installed, the sooner the price of buying other people's home-generated electricity from the grid will start to fall. Falling grid prices could turn power companies into middlemen between homes, as opposed to merchants of their own electricity.

But the cost of batteries will have to improve first. Only then can solar reach its full potential.