Introduction

The presence of dyes in water is one of the major causes of water pollution, even at low concentrations, because of their high solubility in water and resistance to bio-degradability [1, 2]. These toxic substances have a detrimental impact on aquatic life, not only because they prevent light from reaching aquatic plants, which hinders the photosynthesis process, but also because they reduce the oxygen ratio in water [3]. For these reasons, the current challenge is discovering an efficient technique to protect the environment from these toxic issues.

In reason of environmental protection, various techniques have been applied in textile industries to eliminate dye from wastewater before being discharged, such as oxidation[4], flocculation [5], membrane filtration [6], biodegradation [7], adsorption [8], electrochemical method [9], photo-oxidation [10]. Adsorption using Carbonaceous materials is supposed to be a better choice for water depollution because of its noticeable surface area, thermal stability, favorable porous structure, high dyes adsorption capacity, and low environmental impact.

The production of a potential activated carbon needs physical and chemical processes that could be costly or consume energy, so endeavors are focused on using economical, renewable, and sustainable sources of the initial precursor [11]. In this pursuit, agricultural wastes are the most commonly applied precursors for activated carbon production, such as rubber leaf [12], sorghum straw[13], Dacryodes edulis seeds[14], rice husk [15], soursop seeds [16], Ficus carica bast [17], and fig grape leaves [18]. Leucaena leucocephala is known for its expeditious growth as an arboreal plant, attaining heights of up to 20 m. This tree is well-known all over the world and grows over an area that is thought to be between 2 and 5 million hectares. A notable feature of this tree is its ability to generate an ample amount of pods on many occasions throughout the year, making it a renewable and accessible resource suitable for exploitation as a precursor in the production of activated carbon [19].

The quality of the carbon produced by the activation process is significantly influenced by the activation conditions that modify the surface proprieties and the adsorption capacity, these conditions include the biomass source, the method of activation, and the chemical activator choice [20]. Chemical activation has been demonstrated as an effective method for preparing potentially activated carbon with highly porous structures. This method provides a significant benefit by requiring lower pyrolysis temperatures and shorter processing periods. Furthermore, it exhibits the potential of creating a high surface area surpassing what can be achieved by the physical activation method [21]. Chemical activation involves the impregnation of the biomass in a chemical activator solution with a specific concentration followed by subjecting the mixture to a thermal treatment. Commonly used activators for chemical activation are H2SO4, KOH, NaOH, Zncl2, KMnO4, HNO3, H2O2, H3PO4, and K2CO3. These activators play a crucial role in enhancing the porosity and adsorption capacity of the produced carbon [22, 23].

Drawing from the previous works on LP biomass, some studies reported the basic activation of LP waste by NaOH where it was applied for the adsorption of dyes and heavy metals [24], while the acidic activation using H3PO4 as a chemical activator of LP biomass has not been explored yet. Furthermore, phosphoric acid has been chosen in various studies for its potential to interact with biomass surface, creating high porosity and surface area [25], as demonstrated in previous studies [26,27,28,29,30].

To maximize the efficiency of dye removal, it is essential to optimize the experimental conditions. Response surface methodology (RSM) is a statistical technique that involves the simultaneous variation of the experimental factors to maximize the response, while considering their interaction effects. Furthermore, this technique offers a comprehensive study of how variables influence the response with fewer sets of experiments. In the current study Box Benken design was applied for several reasons, including the efficiency of this model in providing a precise approach to the results and the economic aspect of this model, which offers a reduced set of experiments [31].

The objective of this study is to valorize agricultural wastes in the preparation of ecofriendly activated carbon which demonstrates promising capabilities in textile dye elimination from wastewater. Additionally, the research delves into comprehending the adsorption behavior through isotherm, kinetic, and thermodynamic study, besides the physicochemical characterizations (FTIR, SEM–EDS, TGA, BET, pHpzc) that enhance the identification of the various interactions that occur on the activated carbon structure.

Materials and methods

Preparation of the activated carbon (LP-AC)

Following the washing and drying steps, LP pods was further processed through a grinder to achieve a particle size of 250 μm. The activated carbon was prepared by the impregnation of the biomass in phosphoric acid with concentration of 98% (w/v) and predetermined mass ratio of (1/3), (biomass/H3PO4), the mixture was stirred for 4 h to ensure the homogenization of the slurry, then dried in an oven for 24 h at 100 °C. After that, the sample was subjected to pyrolysis in a muffle furnace at 500 °C for 55 min. The carbonized sample was washed abundantly with hot distilled water until the neutralization of the filtrate. Finally, the produced activated carbon was dried at 80 °C, crushed, and sieved to a particle size < 80 μm and kept in an airtight container for further use.

Reagents and apparatus

This study targets methylene blue molecules (C16H18ClN3S3.H2O) with a molecular weight of 319.86 g mol−1. Phosphoric acid H3PO4, sodium hydroxide NaOH, and hydrochloric acid HCl were acquired from Sigma Aldrich company. The residual concentration of methylene blue was determined using a UV–Visible spectrophotometer type (GENESYS 10SUV-VIS). pH measurements were conducted using pH meter type (OHAUS, STARTER 3100). Design Expert software 13 was used as an analytical tool in the response surface methodology study.

Characterization of the adsorbent

Carbon porosity and surface area were determined using adsorption–desorption isotherms of N2 at 77 K with relative pressure range 0 < P/P° < 1 using outgases of 8 h, using Autosorb 1C (Quantachrome) machine. The BET (Brunauer–Emmett–Teller) method was employed to estimate the surface area (SBET) of the prepared activated carbon. Surface functional groups were qualitatively determined using Fourier transform infrared spectroscopy (FTIR) at wave light ranging from 400 to 4000 cm−1, using (Nicolet IS5) instrument. The hydraulic pump was used to produce pellets after mixing 2 mg of the sample with 80 mg of KBr. The surface morphology of the raw LP and LP-AC materials was identified through SEM analysis, applying magnification of ×2500 with a Quanta FEI 250 apparatus. Elemental composition analysis of both raw and activated carbon was determined using EDS analysis. Thermal behavior of LP material was characterized using (TGA/DSC) (thermal gravimetric analysis/differential scanning calorimeter) from room temperature 20 °C up to 600 °C using sta 449F3 jupiter (Netzsch) apparatus.

Adsorption experiment using Box Benken design

Box Benken design was used to determine the optimal conditions for maximizing MB removal using activated carbon within three independent variables and three levels. To create a Box Benken matrix, a series of primary tests is essential to determine the parameters that strongly affect the MB adsorption on the LP-AC material. The independent variables are codded as A: initial concentration, B: initial pH, and C: adsorbent mass. Variables range limits are coded as − 1 for low level and + 1 for high level, while 0 for the central points as summarized in the Table 1. During the adsorption experiment, a mass of adsorbent was added to 50 mL of MB solution and then mixed for 2 h at a shaking speed of 300 rpm. Subsequently, the solid separation was performed using a 0.4 μm filter, and the residual concentration of MB dye was measured at (λmax = 664 nm). pH solution was adjusted using 0.01 M of HCl and NaOH solutions. Removal efficiency (R %) of dye and the adsorbed amount at the equilibrium qe (mg g−1) was determined using Eqs. 1 and 2:

$$R\% = \frac{{\left( {C_{0} - C_{e} } \right)}}{{C_{0} }} \times 100$$
(1)
$$q_{e} = \frac{{\left( {C_{0} - C_{e} } \right) \times V}}{W}$$
(2)
Table 1 Codded levels of the input variables

Here Co and Ce (mg L−1) are starting and equilibrium concentrations of MB, V, and W are the solution volume (L) and the adsorbent mass (g). The statistical study of the model was performed using Design Expert (13.0, Stat-Ease, USA).

The mathematical model at the end of the design, which predicts the removal efficiency of MB dye, can be constructed using the following equation:

$$R = \beta_{0} + \mathop \sum \limits_{i = 1}^{K} \beta_{i} X_{i} + \mathop \sum \limits_{i = 1}^{K} \mathop \sum \limits_{i = 1}^{K} \beta_{ij} X_{i} X_{j} + \mathop \sum \limits_{i = 1}^{K} \beta_{ii} X_{i}^{2}$$
(3)

Here R is the output (MB removal efficiency), β0 is a constant coefficient, βi, βii, and βij are regression coefficients of linear interaction, quadratic effect, and linear interaction of variable. Xi, Xj are experimental variables [32, 33].

Isotherm study

Isotherm models mainly explain the interfacial phenomena between the adsorbent and the adsorbate molecules. Various models such as Langmuir, Freundlich and Temkin are used to describe the adsorption behavior under equilibrium conditions. The Langmuir isotherm suggests that the adsorbent sites are covered by a monolayer of the adsorbate molecules occupying uniform sites. The nonlinear form of Langmuir is expressed as [34]:

$$q_{e} = \frac{{{\text{q}}_{{\text{m}}} {\text{K}}_{{\text{L}}} {\text{C}}_{{\text{e}}} }}{{1 + {\text{K}}_{{\text{L}}} {\text{C}}_{{\text{e}}} }}$$
(4)

Here qm (mg g−1), KL (L mg−1), and Ce (mg L−1) are the dye maximum adsorption capacity, Langmuir constant, dye concentration at the equilibrium. Adsorption feasibility can be determined using Langmuir dimensionless constant as follows Eq. 5:

$${\text{R}}_{L} = \frac{1}{{1 + {\text{K}}_{{\text{L}}} {\text{C}}_{0} }}$$
(5)

Depending on the RL values, the adsorption equilibrium can be unfavorable (RL > 1), linear (RL = 1), favorable (0 < RL < 1), or irreversible (RL = 0) [35].

The Freundlich isotherm is employed to describe the adsorption phenomenon on a heterogeneous adsorbent surface, allowing for the formation of multiple layers of solute molecules on the adsorbent surface. The Freundlich non-linear equation can be illustrated as follows [36]:

$$q_{e} = K_{f} C_{e}^{\frac{1}{n}}$$
(6)

Here Kf ((mg g−1) (L mg−1)1/n), Ce (mg g−1), and n are the Freundlich equilibrium constant, equilibrium concentration, and heterogeneity constant respectively.

Temkin isotherm assumes that the heat of the adsorption changes linearly with the surface coverage of the adsorbent molecules. The nonlinear Temkin equation is expressed as:

$$q_{e} = \frac{RT}{{b_{T} }}\ln \left( {K_{T} C_{e} } \right)$$
(7)

Here bT (J mol−1) is the heat adsorption constant, KT (L mg−1) is the Temkin constant at the equilibrium, T is the temperature in kelvin, R gas constant (8.314 J mol−1 K−1) [37].

Results and discussion

Adsorbent characterization

Zero charge point

The adsorbent performance depends on the interactions formed between its surface charge and the charge of the target molecules. Notably, the adsorbent surface could be basic, acidic, or neutral which influences the adsorption efficiency. Fig. S1 (Online Resource 1) represented the zero charge point of the activated carbon determined following the salt addition method as expressed by Manna et al. [38]. It can be seen that the carbon produced has an acidic surface, as indicated by the zero charge point of 2.3. Above this point, the LP-AC surface shows a negative charge, which is favorable for creating electrostatic interactions with positive MB molecules [39].

Textural characteristics of the activated carbon

Nitrogen adsorption–desorption isotherm model was used to study the porosity and texture properties of the activated carbon. According to the IUPAC classification, the observed curve shape in Fig. 1a is of type IV, characterized by a narrow hysteresis loop of type H4 at 0.4 < P/P0 < 1, indicating the presence of both microporous and mesoporous structure, which is confirmed by the Barrett–Joyner–Halenda (BJH) pore distribution Fig. 1b, where it can be seen that the most of pores sizes are ranging between 1.55 and 9.75 nm, corresponding to micropores with diameters < 2 nm, and mesopores with diameters from 2 to 50 nm [40]. Table 2 shows that the LP-AC exhibits a high BET surface area of 1367.30 m2 g−1 with a significant mesoporous area of 803.95 m2 g−1 which enhance the MB adsorption.

Fig. 1
figure 1

N2 adsorption–desorption isotherm (a), and pore size distribution (b) of LP-AC

Table 2 Textural properties of LP-AC

FTIR analysis

FTIR analysis was applied to identify the surface functional groups on LP activated carbon as presented in Fig. 2. The broad peak at 3383 cm−1 could be attributed to the presence of hydroxyl groups OH originating from alcohol, carboxyl, and phenol, or may occur due to water adsorption. The peak at 1578 cm−1 can be associated with the presence of a C=C bond, indicating that the LP-AC may contain aromatic rings [41]. It could be noteced that the intensity of methyle C–H3 peak at 1311 cm−1 is more intense after MB adsorption, besides, the appearance of a new peak at 1319 cm−1 which could be due to the formation of electrostatic interactions with MB molecules [42]. Peak at 1211 attributed to the C–O vibration [43]. The peak at 1075 cm−1 may refer to the symitric and asymitric vibration of P–O–C and P–O respectively [44, 45]. The appearance of small peaks at around 885–800 cm−1 after MB adsorption refers to the =C–H Alkene bonds of the benzen ring [46, 47].

Fig. 2
figure 2

FTIR analysis of LP-AC before and after MB adsorption

SEM analysis

The effect of the chemical activation on the surface morphology of the activated carbon was determined using SEM analysis as presented in Fig. 3. It is observable that the LP precursor in Fig. 3a is characterized by a wavy, non-porous surface with the presence of wrinkles, which may explain their restricted surface area. while, the produced activated carbon Fig. 3b represents a rough, cracked, and extremely heterogeneous surface that includes various forms of cavities and pits that allow the adsorption of different sizes of solute molecules. Pore formation could be attributed to the reaction of the phosphoric acid with the raw LP during the activation process which leads to the emission of volatile compounds [29, 48, 49]. After MB adsorption Fig. S2 (Online Resource 1), the surface of LP-AC becomes smoother and denser confirming that the LP-AC surface is covered by MB molecules. However, there are no significant changes in the overall structure of LP-AC.

Fig. 3
figure 3

SEM image for raw LP at ×2500 (a), and activated carbon at ×2500 (b)

EDS analysis Fig. S3a and b (Online Resource 1) indicated that the carbon content increases from 52.28 to 80.70% in raw and activated carbon respectively. That could be attributed to the vaporization of volatile substances during the activation process, resulting in a material that has a higher concentration of carbon. This affirms the efficiency of the activation process in carbon production using phosphoric acid. Furthermore, the produced carbon is rich with oxygen and phosphor which is in consistent with the FTIR analysis.

Thermal gravimetric analysis of LP-AC

Thermal gravimetric analysis TGA and differential scanning calorimeter DSC of raw precursor represented in Fig. 4 indicated that LP degradation occurs in three main sections. At the first stage, a small weight loss of 7.62% was observed at temperature of (50–150 °C) because of the volatile matter and water evaporation. At the second stage, a notable mass loss of 46.11% was observed within the temperature range of (200–350 °C). This aligns with earlier studies which suggests that cellulose, hemicellulose, and lignin decompose within the temperature range of (265–310 °C) [50]. At this stage an intense pic of exothermic reaction is observed at 300 °C. The third stage of mass loss corresponds to the degradation of the rest of lignin molecules at temperature range of (350–500 °C) with a mass loss of 32.39%. At temperatures beyond 500 °C, there is no longer any loss of mass, suggesting that this temperature is the most favorable for the production of activated carbon.

Fig. 4
figure 4

TGA/DSC analysis of raw LP material

Model fitting and statistical analysis

To evaluate the influence of the experimental variables on the removal efficacy of MB using Lp-activated carbon, a Box–Benken matrix including 17 batch trials was undertaken. During these trials, three variables were manipulated, each with three different levels. The values of MB removal efficiency % are tabulated in Table 3. Notably, the experimental results indicated that the maximum removal efficiency of 99.42% is highlighted in the experiment run 17, under the following conditions: dye concentration of 300 mg L−1, pH solution of 7, and an adsorbent dose of 0.05 g.

Table 3 Box Benken matrix of the tree variables

The Analysis of variance (ANOVA) was carried out to assess the significance of variables variation on the response at a confidence level of 95%. The validation of model adequacy relies heavily on the model's P and F values, where a small p value (< 0.05) and large F value (> 0.05) are required for the model significance [51]. The ANOVA results summarized in Table 4 indicated that with p-value < 0.0001 and F value of 71.15, the quadratic model chosen is significant for the results fitting. Moreover, the model exhibited a non-significant lack of fit as indicated by a p-value of 0.5948 confirming the suitability and the adequacy of the model.

Table 4 ANOVA test

In addition, an essential set of parameters is required to assess the significance of the model, including the correlation coefficient R2 = 0.9892, which presents a high value close to 1, suggesting that only 1.08% of the variation remains unexplained by the model [33]. High values were also observed for the adjusted R2 = 0.9753 and the predicted R2 = 0.9289, the difference between these two parameters should be less than 0.2 to revealed a good model fit.

The prediction of the removal efficiency of MB dye using LP-AC is represented by a second-degree polynomial Eq. 8. According to the statistical study of the variables, terms with p-values less than 0.05 are important and play an essential role in the model. In this context, A, B, C, AB, AC, BC, B2, and C2 are found to be significant contributors. However, A2 is not significant in this model.

$${{R\% }} = + 64.16 - 10.45{\text{A}} + 18.53{\text{B}} + 20.22{\text{C}} + 9.51{\text{AB}} - 7.32{\text{AC}} - 12.94{\text{BC}} + 0.323{\text{A}}^{2} + 16.06{\text{B}}^{2} - 5.82{\text{C}}^{2}$$
(8)

To assess the model applicability, the distribution of the model predicted data vs actual data points is illustrated in Fig. S4 (Online Resource 1). It is evident that both results are close, with a uniform distribution that forms a straight line. This could be an emphasis on the accuracy of the model in predicting results [52].

Surface response analysis

Adsorption of MB dyes on LP-AC is influenced by various experimental parameters, including initial dye concentration, solution pH, and Adsorbent dose. These parameters can enhance or impede the removal efficiency of dye. To better understand the interaction effect of parameters on the response, 3D surface response plots were investigated. Fig. 5a shows the interaction effect of the adsorbent dose and pH while holding dye concentration constante at the central point of 500 mg L−1. It could be seen that pH variation has a positive effect on the response where increasing the pH values from 2 to 12 increases removal efficiency from 24 to 86%. That could be a result of the negative charge exhibited by the adsorbent at pH values higher than the (pHzpc = 2.3) which is favorite for dropping positive MB molecules [53].

Fig. 5
figure 5

3D plot of factors interactions, adsorbent dose and pH (a), adsorbent dose and initial concentration (b) (at V = 50 mL, stirring = 300 rpm, T = 28 °C)

Fig. 5b suggests that increasing the adsorbent dose from 0.01 to 0.05 g, improves the MB uptake, which could be a result of the availability of a large number of vacant sites offered by the adsorbent addition [55].

However, the initial dye concentration has a negative effect on the adsorption performance Fig. S5 (Online Resource 1). As it increases from 300 to 700 mg L−1, the removal efficiency decreases from 81 to 43%, which could be explained by the large number of MB molecules at high concentration against the limited active sites of the adsorbent [54].

Optimization of experimental parameters using the desirability function

The desirability function (DF) plays an essential role in optimizing the experimental parameters for maximizing the removal efficiency of MB dye. The scenario chosen for this optimization was based on keeping all variable values within range while maximizing the response. According to the ramp function graph Fig. S6 (Online Resource 1), achieving a removal efficiency of 100.18% with a desirability of 1% corresponds to setting the value of the parameters at an initial dose of 0.049 g, dye concentration of 300.87 mg L−1, pH of 10.07. For the validation of the scenario Table 5 represents the predicted and the experimental values of the responses. It could be noticed that the experimental validation of these conditions shows a removal efficiency of 99.99%, this value is so close to the value predicted by the model. The error calculated using Eq. 9 is estimated as 0.19% this small value is acceptable for the validation of the model prediction. The experiments were repeated at least two times.

$$Error \% = \left| {\frac{Experimentale\,value - Predicted\,value}{{Exprimentale\,value}}} \right|*100$$
(9)
Table 5 Relative error for the model validation

Isotherm study

The isotherm study was conducted using the nonlinear forms of the most commonly employed Langmuir, Freundlich, and Temkin isotherms [56]. Fig. 6 shows the variation of the adsorbed amount as a function of the equilibrium dye concentration varied in the range (100 to 1000 mg L−1), the rest of the experimental conditions were fixed at the optimal values previously determined in the RSM study. The equilibrium parameters of the model fitting are calculated in Table 6.

Fig. 6
figure 6

Isotherm models of Langmuir, Frendlich, and Temkin (at adsorbent mass = 0.049 g, V = 50 mL, t = 2 h, stirring = 300 rpm, T = 28 °C, pH 10.07)

Table 6 Isotherm parameters of Langmuir, Freundlich, and Temkin

To evaluate the best fitted model, the isotherms were compared using R2 values. Both Temkin and Freundlich have higher coefficients than the Langmuir isotherm. Temkin isotherm shows the best agreement with the experimental data with R2 = 0.980 indicating the heterogeneity in the adsorbent site energy. The positive value obtained for the adsorption heat calculated from the Temkin isotherm (bT > 1) revealed that the adsorption process is exothermic [57, 58]. Langmuir isotherm represents a maximum adsorption capacity of qm = 584.32 mg g−1. The obtained adsorption capacity indicated that the produced activated carbon shows a high performance compared to those obtained from different activated carbons for MB removal derived from Garcinia mangostana qm = 163.6 mg g−1 [27], pistachio shells qm = 129 mg g−1 [59], corn cob residue qm = 183.3 mg g−1 [60], Calicotome villosa qm = 169.78 mg g−1 [61]. Furthermore, the RL value less than the unit indicates a favorable adsorption process. Additionally, Freundlich constant 1/n < 1 indicated that MB adsorption on LP activated carbon is a favorable process.

Kinetic study

The kinetic mechanism of the adsorption of MB dye on activated carbon was investigated using the two basic models of Pseudo first order and Pseudo second order using the following equations:

Pseudo first order

$$q_{t} = q_{e} \left( {1 - e^{{ - K_{1} \cdot t}} } \right)$$
(10)

Pseudo second order

$$q_{t} = {{\left( {K_{2} q_{e }^{2} \cdot t} \right)} \mathord{\left/ {\vphantom {{\left( {K_{2} q_{e }^{2} \cdot t} \right)} {\left( {1 + K_{2} q_{e} \cdot t} \right)}}} \right. \kern-0pt} {\left( {1 + K_{2} q_{e} \cdot t} \right)}}$$
(11)

Here qe and qt are the dye amount at equilibrium and instant t, K1 (L min−1) is the pseudo first order constant, K2 (g mg−1 min−1) is the pseudo-second order constant respectively.

Non-linear fitting of the adsorbed amount in function of initial dye concentration is illustrated in Fig. 7. It appears that the equilibrium is achieved in the first 5 min for low concentrations, whereas it necessitates a longer time for high concentrations, typically around 20 min. kinetic parameters derived from the non-linear fitting are illustrated in Table 7. Upon comparing the correlation coefficients, it is evident that the PSO model shows significantly higher values with R2 > 0.997, in contrast to the PFO model with R2 > 0.990.

Fig. 7
figure 7

kinetic plots of pseudo first order (a), and pseudo second order (b) (at adsorbent mass = 0.049 g, V = 50 mL, t = 2 h, stirring = 300 rpm, T = 28 °C, pH 10.07)

Table 7 Kinetic parameters of MB adsorption on LP-AC

Furthermore, the normalized standard deviation of the adsorbed amount Δq% calculated from Eq. 12 indicated that the PSO model is in better agreement with the experimental data, as indicated by the lowest value of Δq = 0.636% compared to the high value obtained from the PFO model Δq = 1.71%, suggesting that chemisorption interactions govern the kinetic rate of the process [62]. These results are in line with those found in a previous study on the adsorption of MB dye on phosphoric-activated carbon [63,64,65].

$$\Delta {\text{q}}\% = 100 \times \frac{{\sqrt {\mathop \sum \nolimits_{i = 1}^{n} \left( {\frac{{q_{e exp} - q_{e cal} }}{{q_{e cal} }}} \right)^{2} } }}{n - 1}$$
(12)

Thermodynamic study

To investigate the effect of temperature on the adsorption of MB dye on the activated carbon, the temperature effect was carried out in a range of (303, 313, 323, and 333 K) using dye concentration of 300 mg L−1, adsorbent mass of 0.045 g, pH of 10.07. Thermodynamic parameters of Gibbs free energy ΔG, enthalpy ΔH, and entropy ΔS were calculated using the following equations:

$$K_{d} = \frac{{q_{e} }}{{c_{e} }}$$
(13)
$$\Delta {\text{G}}^{^\circ } = - {\text{RT ln }}K_{d}$$
(14)
$${\text{lnK}}_{{\text{d}}} = \frac{{\Delta {\text{S}}^{^\circ } }}{R} - \frac{{\Delta {\text{H}}^{^\circ } }}{RT}$$
(15)

Here qe is the dye adsorbed amount at the equilibrium, Ce is the equilibrium concentration, Kd (L g−1) is the equilibrium constant, R is the molar gas constant (8.314 J mol−1 K−1) and T is the temperature in kelvin.

The thermodynamic parameters summarized in Table 8 showed negative values for both enthalpy ΔH and entropy ΔS, indicating that the adsorption process is exothermic in nature and involves a degree of randomness in the arrangement of the adsorbate at the adsorbent interface. The spontaneity of MB adsorption on LP-AC was indicated by a negative value of ΔG Trapped between 0 and − 20 kJ mol−1, indicating that MB adsorption is a physical process. The decreases in ΔG as temperature increases indicated that temperature inhibits the adsorption of MB molecules on LP-AC [66].

Table 8 Thermodynamic parameters of MB adsorption

Regeneration study

The regeneration of spend activated carbon is an important feature for the economical scale application, that the reuse ability for many cycles enhances its cost effectiveness making it an attractive option for the industrial application. The durability of the produced activated carbon was investigated through the treatment of the spend carbon with 1 M HCl solution followed by subsequent washings with hot distilled water. Adsorption tests were carried using adsorbent mass of 0.045 g in 50 ml of MB solution, then the solution was stirred for 2 h. Fig. S7 (Online Resource 1) demonstrates that LP-AC maintains its performance for four cycles where removal efficiency decreased from 99 to 93%. However, in the fifth cycle removal efficiency decreased to 90%, that could be attributed to the incomplete desorption of dye molecules from the surface which saturate the adsorbent active sites [56]. The applied treatment effectively restores the active sites of the carbon, thereby rendering it reusable multiple times.

Conclusion

Activated carbon derived from low-cost precursor of L. leucocephala pods demonstrates high performance in the removal of methylene blue textile dye, achieving a remarkable removal rate of 99.99%. RSM optimization using the Box–Benken design revealed that an initial dye concentration of 300.87 mg L−1, adsorbent dose of 0.049 g, and solution pH of 10.07 are the optimal values that maximize dye removal efficiency. The thermodynamic study showed that the adsorption of MB dye on LP-AC has an exothermic nature with a negative enthalpy. FTIR analysis showed that LP-AC exhibits various surface functional groups such as hydroxyl groups, which enhance the adsorption efficiency of MB. Regeneration study revealed that the prepared carbon exhibits an economic aspect that it could be used for multiple cycles rendering a good performance.