Batteries for efficient energy recovery from wastewater