I watched the piles of feces go up the conveyer belt and drop into a large bin. They made their way through the machine, getting boiled and treated. A few minutes later I took a long taste of the end result: a glass of delicious drinking water.

The occasion was a tour of a facility that burns human waste and produces water and electricity (plus a little ash). I have visited lots of similar sites, like power plants and paper mills, so when I heard about this one—it’s part of the Gates Foundation’s effort to improve sanitation in poor countries—I was eager to check it out.

The water tasted as good as any I’ve had out of a bottle. And having studied the engineering behind it, I would happily drink it every day. It’s that safe.

Here’s a short video from my visit in November, which explains how it all works:

Why would anyone want to turn waste into drinking water and electricity?

Because a shocking number of people, at least 2 billion, use latrines that aren’t properly drained. Others simply defecate out in the open. The waste contaminates drinking water for millions of people, with horrific consequences: Diseases caused by poor sanitation kill some 700,000 children every year, and they prevent many more from fully developing mentally and physically.

If we can develop safe, affordable ways to get rid of human waste, we can prevent many of those deaths and help more children grow up healthy.

Western toilets aren’t the answer, because they require a massive infrastructure of sewer lines and treatment plants that just isn’t feasible in many poor countries. So a few years ago our foundation put out a call for new solution.

One idea is to reinvent the toilet, which I’ve written about before.

Another idea—and the goal of the project I toured—is to reinvent the sewage treatment plant. The project is called the Omniprocessor, and it was designed and built by Janicki Bioenergy, an engineering firm based north of Seattle. I recently went to Janicki’s headquarters to check out an Omniprocessor before the start of a pilot project in Senegal.

The Omniprocessor is a safe repository for human waste. Today, in many places without modern sewage systems, truckers take the waste from latrines and dump it into the nearest river or the ocean—or at a treatment facility that doesn’t actually treat the sewage. Either way, it often ends up in the water supply. If they took it to the Omniprocessor instead, it would be burned safely. The machine runs at such a high temperature (1000 degrees Celsius) that there’s no nasty smell; in fact it meets all the emissions standards set by the U.S. government.

Before we even started the tour, I had a question: Don’t modern sewage plants already incinerate waste? I learned that some just turn the waste into solids that are stored in the desert. Others burn it using diesel or some other fuel that they buy. That means they use a lot of energy, which makes them impractical in most poor countries.

The Omniprocessor solves that problem. Through the ingenious use of a steam engine, it produces more than enough energy to burn the next batch of waste. In other words, it powers itself, with electricity to spare. The next-generation processor, more advanced than the one I saw, will handle waste from 100,000 people, producing up to 86,000 liters of potable water a day and a net 250 kw of electricity.

If we get it right, it will be a good example of how philanthropy can provide seed money that draws bright people to work on big problems, eventually creating a self-supporting industry. Our foundation is funding Janicki to do the development. It’s really amazing to see how they’ve embraced the work; founder Peter Janicki and his family have traveled to Africa and India multiple times so they can see the scope of the problem. Our goal is to make the processors cheap enough that entrepreneurs in low- and middle-income countries will want to invest in them and then start profitable waste-treatment businesses.

We still have a lot to learn before we get to that point. The next step is the pilot project; later this year, Janicki will set up an Omniprocessor in Dakar, Senegal, where they’ll study everything from how you connect with the local community (the team is already working with leaders there) to how you pick the most convenient location. They will also test one of the coolest things I saw on my tour: a system of sensors and webcams that will let Janicki’s engineers control the processor remotely and communicate with the team in Dakar so they can diagnose any problems that come up.

The history of philanthropy is littered with well-intentioned inventions that never deliver on their promise. Hopefully, these early steps will help us make sure the Omniprocessor doesn’t join the list. If things go well in Senegal, we’ll start looking for partners in the developing world. For example I think it could be a great fit in India, where there are lots of entrepreneurs who could own and operate the processors, as well as companies with the skill to manufacture many of the parts.

It might be many years before the processor is being used widely. But I was really impressed with Janicki’s engineering. And I’m excited about the business model. The processor wouldn’t just keep human waste out of the drinking water; it would turn waste into a commodity with real value in the marketplace. It’s the ultimate example of that old expression: one man’s trash is another man’s treasure.