Water is a vital resource in our society, not only for human consumption but for any kind of activity (food production, industrial processes…). During human activity, we contaminate water streams, so, before they can be returned to water bodies, such as lakes or rivers, they must be decontaminated. There is where wastewater treatment plants (WWTP) come into play. WWTP are the facilities where all the wastewater that we produce is treated to remove organic matter, solids and nutrients before it is returned to the environment . During their operation , WWTP become important energy consumers. In the U.S., wastewater treatment accounts for 3 – 4% of national electrical demand, being the electric power consumption the highest operation cost in these plants (more than 30%) .
During their operation, WWTP generate a big volume of sewage sludge, around 250 grams of dry solids per m3 of treated wastewater. Sewage sludge is produced during the primary and secondary settling (Figure 1) and it is mainly composed of the organic matter and solids removed from wastewater, being usually rich in nutrients . Furthermore, sewage sludge cannot be directly disposed, but it requires prior treatment and its management accounts for 30% of WWTP operating costs . Therefore, it is crucial to apply strategies that enables a sustainable management of the sludge, allowing to get the most of it.
Anaerobic digestion is a widespread technology that allows generation of renewable energy in the form of biogas during sewage sludge treatment. During this process, microorganisms break down the organic matter present in the sludge into smaller molecules, producing biogas. Biogas is formed by a mixture of mainly methane and carbon dioxide and it can be used as a fuel for heat and electricity generation .
However, sewage sludge cannot be directly used from primary and secondary settling for anaerobic digestion. The generated sludge goes through a series of process in the WWTP (Figure 2) . First, the sludge is sieved and thickened to reduce the content of water and hence the energy consumed during its digestion. The thickened sludge is then pumped into the digesters and continuously stirred in anaerobic conditions at mesophilic temperatures (35 – 42 °C) during a retention time of around 20 days. About a third part of the solid matter from the sludge is transformed into biogas during digestion, so the digested sludge becomes again very liquid and needs to be dewatered before its final disposal. Dewatering of the sludge is normally achieved by mechanical pressure or centrifugation, although sometimes it can be heat dried to remove even more water. The dewatered sludge can then be used for agriculture, disposed in a landfill or sent to an incineration plant . Finally, as a result of the dewatering process, a liquid stream with a high concentration of contaminants is produced and recirculated to the entrance of the WWTP .
During the anaerobic digestion, biogas is produced by biological breakdown of the biomass. Typical composition of biogas from sewage sludge consists of 60 – 67% methane, 33 – 40% carbon dioxide and traces of other compounds such as hydrogen, nitrogen, siloxanes and hydrogen sulphide . Due to its high methane content, this biogas is a source of energy that is commonly used in WWTP to cover some of their energy demand. Biogas can be used to produce heat directly in a boiler, just as we all do at home. However, the most common application for the biogas produced in wastewater treatment plants is its use in Combined Heat and Power (CHP) units (systems that produce both, electricity and heat, from a single fuel source) . Combustion engines and micro turbines are the most widely used CHP technologies, although some alternatives such as fuel cells are attracting attention due to their higher electrical efficiency , . The heat and electricity produced through these CHP units is used in the WWTP to reduce the energy demand. Heat autonomy is generally achieved with the biogas, and the electrical consumption can be reduced from 30 to 70%, depending on the WWTP size . Furthermore, some technologies aim to go even further to maximize the biogas production by co-digestion of other organic wastes from the WWTP itself (such as the grease removed in the pre-treatment)  or from other sources (such as food wastes or municipal solid wastes) . Lastly, the biogas produced can be upgraded (i.e. increasing its methane content) so it can be used as a vehicle fuel or even injected to the natural gas grid .
Summarising, water and energy are vital and inseparably connected resources. Wastewater treatment processes consume a large amount of energy, which is translated into environmental, social and economic impacts. Anaerobic digestion at WWTP is a technology that produce biogas, a green energy source that can help reducing the footprint of the water cycle and supposes a step-forward towards a more sustainable society.
 J. Palatsi, F. Ripoll, A. Benzal, M. Pijuan, and M. S. Romero-güiza, “Enhancement of biological nutrient removal process with advanced process control tools in full-scale wastewater treatment plant,” Water Res., vol. 200, p. 117212, 2021, doi: 10.1016/j.watres.2021.117212.
 Y. Shen, J. L. Linville, M. Urgun-Demirtas, M. M. Mintz, and S. W. Snyder, “An overview of biogas production and utilization at full-scale wastewater treatment plants (WWTPs) in the United States: Challenges and opportunities towards energy-neutral WWTPs,” Renew. Sustain. Energy Rev., vol. 50, pp. 346–362, 2015, doi: 10.1016/j.rser.2015.04.129.
 N. Bachmann, J. la C. Jansen, D. Baxter, G. Bochmann, and N. Montpart, “Sustainable biogas production in municipal wastewater treatment plants,” IEA Bioenergy, 2015.
 A. Thornton, P. Pearce, and S. A. Parsons, “Ammonium removal from digested sludge liquors using ion exchange,” Water Res., vol. 41, no. 2, pp. 433–439, 2007, doi: 10.1016/j.watres.2006.10.021.
 A. Kiselev, E. Magaril, R. Magaril, D. Panepinto, M. Ravina, and M. C. Zanetti, “Towards Circular Economy: Evaluation of Sewage Sludge Biogas Solutions,” Resources, vol. 9, no. 91, pp. 1–19, 2019.
 M. MosayebNezhad, A. S. Mehr, M. Gandiglio, A. Lanzini, and M. Santarelli, “Techno-economic assessment of biogas-fed CHP hybrid systems in a real wastewater treatment plant,” Appl. Therm. Eng., vol. 129, pp. 1263–1280, 2018, doi: 10.1016/j.applthermaleng.2017.10.115.
 D. M. Riley, J. Tian, G. Güngör-Demirci, P. Phelan, J. Rene Villalobos, and R. J. Milcarek, “Techno-economic assessment of CHP systems in wastewater treatment plants,” Environ. – MDPI, vol. 7, no. 10, pp. 1–32, 2020, doi: 10.3390/environments7100074.
 M. Gandiglio, F. De Sario, A. Lanzini, S. Bobba, M. Santarelli, and G. A. Blengini, “Life cycle assessment of a biogas-fed solid oxide fuel cell (SOFC) integrated in awastewater treatment plant,” Energies, vol. 12, no. 9, 2019, doi: 10.3390/en12091611.
 M. S. Romero-Güiza, J. Palatsi, X. Tomas, P. Icaran, F. Rogalla, and V. M. Monsalvo, “Anaerobic co-digestion of alkaline pre-treated grease trap waste: Laboratory-scale research to full-scale implementation,” Process Saf. Environ. Prot., vol. 149, pp. 958–966, 2021, doi: 10.1016/j.psep.2021.03.043.
 S. Vinardell, S. Astals, K. Koch, J. Mata-Alvarez, and J. Dosta, “Co-digestion of sewage sludge and food waste in a wastewater treatment plant based on mainstream anaerobic membrane bioreactor technology: A techno-economic evaluation,” Bioresour. Technol., vol. 330, no. January, p. 124978, 2021, doi: 10.1016/j.biortech.2021.124978.