1 Introduction

In recent decades, several researchers have reported that the textile industry uses very large quantities of dyes and subsequently produces discharges that are too loaded with colored pollutants [1,2,3]. Pollution of water by textile effluents laden with contaminants is a serious problem facing not only the environment but also human health. From a human health perspective, external exposure to methylene blue (MB) can cause skin irritation and permanent eye damage, inhaling it may cause rapid or difficult breathing and increased heart rate and its ingestion can irritate the gastrointestinal tract, nausea, loss of sweat, mental confusion, cyanosis and necrosis of human tissue [4, 5]. From an environmental standpoint, the discharge of these toxic pollutants into the water reduces the diffusion of light necessary to maintain the stability of aquatic life [6]. For this reason, several physicochemical processes have been used to treat colored effluents, such as coagulation-flocculation, oxidation, filtration, and adsorption [7,8,9,10,11]. Although these processes reduce wastewater pollution factors, they remain limited by their exorbitant costs and incomplete contaminants removal [12]. Adsorption is one of the most effective methods due to its high performance, flexibility, its simplicity of design, low energy demand, selectivity, and its important use for the treatment of water contaminated by textile dyes because this method is considered environmentally friendly and does not leave any pollutant molecular fragment [13,14,15,16,17]. The latter has been the subject of several studies: Koyuncu and Kul asserts that the active charcoal of non-living lichen Pseudevernia furfuracea was efficient to adsorb the methylene blue [18], Öztürk et al. found that the bacteria Rhodopseudomonas palustris 51ATA was a promising adsorbent for Fast Black K azo dye [19], Tukaram bai et al. reported that the cane bagasse was performent to adsorb eosin yellow [20]. In addition to these studies, other scientific works could be mentioned as Arab et al. who observed the effective behavior of zinc oxide and curcumin nanoparticles were to adsorb Congo red [21], Siraorarnroj et al. who noticed that mulberry (Morus alba L.) leaf residue was a promising adsorbent for methyl orange [22], and Karaman et al. who found that orange peel waste was effective to adsorb Congo red [23]. Many researchers have studied the methylene blue adsorption on different materials such as Phosphoric Acid-Treated Balanites Aegyptiaca Seed Husks Powder [24], mango leaf powders [25], and Caesalpinia ferrea [26]. Biological treatment corresponds to a transfer of organic matter with the production of mud explains the performance of biomass for the degradation of textile effluents having a very high concentration of organic matter [27]. Besides, some scientific researchers have demonstrated the magnificence of the adsorbent properties of peanut and walnut shells on various synthetic dyes: For peanut shells, Garg et al.  studied the adsorption property of activated carbon in peanut shells to remove acid yellow 36 [28]. Garg et al. studied the adsorption property of activated carbon in encapsulated alginate peanut shells to remove the Direct Blue-86 dye [29]. Liu et al. investigated the biosorption of crystal violet on ​​the residue of fermented peanut shells [30]. For the walnut shells, Hajialigol and Masoum studied the performance of the nano-biomass based on the chemical activation of nutshells in the elimination of malachite green [31], as for Pang et al. have shown that pecan-based biomass could be a competitive adsorbent in terms of a possible real application to remove the crystal violet dye [32]. The novelty and originality of our scientific work are integrated into a process of valorization of walnut shells and peanut shells as food wastes abundantly available in municipal landfills by exploiting them in an innovative experimental project based on the preparation of effective adsorbents to be used for the removal of the methylene blue dye (MB) present in textile waters with consideration of the profitability and cost-effectiveness ratio. Various parameters were studied, such as the contact time, the initial concentration of dye, the adsorbents dose, the pH, the temperature of the solution, the adsorbents particle size, and the ionic strength. The kinetic adsorption data were tested by pseudo-first-order, pseudo-second-order kinetic models, and intra-particle diffusion. The equilibrium data were analyzed using the isotherms of Langmuir, Freundlich, and Dubinin Radushkevich. The effect of temperature on the adsorption of the dye was also studied and the thermodynamic parameters were determined. Then, aiming at an eco-environmental approach, several regeneration cycles were performed to avoid the transfer of pollution from liquid to solid. Finally, to evaluate the economic performance of the two adsorbents TWS and TPS, and their applicability on an industrial scale, the cost estimation of the methylene blue adsorption process was based on the analytical accounting of the prices of all the raw materials and chemicals used.

2 Materials and Methods

2.1 Adsorbate Preparation

The adsorbate used in the present study is methylene blue (MB) of purity 99% with formula C16H18ClN3S and molecular weight 319.852 g mol−1. Several solutions of the MB dye were prepared by dilution with ultrapure water from a stock solution of concentration 1 g L−1. Then, absorbances were obtained using UV–visible spectroscopy which gives us a maximum wavelength λmax = 664 nm.

2.2 Adsorbents Preparation

Walnut shells and peanut shells are two natural bio-adsorbents from a local market in the city of Fez, Morocco. These biomaterials were washed with ultrapure water to remove adhering impurities, dried, then ground, and sieved to obtain different fractions. Then, 200 ml of ethanol (95%) was added to each fraction of our bio-adsorbents to solvate the different organic molecules present in the samples. After that, H2O2 (30%) was added as a bleaching agent to oxidize any non-solvated organic matter. Finally, the two treated bio-adsorbents were oven-dried for 24 h at 100 °C and sieved to obtain the treated walnut shells (TWS) and treated peanut shells (TPS).

2.3 Biosorption Process

Different characterization techniques were used to identify the composition of the main constituents of the treated walnut shell (TWS) and treated peanut shell (TPS) powders. Fourier transform infrared spectroscopy is an important tool to identify functional groups capable of adsorbing pollutant molecules onto TWS and TPS adsorbents. Scanning electron microscopy analyses require that the powders of treated peanut shells and treated walnut shells are granulated by a granulating machine that applies pressure to the powder. The isoelectric pH (zero charge point pHpzc) of the two bio-adsorbents was determined using the method applied by several researchers [33,34,35,36]. It consists of adding 20 ml of sodium chloride (0.05 M) to several 50 ml polystyrene beakers and adjusting the pH (2–12) by adding drops of hydrochloric acid and sodium hydroxide (0.1 M). After shaking the suspensions at 25 °C for 48 h, they were filtered through a membrane filter (0.45 μm pore diameter) before measuring the final pH values. The zero charge point value pHpzc was determined by the point of intersection of the ΔpH = pHfinal − pHinitial curve with the pHinitial axis. The efficiency of the TWS and TPS biosorbents was tested for the removal of methylene blue (MB) dye. Several parameters such as contact time (0–60 min), initial methylene blue concentration (30–60 mg L−1), adsorbent dose (0.5–2 g L−1), particle size (90–200 μm), pH (2–12), and temperature (20–60 °C) were studied. The dye solution was withdrawn every five minutes, centrifuged, and then filtered through syringe filters (0.45 μm) and then immediately measured the absorbance of the supernatant using a UV–visible spectrophotometer with λmax = 664 nm. The performance of the adsorbent is generally represented by the adsorption capacity at time t (Qt, mg g−1) which was calculated based on the difference between the initial concentration (Ci, mg L−1) and the concentration at time t (Ct, mg L−1) using Eq. (1) [37]:

$$Q_t=\frac{C_i-C_t}WV$$
(1)

where Ci is the initial concentration of methylene blue (mg L−1), Ct is the concentration of methylene blue in the time t (mg L−1), V is the volume of the solution (L), W is the weight of the adsorbent (g), and Qt is the amount of adsorption at time t.

3 Results and Discussion

3.1 Characterization of the Adsorbents

3.1.1 Fourier Transform Infrared Spectroscopy

The spectrum in Fig. 1 obtained by Fourier transform infrared spectroscopy (FTIR) in a vague range that varies between 400 and 4000 cm−1 confirms the presence of the absorption bands characterizing the treated walnut shells (Fig. 1a) and the treated peanut shells (Fig. 1b).

Fig. 1
figure 1

The infrared spectrum of treated walnut shells (a) and treated peanut shells (b)

For the treated walnut shell infrared spectrum shown in Fig. 1a: the band centered at 3329 cm−1 refers to the alcohol groups’ O–H stretching vibration [38, 39]. The 2926 cm−1 and 2856 cm−1 bands are due to the CH stretching vibrations in the methyl group [31, 40]. The absorption bands in 1607 cm−1 refer to stretching vibrations of groups C=O, while the skeletal vibrations C=C lead to two other bands at approximately 1512 cm−1 and 1425 cm−1 [41, 42]. The 1738 cm−1 plug is derived from the C=O group of carbonyl compounds (ketones, aldehydes, carboxylic compounds, esters) [40, 43]. The bands at 1315, 1236, and 1022 cm−1 are due to C–O stretching vibrations in alcohols, phenols, or ether groups [31, 44]. The bands between 893 and 663 cm−1 correspond to aromatic bands attributed to the bending vibrations of the CH groups [45, 46].

For the infrared spectrum of treated peanut shells represented in Fig. 1b: The band located at 3319 cm−1 corresponds to the O–H stretching vibration of hydroxyl groups which can indicate the presence of cellulosic structure in the adsorbent surface [47, 48].The bands at 2920 cm−1 and 2858 cm−1 are attributed to the stretching vibrations of C–H in the methyl groups on the surface, which can present the lignin structure [47, 49]. The absorption bands in the region of approximately 1631 cm−1 correspond to stretching vibrations of groups C=C aromatic rings [47, 50], while the O–H twisting vibrations and aliphatic CH3 and CH2 distortions in cellulose and lignin structures lead to another band to approximately 1367 cm−1 [51]. The plug which is of the order of 1730 cm−1 is derived from the group C=O extending vibrations of keto carbonyl gatherings or carboxylic groups [47]. The intense band at around 1020 cm−1 is attributed to the C–O of alcohol, carboxyl, or phenol [50]. The band in 530 cm−1 could be attributed to the in-plane ring twisting.

3.1.2 Surface morphology by SEM-EDX

Observation with a scanning electron microscope (SEM) coupled with energy-dispersive X-ray spectroscopy (EDX) shows the surface morphology of peanut shells and the walnut shells biosorbents. SEM micrographs of the TWS and TPS adsorbents are shown in Fig. 2.

Fig. 2
figure 2

SEM-EDX of TWS (a, b) and TPS (c, d)

The images presented in Fig. 2 highlight the fibrous and irregular structure of the TWS and TPS adsorbents. This fibrous structure explains the stiffness of the lignocellulosic material [52]. Chemical analysis by EDX shows that both bio-adsorbents are mainly formed of the elements Carbon and Oxygen. Similar EDX elemental distribution results were reported for mesopore silica composite from rice husk with activated carbon from coconut shell [53], tamarind fruit shell powder [54], banana peels, and eggshells [55]. In general, the morphological and elemental analysis of the surfaces, for each of the two biomaterials, confirms their ability to uptake toxic molecules present in an aqueous solution.

3.2 Effect of Contact Time and Initial Concentration

Figure 3 represents the evolution of the adsorbed quantity of methylene blue per gram of treated walnut shells and treated peanut shells as a function of the contact time at different initial dye concentrations (from 30 to 60 mg L−1) with a constant mass of adsorbent of 0.5 g L−1, at T = 20 °C and for 60 min.

Fig. 3
figure 3

Effect of methylene blue dye initial concentration on adsorption capacity onto treated walnut shells (a) and treated peanut shells (b) (T = 20 ° C, adsorbent dose = 0.5 g L−1, particle size = 90 μm)

The adsorption kinetics of methylene blue on both the treated walnut shells (Fig. 3a) and the treated peanut shells (Fig. 3b) show paces characterized by rapid adsorption from the first minutes of contact, followed by a slow increase until reaching a state of equilibrium at t = 30 min. This could be explained by the fact that the sorption sites are open at the beginning and that the molecules of methylene blue easily access these sites. Beyond t = 30 min, the adsorption capacities remain constant because of the binding site saturation and increase with the increase in the initial concentration of methylene blue. This increase can be attributed to the presence of an inordinate range of molecules that can be uptaken on the sites on the surface of the adsorbent [56, 57], and/or to the fact that the molecules of the dye can occupy more sorption sites at higher initial concentrations [16, 28], and/or to the fact that the driving force, necessary to overcome all the mass transfer resistances of the dye molecules between the solution and the surface, is provided by the high value of the concentration gradient [58, 59]. Furthermore, according to Fig. 3, the optimal initial concentration of methylene blue dye is 60 mg L−1 with 101.43 mg g−1 and 67.42 mg g−1 as adsorption capacities on treated walnut shells and treated peanut shells respectively.

3.3 Effect of the Adsorbent Amount

This study was carried out to assess the adsorption capacity of methylene blue by different doses of TWS and TPS from 0.5 to 2 g L−1 by keeping constant the initial concentration of methylene blue at 60 mg L−1 and the temperature of the solution at 20 °C (Fig. 4).

Fig. 4
figure 4

Effect of the treated walnut shells (a) and treated peanut shells (b) amounts on methylene blue adsorption capacity (T = 20 °C, [MB] = 60 mg L−1, particle size = 90 μm)

The adsorbed amounts of MB on TWS are 99.98 mg g−1, 46.66 mg g−1, 26.03 mg g−1, and 12.44 mg g−1 and on TPS are 60.47 mg g−1, 28.58 mg g−1, 16.47 mg g−1 and 10.09 mg g−1 for adsorbent doses 0.5 g L−1, 1 g L−1, 1.5 g L−1, and 2 g L−1, respectively. These results show that the adsorption capacity of methylene blue decreases by increasing the adsorbent’s dose. This can be explained by the saturation of most adsorption sites with high doses of adsorbent [60, 61].

3.4 Effect of Particle Size

Particle size is a key parameter for the study of MB dye adsorption on the surface of TWS and TPS. To this end, the study of adsorbent particle size allows the determination of the optimal particle size through a series of experiments conducted with different particle sizes from 90 to 200 μm using 60 mg L−1 of methylene blue, 0.5 g L−1 of adsorbent, pH 6, at room temperature and under stirring at 250 rpm (Fig. 5).

Fig. 5
figure 5

Effect of treated walnut shell and treated peanut shell particles size on methylene blue dye adsorption (T = 20 °C, [MB] = 60 mg L−1, adsorbent amount = 0.5 g L−1)

According to Fig. 5, the adsorption capacity of the methylene blue dye decreases by increasing the particle size of each of the two bio-adsorbents. The adsorption equilibrium capacity for walnut shells goes from 101.43 mg g−1 at 90 μm to 83.2 mg g−1 at 200 μm. The same thing is observed in the case of peanut shells when the adsorption equilibrium capacity decreases from 67.42 mg g−1 at 90 μm to 49.2 mg g−1 at 200 μm. This could be due to the availability of more active sites and larger specific surface area for the bio-adsorption process in fine particle sizes more than in bigger ones [62, 63]. In all the batch adsorption experiments, a particle size of 90 μm was picked to be the best size.

3.5 Effect of the Initial pH Solution

The study of the acid–base behavior of the treated walnut shells and treated peanut shells surfaces’ in the presence of the methylene blue dye makes it possible to predict a probable selectivity and mechanism of the liquid phase adsorption on the surface of the solid phase [64]. So it is wise to know the adsorption efficiency at different pH. In this case, 0.5 g L−1 of the adsorbent is introduced into a solution of the dye having an initial concentration of 60 mg L−1 at T = 20 °C. The solutions of sodium hydroxide and hydrochloric acid (0.1 N) were used to adjust the pH of the test solutions which were made with a pH range of 2–12 (Fig. 6).

Fig. 6
figure 6

pH solution effect on methylene blue adsorption capacity onto TWS and TPS (T = 20 °C, [MB] = 60 mg L−1) (a), Amount of adsorbent = 0.5 g L−1, particle size = 90 μm), pHpzc of TWS and TPS (b)

Figure 6a shows that the adsorption capacity increases by increasing the pH. Indeed, the weak elimination of the cationic dye, methylene blue, in an acid medium can be explained by the competition between protons and cations formed by methylene blue [65]. According to Fig. 6b, the two pHpzc values of treated walnut shells and treated peanut shells obtained are equal to 7.2 and 6.3, respectively. As the pH is increased, there is a decrease in the hydrogen cations, so the adsorbents’ charge becomes negative, which promotes the adsorption of the methylene blue cations by the electrostatic attraction phenomenon [66, 67].

3.6 Effect of the Temperature

The temperature of the solution is another characteristic of great interest in kinetic adsorption processes since its influence on the diffusion process is very important, especially for textile effluents which are released with considerable heat due to dyeing, bleaching, and washing procedures [30]. For this reason, we have introduced the adsorbent (0.5 g L−1) into methylene blue solutions at an initial concentration (60 mg L−1) with a temperature range (20–60 °C), and the results were obtained are shown in Fig. 7.

Fig. 7
figure 7

Effect the solution temperature on methylene blue adsorption capacity onto TWS (a) and TPS (b) ([MB] = 60 mg L−1, Amount of adsorbent = 0.5 g L−1, particle size = 90 μm)

From Fig. 7, it can be noted that when the temperature increases, the adsorption rate also increases. The increase of the adsorption capacity as a function of time could be probably explained by the increase in the active sites on the adsorbent surface [68] and/or the decrease in the mass transfer resistance of adsorbate in the boundary layer [69], and/or the endothermicity of the reaction [16, 59, 70], and/or the increase of chemical adsorbate–adsorbent interaction [16], and/or intraparticle diffusion in the pores of the adsorbent with the increased speed at a higher temperature [68], and/or modification of the internal structure of the adsorbent [29]. In the present study, the system shows that the adsorption capacities of methylene blue on treated walnut shells (Fig. 7a) and treated peanut shells (Fig. 7b) increase with temperature. It can be observed that when the temperature increases from 20 to 60 °C, the adsorption capacity on treated walnut shells increases from 86.51 to 93.55 mg g−1 and from 60.47 to 103.15 mg g−1 for treated peanut shells. Consequently, the adsorption process is endothermic and requires less energy because, when the system is exothermic, it favors low temperatures for improved adsorption [71].

3.7 Effect of Ionic Strength

The presence of alkali metals (such as sodium and potassium), alkaline-earth metals (such as barium, calcium, and magnesium), and transition metals (such as cuprous ions, chromium (III)) in textile wastewater causes interionic interactions of all ions, such as molecular attractions or repulsions that could influence the adsorption phenomenon. To research the effect of ionic strength on the adsorption phenomenon of methylene blue on treated walnut shells and treated peanut shell powders, various concentrations of barium chloride, calcium chloride, and sodium chloride (0.1–0.5 M) was added at the initial concentration of 60 mg L−1 of methylene blue and adsorbent mass (0.5 g L−1).

The effect of sodium chloride, barium chloride, and calcium chloride salts on the adsorption quantity of Methylene Blue dye on treated walnut shells and treated peanut shells is seen in Fig. 8. The results show that there is a decrease in equilibrium adsorption capacity for the two bio-adsorbents when there is a growth of each salt concentration, especially for divalent metallic ions (Ba2+ and Ca2+) because they are more competitive than Na+ (monovalent) against the methylene blue cationic dye: For the treated walnut shells, increasing the concentrations of salts from 0 to 0.5 M decreases the adsorption capacity from 101.43  to 94.1 mg g−1 in sodium chloride, to 81.2 mg g−1 in barium chloride and 80.1 mg g−1 in calcium chloride. In the case of the treated peanut shells, increasing the salt concentrations from 0 to 0.5 M decreases the adsorption capacity from 67.42 to 60.1 mg g−1 in sodium chloride, to 52.3 mg g−1 in barium chloride, and 50.1 mg g−1 in calcium chloride. The explanation for these results could be the fact that the salt ions interfere with the molecules of the cationic dye on the surface of each of the two bio-adsorbents thus leading to the breakdown of the electrostatic interaction between the dye molecules and the adsorbent surface [10, 72,73,74,75].

Fig. 8
figure 8

Effect of ionic strength on Methylene blue adsorption on treated walnut shells (a) and treated peanut shells (b) ([MB] = 60 mg L−1, Amount of adsorbent = 0.5 g L−1, particle size = 90 μm)

3.8 Thermodynamic Studies

Thermodynamic studies are very important because they allow us to predict the behavior of the adsorbent, the appropriate temperature range for adsorption, and the nature of the sorbent and the adsorbate at equilibrium [76]. For the phenomenological description of the adsorption, and more specifically the thermodynamic behavior of the system, adsorption tests have been carried out in temperatures (293–333 K) and allow to measure the parameters which must be taken into account: ∆H° (standard enthalpy), ∆S° (standard entropy) and ∆G° (standard Free energy).

The values ​​of ∆H° and ∆S° were obtained using the Vant-Hoff Eq. (2) [20, 77] :

$$\text{L}\text{n} \left({\text{K}}_{e}\right)=\frac{\varDelta S^\circ }{R}-\frac{\varDelta H^\circ }{RT}$$
(2)

where ∆H° is standard enthalpy, ∆S° is standard entropy, ∆G° is standard Free energy, R is the perfect gas constant (R = 8.314 J mol−1 K−1), T is the absolute temperature of the solution, and Ke is the partition coefficient at equilibrium calculated by using Eq. (3):

$${K}_{e}=\frac{{Q}_{e}}{{C}_{e}}$$
(3)

where Qe is Adsorption capacity at equilibrium, and Ce is Concentration of adsorbate at equilibrium.

The values ​​of ∆H° and ∆S° were calculated respectively from the slope and the ordinate at the origin of Ln (Ke) as a function of 1/T as represented in Fig. 9.

Fig. 9
figure 9

Graphical representation of Ln (Ke) as a function of the inverse of the temperature (1/T)

Values ​​of ∆G° can be obtained from the values of ∆H° and ∆S° and the Gibbs–Helmholtz Eq. (4).

$$\varDelta G^\circ =\varDelta H^\circ -T\varDelta S^\circ$$
(4)

where ∆H° is standard enthalpy, ∆S° is standard entropy, ∆G° is standard free energy, and T is the absolute temperature of the solution. Table 1 represents the values ​​of ∆H°, ∆S°, and ∆G°.

Table 1 Thermodynamic parameters for the adsorption of methylene blue onto treated walnut shells and treated peanut shells

Positive values ​​of ∆H° show that the adsorption process is endothermic. Besides, |∆H°| <60 kJ mol−1 shows that the adsorption process is based on physical interactions (physisorption) [70]. The positive values ​​of ∆S° for the adsorption of methylene blue on walnut shells and peanut shells indicate that the randomness of the polluting molecules increases at the interface of the adsorbent-adsorbate solution [78, 79]. ∆G° < 0 kJ mol−1 indicates that the adsorption of methylene blue on both walnut shells and peanut shells is feasible and spontaneous [80, 81].

3.9 Adsorption Isotherms

In the analysis of adsorption processes, the equilibrium data are normally expressed in adsorption isotherms: isotherms are an essential part of the modeling of adsorption and therefore of the design, calculation of yields, and costs of adsorption. The adsorption isotherms allow us to estimate the degree of purification that can be achieved, the quantity of adsorbent required, and the sensitivity of the process to the concentration of the product [82].

3.9.1 Langmuir’s Isotherm

Langmuir’s (1918) model, based on thermodynamic and kinetic considerations, is based on the existence of free sites on the surface of the adsorbent material where the adsorption of the solute takes place. The use of this model implies reversible adsorption supposedly monolayer. This theory also admits that the adsorption energy is uniform on the surface of the adsorbent [83]. The mathematical expression of the Langmuir isotherm is given by Eq. (5) [84] :

$${\text{Q}}_{\text{e}}=\frac{{{\text{Q}}_{\text{L}}{{\text{k}}_{\text{L}}}{\text{C}}_{\text{e}}}}{{1+{{\text{k}}_{\text{L}}}{\text{C}}_{\text{e}}}}$$
(5)

The linear representation of the Langmuir model can be represented by Eq. (6) [70] :

$$\frac{{C}_{e}}{{Q}_{e}}=\frac{1}{{k}_{L}{Q}_{L}}+\frac{{C}_{e}}{{Q}_{L}}$$
(6)

where Ce is Concentration at equilibrium (mg L−1) of methylene blue; Qe is Adsorption capacity of methylene blue at equilibrium (mg g−1); QL (mg g−1) and kL (L mg−1) are Langmuir constants relating to the adsorption capacity and the adsorption energy that are obtained by determining the slope and the ordinate at the origin of the Ce/Qe versus Ce. The results are listed in Table 2.

Table 2 Isotherm constants for methylene blue adsorption onto walnut shells and peanut shells

The dimensionless constant separation factor RL is used to express the essential characteristics of the Langmuir isotherm, which is given by Eq. (7) [70]:

$${R}_{L}=\frac{1}{1+{k}_{L}{C}_{i}}$$
(7)

where KL (L mg−1) is Langmuir constant, Ci (mg L−1) is the initial concentration in the liquid phase, and RL is the dimensionless parameter of equilibrium intensity or adsorption intensity. Its value indicates the model of isothermal adsorption characteristics as follows [85]: If RL = 0, the adsorption is invertible. If 0 < RL < 1, the adsorption is favorable. If RL = 1, the adsorption is linear. If RL> 1, adsorption is unfavorable.

For the adsorption of methylene blue on walnut shells and peanut shells, the RL values ​​listed in Table 2 are 0.067 and 0.037 respectively, which indicates that adsorption on both the two adsorbents is a favorable process.

The specific surface of an adsorbent could be estimated by the Langmuir isotherm through the following Eq. (8) [86, 87] :

$${S}_{a }=\frac{{Q}_{L}{N}_{A}{S}_{MB}}{{M}_{MB}} \left(8\right)$$
(8)

where MMB is the molecular mass of methylene blue dye (mg mol−1) and it is equal to 319,850 mg mol−1, NA is Avogadro’s number (6.02 × 1023 mol−1), Sa is the adsorbent surface (m²g−1); SMB is the contact area for each molecule of methylene blue dye (m2) and is equivalent to 1.972 × 10−18 m².

The values of the specific surface of each of the two adsorbents are also noted in Table 2.

3.9.2 Freundlich’s Isotherm

Freundlich considers that there are different types of adsorption sites for a different energy, but with the same entropy, distributed according to an exponential law as a function of the heat of adsorption. The site density decreases exponentially and the quantity adsorbed at equilibrium is written as the following Eq. (9) [65, 88] :

$${Q}_{e}={k}_{F}{\left({C}_{e}\right)}^{\frac{1}{n}}$$
(9)

The linear representation of the Freundlich model can be written as the following Eq. (10) [89] :

$$Ln\left({Q}_{e}\right)=Ln\left({k}_{F}\right)+\frac{1}{n}Ln\left({C}_{e}\right)$$
(10)

where kF is Freundlich’s adsorption capacity and n is adsorption intensity.

For the calculation of the equilibrium constants of the Freundlich adsorption, the linear curve Ln (Qe) versus Ln (Ce) is used. The slope (1/n) with 0 < 1/n < 1: is a measure of the adsorption intensity or the heterogeneity of the surface and as its value approaches 0, the surface becomes more heterogeneous. kF is obtained by the exponential of the intercept.

3.9.3 Dubinin Radushkevich Isotherm

Dubinin Radushkevich’s isothermal model was developed to describe the effect of the porous structure of adsorbents [90,91,92,93]. It was based on the theory of adsorption potential and assumed that the adsorption process was related to the filling of the micropore volume as opposed to the layer-by-layer adsorption on the walls of the pores [94]. The mathematical expression of Dubinin Radushkevich isotherm is given by Eq. (11) [95] :

$${Q}_{e}={Q}_{DR}{e}^{-\beta \epsilon^2}$$
(11)

The linear representation of the Dubinin Radushkevich model can be written as the following Eq. (12) [96] :

$$Ln\left({Q}_{e}\right)=Ln \left({Q}_{DR}\right)-{k}_{DR}{\epsilon }^{2}$$
(12)

where kDR (mol² kJ²): Isothermal constant of Dubinin Radushkevich, QDR is Dubinin Radushkevich theoretical maximum adsorption capacity and ε is Polanyi’s potential represented in the Eq. (13):

$$\epsilon =RT \,Ln\left(1+\frac{1}{{C}_{e}}\right)$$
(13)

where R is the perfect gas constant (8.314 J mol−1 K−1), T (K): absolute temperature, QDR (mg g−1): maximum adsorption capacity in micropores, and Qe (mg g−1): adsorption capacity at equilibrium.

The average free energy of adsorption (kJ mol−1) can be calculated as the following Eq. (14) [96] :

$$E=\sqrt{\frac{1}{2 {k}_{DR}}} \left(14\right)$$
(14)

Plotting Ln (Qe) as a function of ε² provides QDR and kDR. Langmuir’s isotherm constants do not explain the properties of the physical or chemical process. However, the average energy of adsorption (E) calculated from the Dubinin Radushkevich isotherm provides important information about these properties [97]: If E < 8 kJ mol−1, physisorption dominates the sorption mechanism, and if 8 < E < 16 kJ mol−1, ion exchange is the dominant factor (chemisorption). In this study, the adsorption energies are 0.5 and 0.2357 kJ mol−1 respectively for the peanut shells and walnut shells, which suggests that the adsorption process is dominated by physical forces at all temperatures.

3.9.4 Comparison Between the Isotherms: Langmuir, Freundlich, and Dubinin Radushkevich

Based on the coefficient of determination R2: R2L (0.9999) > R2DR (0.9922) > R2F (0.9583) for walnut shells and R2L (0.9979) > R2F (0.9583) > R2DR (0.8428) for peanut shells. Therefore, the adsorption of methylene blue onto walnut shells and peanut shells is better represented by the Langmuir model with a maximum monolayer capacity equal to 19.01 mg g−1 for walnut shells and 72.99 mg g−1 for peanut shells, which indicate that the adsorption surface is homogeneous [98,99,100].

3.10  Theoretical Models of Adsorption Kinetics

To model the kinetics of adsorption, three empirical models are often used: Pseudo-first-order, Pseudo-second order, and the model of intraparticle diffusion.

3.10.1 Model of the Kinetics of the Pseudo-first-order

The pseudo-first-order model, established by Lagergren, is the first speed equation describing the adsorption kinetics of an adsorbate-adsorbent couple. It is based on the quantity adsorbed. The speed of adsorption at a time t is proportional to the difference between the quantity adsorbed at equilibrium Qe and that adsorbed at time t (Fig. 10). The equation of the pseudo-first-order is described according to the following Eq. (15) [101] :

$$\frac{dQ}{dt}={k}_{1}\left({Q}_{e}-{Q}_{t}\right)$$
(15)

where Qe is the quantity of solute adsorbed at equilibrium (mg g−1), Qt is the quantity of solute adsorbed at time t (mg g−1), and k1 is the velocity ​​constant of the pseudo-first-order (min−1).

Fig. 10
figure 10

Pseudo-first-order kinetic model of adsorption of methylene blue on treated walnut shells (a) and treated peanut shells (b)

The integration of the Eq. 15 for the initial conditions at Qt=0 to t=0 gives the Eq. (16) [102]:

$$Ln\left({Q}_{e}-{Q}_{t}\right)=Ln\left({Q}_{e}\right)-{k}_{1}t$$
(16)

The quantity of solute adsorbed at equilibrium Qe and the speed constant of the pseudo-first-order k1 is determined from the graphic representation of Ln(Qe − Qt) as a function of time t (Fig. 10) [103].

3.10.2 Model of the Kinetics of the Pseudo-second-order

The velocity of adsorption of the pseudo-second-order, established by Blanchard [104] also depends on the amount adsorbed at equilibrium. The kinetic equation of the pseudo-second-order is given by the following Eq. (17) [105]:

$$\frac{dQ}{dt}={k}_{2}{\left({Q}_{e}-{Q}_{t}\right)}^{2}$$
(17)

where Qe is the amount of solute adsorbed at equilibrium (mg g−1), Qt is The quantity of solute adsorbed at time t (mg g−1), and k2 is the velocity ​​constant of pseudo-second-order (g mg−1 min−1).

The integration of the last equation with the boundary conditions Qt=0 to t = 0 takes the linear form as described by the following Eq. (18) [102] :

$$\frac{t}{{Q}_{t}}=\frac{1}{{K}_{2}{Q}_{e}^2}+\frac{1}{{Q}_{e}}t$$
(18)

Plotting 1/Qt as a function of time gives you a curve with a slope of 1/Qe and an ordinate at the origin of (1/ (k2Qe²)) (Fig. 11).

Fig. 11
figure 11

Pseudo-second-order kinetic model of adsorption of methylene blue on treated walnut shells (a) and treated peanut shells (b)

3.10.3  Model of the Kinetics of Intraparticle Diffusion

The kinetic model of intra-particle diffusion designed by Weber and Morris is, as its name suggests, a kinetic model based on the diffusion of the adsorbate until it enters the adsorbent [106]. The empirical equation of the model in Eq. (19) [70] :

$${Q}_{t}={k}_{ID}\sqrt{t}+I$$
(19)

where Qt is the adsorption capacity at time t (mg g−1), kID is the constant of the intra-particle diffusion model (mg g−1 min−1/2), t is contact time (min), and I (mg g−1) is boundary layer thickness.

According to Weber and Morris, if intra-particle diffusion is the limiting step in the adsorbate elimination process, the graph Qt vs. √t should give a straight line that passes through the origin of the contact information [70, 106,107,108].

Referring to Fig. 12, for all initial concentrations, the first step was completed within the first eight minutes and the second step of controlling intra-particulate diffusion was reached. The third step occurred for all initial concentrations of methylene blue at 30 min. The different adsorption rates observed indicate that the adsorption rate is initially faster and then slows down as the weather increases. As can be seen in Fig. 12, the linear lines have not passed through the origin and this deviation from the origin or near the saturation may be due to the difference in transfer speed of mass between the initial and final stages of adsorption [109]. It turns out that intra-particle diffusion was not the only mechanism limiting the start of the adsorption process. The values ​​of KID, I, and the coefficient of determination R2 obtained for the plots are given in Table 3.

Fig. 12
figure 12

Intraparticle diffusion kinetic model of adsorption of methylene blue on treated walnut shells (a) and treated peanut shells (b)

Table 3 Comparison between the Pseudo-first-order, Pseudo-second-order, and Intraparticle diffusion model adsorption rate constants, calculated and experimental qe values for different initial methylene blue concentrations

From Table 3: R22> R21> R2ID, therefore the most suitable model for describing the adsorption kinetics of methylene blue on both treated walnut shells and treated peanut shells is the pseudo-second-order model.

3.11 Comparison of adsorption results with other available adsorbents

The adsorption capacities of treated walnut shells and treated peanut shells were compared with other adsorbents (Table 4). These data demonstrated that walnut shells and peanut shells are effective low-cost adsorbents for removing the methylene blue dye from the aqueous phase compared to other adsorbents.

Table 4 Comparison of the methylene blue adsorption capacities on various adsorbents

3.12 Thermal Regeneration of Adsorbents

Thermal regeneration not only removes all organic pollutants retained by physical adsorption as well as inorganic compounds from the pores of adsorbent materials without destroying their textural structure, but it also remains an ecological option preventing the formation of toxic substances from the waste solid. This study highlights the overall cost of the treatment process, the importance of the reuse of low-cost materials (such as agrifood waste), and their regenerative capacity at a temperature equal to 500 °C for two hours after adsorption of methylene blue (60 mg L−1) for which we obtained other adsorption capacities represented in the Fig. 13 bar graph under the same operating conditions mentioned above.

Fig. 13
figure 13

Effect of thermal regeneration cycles of treated walnut shell powders and treated peanut shell powders on the adsorption capacity of methylene blue dye ([MB] = 60 mg L−1, Amount of adsorbent = 0.5 g L−1, particle size = 90 μm)

The recycled output of both treated walnut shells and treated peanut shells for the removal of methylene blue for four cycles is shown in Fig. 13. The findings revealed that the dye removal potential for treated walnut shells increased significantly from 101.43 mg g−1 during the adsorption to 109.55 mg g−1 during the first thermal regeneration cycle and then decreased to 96.2 mg g−1 during the second thermal regeneration cycle and then decreased to 90.5 mg g−1 during the third thermal regeneration cycle and then decreased to 86.5 mg g−1 during the fourth regeneration cycle. The same thing occurred with the peanut shells, as the dye removal potential rose from 67.42 mg g−1 during the adsorption to 73.5 mg g−1 during the first thermal regeneration cycle and then decreased to 62.2 mg g−1 during the second thermal regeneration cycle, and then decreased to 58.5 mg g−1 during the third thermal regeneration cycle, and then decreased to 51.9 mg g−1 during the fourth thermal regeneration cycle. This may be attributed to the fact that fresh and free pores were generated for the first thermal regeneration cycle and then a greater basic surface which promotes the dye uptakes [120]. For the other thermal regeneration cycles, there is perhaps a biomaterials deterioration caused by heat treatment [121].

3.13 Process Economic Study and Cost’s Comparison

To better decide on the effectiveness and feasibility of a method and to predict and implement any potential environmental consequences, it is recommended that process costs be estimated taking into account the practicality of the material preparation procedures [122, 123]. These calculations were performed at the laboratory scale and their results, as well as those for other materials previously available in the scientific literature, are presented and summarized in Table 5.

The cost of the raw materials is almost negligible since they are agri-food waste available in large quantities. Therefore, the total cost is dominated by the cost of the chemicals used for the preparation of the two adsorbents. In conclusion, the adsorption of 1 L of methylene blue dye costs $0.6968 using walnut shells and $0.6965 using peanut shells. These two adsorbents remain less expensive overall compared to graphene oxide which costs $3.31 to synthesize 1 g [124] or to other commercial materials such as activated carbons whose price is around $0.75 and $2.60 kg−1, silica gels which cost approximately $4.4 to $5.3 kg−1, and polymer beads whose price is around $5.5 kg−1 [125]. Economically, both the two adsorbents TWS and TPS are inexpensive materials for industrial wastewater treatment.

Table 5 Cost analysis of methylene blue adsorption on TWS and TPS

4 Conclusions

The elimination of methylene blue from the aqueous solution by biosorption on the treated walnut shells and the treated peanut shells was studied in the present study. The biosorption capacity was estimated based on the initial pH, the contact time at different initial concentrations of dye, the dose of biosorbent, the temperature of the solution, and particle size. The kinetic modeling study showed that the experimental data followed the pseudo-second-order model. The equilibrium data were better adapted to the Langmuir isotherm model with a maximum mono-layer adsorption capacity of 101.43 mg g−1 for treated walnut shells and 67.42 mg g−1 for treated peanut shells. Thermodynamic analysis has shown that the adsorption of methylene blue by both treated walnut shells and treated peanut shells powders is a spontaneous, feasible, endothermic, physisorption and that the interfaces between the liquid and solid phases decrease randomly during the process. Treated walnut shells and treated peanut shells, as bio-adsorbents, have great potential for removing textile dyes because these are low-cost products and there is no need for expensive equipment and because of their regeneration power to be reused in the adsorption of methylene blue cationic dye despite the decrease in adsorption capacity up to the fourth cycle of regeneration due to the reduction in specific surface area by heat treatment. Furthermore, the cost analysis revealed that the adsorption of one liter of methylene blue dye costs $0.6968 with walnut shells and $0.6965 with peanut shells. Therefore, both TWS and TPS biomaterials could be considered cost-effective, selective, promising, and environmentally friendly for textile dye removal. Last but not least, chemometric tools, such as the design of experiments and artificial neural networks, could be explored in the valorization of peanut shells and walnut shells as effective bio-adsorbents to predict and optimize dyes removal from textile wastewater as an interesting perspective for future work.