1. Introduction
Urbanization, population growth, and increasing demands for public sanitation services have led to greater levels of sewage sludge production, a by-product of the wastewater treatment process. Traditionally, this was viewed as waste to be disposed of; however, sewage sludge has increasingly become seen as a potential source of renewable energy and agricultural resources. The challenges involved in managing sewage sludge, e.g., high treatment costs, environmental risks, and the need for sustainable practices, have prompted research into alternative uses for this material. One of the most promising strategies is anaerobic digestion, a biological process that converts organic matter into sludge and biogas, a combustible gas primarily comprising methane. This biogas can be then used to generate electricity and heat, thereby improving the energy self-sufficiency of wastewater treatment plants (WWTPs) and reducing greenhouse gas emissions. Notably, methane has a global warming potential that is more than twenty times greater than carbon dioxide. As such, CO
2 and greenhouse gas emissions must be urgently reduced [
1,
2,
3,
4].
Brazil is facing changes in the basic sanitation sector, brought about by the New Legal Framework for Sanitation established by Laws No. 11.445/2007 and No. 14.026/2020 [
5,
6], which aim for universal access by 2033: 99% for drinking water and 90% for sewage collection and treatment. However, over 90 million Brazilians still lack access to sewage collection, with treatment rates rising only slightly from 51.2% to 52.2% between 2021 and 2022 [
7]. According to the Sewage Atlas of the National Water and Basic Sanitation Agency [
8], around 43% of the Brazilian population has access to collected and treated sewage, while 12% use individual solutions, e.g., septic tanks, totaling 55%, with some of these treatment solutions being inadequate. At the current pace, complete universalization may not happen until 2070, and would require investments exceeding R
$509 billion [
9]. This situation also affords an opportunity for energy recovery from the Wastewater Treatment Plants (WWTPs), with biogas production potential in Brazil projected to exceed 97 billion Nm
3 per year by 2031 [
10,
11]. Federal Decree No. 11.003/2022 [
12] promotes the sustainable use of biogas and biomethane, and supports decarbonization and circular economy goals.
The Brazilian RenovaBio program, established by Law No. 13.576/2017 [
13], aims to promote the sustainable expansion of biofuels while reducing greenhouse gas emissions and meeting the Paris Agreement goals [
14,
15]. Biogas produced in WWTPs has become an essential source of renewable energy, especially when converted into biomethane. By including biomethane in RenovaBio, certified producers can issue Decarbonization Credits (CBIOs), providing economic incentives for using treated sewage as an energy source. This integration transforms STPs into active participants in Brazil’s energy transition, contributing to a diversified energy grid and a decarbonized transportation sector [
15,
16,
17].
While wastewater treatment plants (WWTPs) are effective in purifying wastewater, they generally consume a considerable amount of electricity, which is estimated to be between 0.3 and 0.8 kWh per cubic meter. Additionally, anaerobic digestion of excess sludge can only provide about 50% of the total energy consumption required [
18]. Christoforidou et al. [
19] evaluated energy consumption in wastewater treatment plants (WWTPs) in Greece using key performance indicators. They measured specific energy consumption per population equivalent (3 to 150 kWh/Person Equivalent), per cubic meter treated (0.2 to 2.0 kWh/m
3), and per unit of organic load removed (0.03 to 7.13 kWh/CODremoved). Mattio Gebrezgabher [
20] reported an energy demand of 20 to 30 kWh per person per year. The Brazilian Biogas Association (ABiogás) estimates that Brazil’s total technical potential for biogas production is about 84.6 billion Nm
3 per year, mainly from urban sanitation sources like landfills and WWTPs. In the short term, the immediate biogas potential is around 10.8 billion Nm
3 per year, primarily generated from municipal solid waste and sewage effluents [
21]. Probiogas [
22] identified key benefits of biogas energy production as being: decentralized generation, combined heat and power, reduced methane emissions, and potential profits from energy partnerships.
Anaerobic digestion is a crucial process for stabilizing and decreasing municipal sewage sludge [
23]. Results from the Life Cycle Assessment showed that anaerobic digestion has a lower environmental impact than composting, with the difference being between 6.5% and 7.5% [
24]. Anaerobic digestion is a biological process that converts organic materials like sewage sludge into biogas and digestate [
25]. The latter is a mixture of biomass, water, and both inert and undigested solids, with potential fertilizer properties.
Biogas is an energy source, and digestate can be used as a value-added fertilizer [
25,
26]. Biogas technology could be a more appealing option given its compact design, cleaner operation, and the variety of products it generates, including gas for energy and processed solid waste that can be used as organic fertilizer. Methane is the primary component of biogas, retaining approximately 90% of the energy from the substrate [
27]. Furthermore, a sewage treatment plant can continuously produce biogas via anaerobic digestion [
23], and anaerobic digestion more effectively removes pathogens, especially in multi-stage digesters with a pasteurization step. Thus, the resulting byproduct, digestate, can serve as a high-quality fertilizer with improved nutrient availability for plants [
27]. It also affords other benefits, including reduced phosphate levels [
28,
29,
30,
31,
32], making it a sustainable method for producing organic-mineral fertilizers from locally available renewable resources with a low carbon footprint [
33].
Sewage sludge, which includes activated sludge, contains 6–8% nitrogen (N) when measured considering dry matter [
33]. The anaerobic digestion of sludge enhances the breakdown of organic matter, increasing levels of soluble nutrients like total ammonia nitrogen and ortho-phosphate, which plants can easily absorb [
26,
34]. This process also sanitizes sewage sludge, particularly at thermophilic temperatures (50–55 °C) (Smith et al., 2005) [
35], even though it was not originally intended as a method for disinfecting sludge [
35]. In short, an additional benefit is that pathogen reduction can be achieved at mesophilic temperatures (30–35 °C) [
26,
36].
Basrawi et al. [
23] compared biogas-fueled micro gas turbine cogeneration systems with various output powers across different scales of sewage treatment plants under various ambient temperature conditions. The authors concluded that the micro gas turbine cogeneration system, which operates at full load with an energy input similar to biogas produced on-site, was the most efficient. Biogas from sewage digesters contains 55% to 65% methane [
37,
38], 35% to 45% carbon dioxide, and less than 1% nitrogen. Biogas from organic waste digesters, however, has 60% to 70% methane and 30% to 40% carbon dioxide, with less than 1% nitrogen. In landfills, methane content ranges from 45% to 55%, carbon dioxide from 30% to 40%, and nitrogen from 5% to 15% [
37]. It contains smaller levels of contaminants like hydrogen sulfide, nitrogen, water, oxygen, ammonia, and siloxanes, with concentrations varying by gas source [
39]. For biogas containing 75% CH
4, the calorific value is high at 26.9 MJ/m
3 or 7.5 kWh/m
3 [
40].
Rasi and Rintala [
37] examined biogas from a sewage treatment plant serving Jyväskylä, three nearby towns, and two factories. Biogas was produced in two 2750 m
3 digester tanks that stabilized the plant’s sludge. Most of the biogas was used for heat and mechanical energy, with the excess being flared off. Rasi and Rintala [
37] suggest that producing biogas for vehicle fuel is simpler from manure or sewage sludge, given the lower nitrogen and halogenated compound levels, which facilitates upgrading.
Venkatesh and Elmi [
41] developed a methodology for analyzing the economic and environmental aspects of handling sewage sludge biogas in wastewater treatment plants (WWTPs). This approach was applied to the Bekkelaget WWTP in Oslo, Norway, considering 49 option-cost scenarios. Technologies like the Upflow Anaerobic Sludge Blanket (UASB) reactor are becoming increasingly relevant given their effectiveness in treating domestic sewage in tropical regions, and since they can produce biogas during the treatment process [
2,
3,
4]. In contrast, aerobic systems, e.g., activated sludge, have higher energy requirements and require an additional anaerobic digestion stage for energy recovery from the produced sludge [
2,
3,
4]. The two systems have distinct implications regarding investment, operation, and energy production.
In regions with strong agricultural potential, like Ribeirão Preto in São Paulo State, Brazil, the constant demand for intensive energy use and the emphasis on sustainability create a competitive advantage. Integrating sewage treatment with renewable energy generation has several advantages. This approach not only promotes energy efficiency and reduces environmental liabilities but also allows stabilized sludge to be reused as a soil conditioner, thereby supporting circular economy principles.
The Arrudas WWTP in Brazil, operated by COPASA, best exemplifies biogas-based energy cogeneration. It has a capacity of 4500 L per second, serves about 1.5 million residents, and treats 50% of Belo Horizonte’s and 40% of Contagem’s sewage. The facility includes a Small Thermoelectric Power Plant (STP) with three sets of four 200 kW microturbines, totaling 2.4 MW, which meets up to 90% of the plant’s energy needs using methane from sludge biodigesters. The system recycles heat from exhaust gases to enhance anaerobic digestion, thereby increasing biogas production. The project has already received over R
$50 million in investments, resulting in savings of up to R
$2.7 million annually [
42,
43,
44].
This study evaluates and compares the energy potential and economic viability of biomethane production from treated effluent (via UASB) and sludge generated by a continuous flow activated sludge system. This is done by considering their contribution to biogas and biofertilizers separately. To accomplish this, projections for population growth and effluent generation over the next 20 years were considered. We also simulated implementing a wastewater treatment plant in the municipality of Ribeirão Preto-SP. The expected results can inform sustainable infrastructure development strategies that integrate the energy, sanitation, and agriculture sectors.
4. Discussion
According to the projections, Ribeirão Preto, São Paulo, Brazil, is expected to reach an estimated population of 833,982 inhabitants at the end of the 20-year period, i.e., the timeframe established for project implementation. The logistic growth model explicitly accounts for environmental and social factors that influence population growth and incorporates the carrying capacity of the environment [
50]. This model is widely used in demographic studies to predict population dynamics under constraints. Its ability to depict growth patterns makes it a valuable tool for urban planning and resource allocation studies [
50]. The results of this present study indicate significant potential for biogas and methane production from wastewater treatment in Ribeirão Preto, São Paulo, Brazil, highlighting the feasibility of energy recovery from this resource. The estimated methane production for the UASB system was approximately 2277.63 m
3/day with primary sedimentation, and 3235.6 m
3/day without primary sedimentation. In contrast, the estimated methane production in the activated sludge system (ASS) was 1990 m
3/day.
These values corroborate Chernicharo [
2,
79], who highlighted that UASB-type anaerobic reactors can generate between 0.20 and 0.35 m
3 CH
4/kg COD removed, depending on temperature, wastewater characteristics, and system efficiency.
The greater biogas production potential of the UASB system, compared to activated sludge, stems from its anaerobic configuration, which converts organic matter directly into methane without requiring an additional digestion step. This advantage is especially significant in tropical regions, where high average temperatures favor microbial activity and increase process efficiency [
2,
3].
However, this system presents operational challenges, i.e., greater sensitivity to load variations and the risk of accumulated solids.
In this context, it is important to consider potential inhibitors present in industrial wastewater, including effluent from the brewing industry, which was examined in this study. These effluents can lead to the accumulation of volatile fatty acids (VFAs), lowering the pH below 6.5 and thereby inhibiting methanogenic archaeal activity [
2]. Another factor to consider is nutrient imbalance: the inputs of specific industrial effluents may alter the C:N:P (carbon, nitrogen, and phosphorus) ratio, which can limit microbial growth [
3,
60]. Accordingly, future studies should conduct Specific Methanogenic Activity (SMA) and Biochemical Methane Potential (BMP) tests using real samples from the Ribeirão Preto industrial park to validate the theoretical methane yields estimated in this study.
The activated sludge system, while more stable for treatment, consumes more energy and requires a secondary digestion step for energy recovery, which increases operating costs. This comparison highlights that UASB may be more attractive, both from an energy and economic perspective, for cities with a high level of agricultural activity and a favorable climate.
In our study, 0.15 m
3 CH
4/kg COD [
3] yielded conservative estimates, reinforcing the potential to enhance biogas production by 5% through operational improvements. Sustainable biogas production in municipal sewage treatment plants is widely recognized for its benefits, including energy efficiency and nutrient recycling. Recent reviews stress the need for innovative strategies to enhance biogas generation from sewage sludge [
80,
81,
82].
From an energy perspective, the UASB system showed potential electricity generation of 1839.69 MWh/year, whereas the activated sludge system showed 1654.27 MWh/year. Studies show that using biogas for electricity generation significantly enhances the operational sustainability of wastewater treatment plants, meeting approximately 50% to 70% of the sanitation system’s energy demand, contingent on the efficiency of the conversion process [
80,
81,
82].
Bachmann et al. [
82] reported that wastewater treatment plants (WWTPs) achieve electrical self-sufficiency of about 37% in smaller plants (<10,000 population equivalent, PE) and between 68% and 100% in larger plants (>100,000 PE). They also reported that the electrical energy generated by WWTPs ranges from 10 to 20 kWh per population equivalent (PE) per year. Similar values, between 50% and 70%, were reported by Lima et al. [
83]. Hao et al. [
18] evaluated the feasibility of operating carbon-neutral wastewater treatment plants in China and concluded that biogas recovery could supply up to 60% of the plants’ energy demand. The European Biogas Association [
84] reported that anaerobic treatment can reduce energy consumption by up to 75% compared with aerobic treatment.
Outside of Brazil, international studies reinforce the importance of integrating sanitation and energy generation. In Europe, several treatment plants have already achieved energy self-sufficiency, e.g., in Germany and Denmark, which use biogas to meet 100% of their electricity and heat demand [
82,
84]. In China, recent studies demonstrate the potential to operate carbon-neutral sewage treatment plants by combining anaerobic digestion with energy recovery and carbon-credit generation [
18]. These international studies show that adopting UASB and activated sludge systems in Brazil aligns with a global trend toward making sanitation systems more sustainable and energy-efficient.
In economic terms, both systems were viable, exhibiting positive NPV and IRR values, i.e., 14.69% for the activated sludge system, and 16.83% for the UASB system. This reinforces the financial viability of implementing energy recovery units that make use of the generated biogas. Additionally, when compared to the LCOE values reported by Energy Research Office (EPE) [
65] for conventional thermal sources in Brazil, the benefits of these systems become even more apparent (about R
$400/MWh). The analyzed systems showed a lower levelized cost (between US
$ 61.82/MWh and US
$ 81.29/MWh), showing competitiveness and helping to diversify the energy mix.
However, it is important to emphasize that the superiority of the results obtained by the UASB system is contextualized, in this study, within the regional and climatic specificities of the municipality of Ribeirão Preto and consequently of Brazil, where tropical and subtropical areas are present and contribute to the efficiency of anaerobic digestion, which is highly sensitive to operating temperature, showing better performance when the ambient temperature remains in the mesophilic range (between 20 °C and 35 °C), favored in this case by the study region. On the other hand, in temperate regions or cold climates (psychrophilic conditions), the UASB process faces significant challenges, such as reduced biogas yield and the potential for solids accumulation, which would increase both the CAPEX and OPEX of the process due to thermal stabilization. Therefore, while the UASB configuration presents a robust case for energy recovery in the context of sanitation in areas with tropical and subtropical climates, its applicability as a primary treatment stage in colder climate regions requires careful evaluation.
The cash flow analysis showed a payback period of approximately one year for both systems, as shown in
Figure 3, demonstrating real economic advantages and a rapid financial return for the project. The calculated unit costs for biogas production, which ranged from US
$ 0.43 to US
$ 0.52/m
3, were in line with the Brazilian market reference price of US
$ 0.497/m
3. However, these values represent ‘initial costs’ and do not include storage, purification, or transportation costs. Since base costs already account for approximately 86–90% of the market price, external sales may operate with narrow profit margins. Consequently, the project’s strategic viability is better aligned with energy sales, or, in this context, can be maximized through on-site biogas use, which avoids additional logistical costs and leverages the identified economies of scale.
Furthermore, the RenovaBio program (Law No. 13.576/2017) [
13] also represents a strategic opportunity, given the narrow margins in the unit cost of biogas, as it allows biomethane producers to issue Decarbonization Credits (CBIOs). Since methane has a global warming potential that is 20 times greater than CO
2, capturing and transforming methane into fuel significantly contributes to energy transitions and provides an economic incentive that can decouple project viability from natural gas sales. Additionally, the regional economic profile of Ribeirão Preto as a strong agro-technological and biofuel hub offers opportunities for co-digestion. Mixing sewage sludge with organic waste from local agribusiness can substantially increase biogas production without proportionally increasing initial investments. Finally, prioritizing in situ energy recovery for self-consumption can reduce a plant’s electricity demand by up to 70%, thereby protecting the project from logistical costs and fossil fuel market fluctuations.
Table 11 compares the baseline scenario, as described in this article, and a circular integration scenario to highlight the possibilities for economic growth, considering the potential economic opportunities arising from the use and application of the marketable resources involved in this project.
Table 11 clearly shows that although the financial viability of the UASB system is already positive in the current model, the profit margin can be significantly expanded by monetizing environmental externalities. CBIOs can be issued, for example, thereby transforming environmental liabilities into tradable financial assets and protecting the project against fluctuations in the cost of biomethane production. Furthermore, the agricultural application of sludge eliminates landfill costs and generates a high-value-added product for the regional agricultural community.
The tornado diagram shows that the economic feasibility of both technologies is primarily influenced by Net Present Value (NPV), the most sensitive indicator across all scenarios. The Activated Sludge system is more operationally vulnerable, as its profitability is strongly affected by changes in wastewater flow rate (a 47.03% decrease in NPV with a −30% variation). In contrast, the UASB system shows greater financial sensitivity, being most affected by changes in the discount rate (a 53.80% increase in NPV when the rate is reduced by 30%). The analysis confirms consistent economies of scale: increasing the influent flow rate not only raises biomethane production but also systematically reduces LCOE and the unit cost per m3, thereby improving the overall economic efficiency of the systems.
With respect to the discount rate, the results highlight the weight of the cost of capital in long-term feasibility. We observed an inverse relationship of high magnitude in both systems, reducing the rate to 5.6% (a −30% variation), which increases NPV more aggressively than any other variable assessed. In the UASB system, this sensitivity was particularly pronounced, resulting in a 53.80% increase in NPV. For the Activated Sludge (AS) system, the increase was 44.19%. This indicates that UASB is financially more “elastic”, meaning that its economic attractiveness depends critically on low-interest-rate environments or access to subsidized credit lines. In contrast, the impact on LCOE and cost per m3 remained moderate, ranging from 10% to 11%, suggesting that while investor profitability is highly volatile, energy production costs are relatively resilient to macroeconomic changes.
The sensitivity analysis shows that biogas production from urban effluents is technically feasible but financially sensitive. The main warning for managers and investors lies in the mismatch between the relative stability of production costs (LCOE) and the volatility of profitability (NPV). While unit costs remain competitive under moderate variations, returns on capital may be severely impaired by interest-rate fluctuations or disruptions in treatment scale, with the UASB system being more exposed to financial risks and the Activated Sludge system to operational risks.
The agricultural use of treated sludge has proven viable when legal and environmental criteria are met. Brazilian studies indicate that sludge from anaerobic processes, such as UASB, contains significant concentrations of nitrogen (6–8% dry matter) and phosphorus, which can improve soil structure [
3,
60]. International research also confirms that anaerobic digestion reduces pathogens and increases nutrient availability, making the sludge comparable to conventional organic fertilizers [
35]. Thus, agricultural applications should be seen not only as a disposal alternative but also as an integral part of the circular economy and sustainable agriculture.
The findings of this study corroborate Campello et al. [
69], who assessed the economic viability of using biogas generated from WWTPs to produce electricity in Minas Gerais, Brazil. They reported positive NPV and IRR values exceeding 8%, with a payback period of approximately 1.25 years for cities with populations over 250,000. Additionally, Enebe et al. [
85,
86] emphasized the sustainable generation of biogas and syngas from sewage sludge, indicating that anaerobic digestion and gasification are promising methods for energy production.
Sludge from WWTP can meet soil quality standards after anaerobic digestion, provided it meets the criteria set out in CONAMA Resolution No. 498/2020 [
61]. According to this Resolution, digestion must occur for at least 15 days at 35–55 °C or 60 days at 20 °C for Class B biosolids. To reduce vector attractiveness, VS must be reduced by at least 38% or alternative criteria in CONAMA Resolution 498/2020 [
61] must be met. If a 38% reduction in VS is not achieved, the process can still be accepted if laboratory tests show that the same sludge sample has less than a 17% reduction in VS after an additional 40 days at 30–37 °C [
61]. According to Normative Instruction SDA No. 25/2009 [
59], organic fertilizers made from sewage sludge are classified as Class D. These products come from sewage treatment and have specific restrictions [
59]:
− They must be applied using mechanized equipment.
− Prohibited in pastures, and for growing vegetables, tubers, roots, flooded crops, or any crops with edible parts touching the soil.
− Personal protective equipment (PPE) is required during handling and application.
To register Class D fertilizers, you must provide the raw material source, nutrient and contaminant details, and an environmental operating license for using sewage sludge in agriculture. The label must include usage restrictions and recommendations in accordance with relevant authorities [
59].
The application rate of treated sewage sludge as an organic fertilizer should be determined based on the lowest value among the following criteria:
- (1)
The amount of nitrogen available in the biosolids relative to the crop’s needs;
- (2)
The requirement for correcting soil acidity, particularly for biosolids treated through alkaline processes;
- (3)
The maximum annual application rate or accumulated load limits for chemical substances, especially in Class B biosolids;
- (4)
The necessary dose of organic matter for rehabilitating degraded areas [
61].
These calculations must account for soil characteristics, the crop’s nutritional requirements, and established limits to prevent environmental contamination. They should be carried out by a qualified technical manager and included in the application project [
61].
Other factors that also need to be addressed are the efficiency of pathogen removal and the control of heavy metals, to guarantee sanitary safety in the agricultural reuse of sewage treatment byproducts. Comparative studies have shown that UASB systems, although efficient in removing organic load, are limited with respect to microbiological inactivation when operated in isolation. Research indicates that UASB systems reduce thermotolerant coliforms by approximately 1 log, maintaining helminth egg concentrations above 1.0 egg/L, which may make direct reuse in certain crops unfeasible without subsequent disinfection steps [
86,
87]. In contrast, systems that use aerobic processes or combined configurations show superior performance, achieving pathogen removals on the order of 3 logs [
86].
Regarding heavy metals, the literature highlights that elements like Cd, Pb, Cr, and Ni are of critical concern, because they are non-biodegradable and persistent in the soil. Compliance with international standards, like the European Directive 86/278/EEC, establishes strict limits (e.g., Cd: 20–40 mg/kg; Pb: 750–1200 mg/kg), serving as a basis for monitoring the quality of biosolids [
88]. The controlled application of stabilized sludge not only reduces the environmental impact of landfill disposal but also promotes the circular economy by recycling essential nutrients, provided that the treatment ensures the effective reduction in these contaminants and pathogens to levels safe for human and animal consumption.
The integration of sewage treatment and agriculture promotes resource recycling, reduces environmental risks, and supports sustainable agricultural practices. These findings acquire particular significance when considered in the context of Ribeirão Preto. With a GDP per capita of R
$55,484.91 (2021) and a Human Development Index of 0.800 (2010) [
46], the city demonstrates strong socioeconomic indicators. Its economy is deeply rooted in agribusiness and biofuel production, sectors that already integrate biotechnology, clean energy, and advanced materials [
45,
46,
47]. The presence of five development hubs, particularly in biofuels, agritech, and technology, underscores the region’s readiness to adopt and expand renewable energy initiatives, such as biogas recovery from wastewater [
45,
46,
47]. Therefore, integrating sewage treatment with energy and agricultural applications not only addresses environmental and sanitation challenges but also aligns with the region’s broader economic and technological development strategy.