Introduction

Biodiesel is a sustainable energy source that has recently received attention for many reasons, including global warming, depleting fossil fuels, and enhancing the concentration of contaminants in the environment1,2. Compared to fossil fuels, biodiesel produces less CO, less sulfur concentration, and unburned hydrocarbons. Generally, biofuels are non-toxic, recyclable, clean, and emit fewer pollutants3,4. Besides, adding a small amount of biodiesel to diesel significantly reduces the emission of some contaminants like particulate matter, CO, sulfur concentration, etc. as well as boosts engine performance factors including BTE and BP, so that in prior investigations, various blends of biodiesel to diesel such as B10 and B20 have been employed in diesel engines5,6.

Several processes are employed to generate biodiesel, such as microemulsion, pyrolysis, transesterification, and even esterification, among which transesterification is the chosen process among scientists for methyl ester synthesis7,8. In this procedure, methyl ester is synthesized through the reaction of methanol and oil in the existence of an appropriate catalyst. In converting oil to biodiesel, the oil source plays a critical role as it comprises 70% of the total biodiesel generation cost9,10. Waste cooking oil (WCO), owing to its availability and cheapness, is considered a useful feedstock compared to other oil sources for biodiesel generation11. Recent literature and market data indicate that WCO is available at significantly lower costs than virgin oils (e.g., palm, soybean), typically ranging between $0.20–$0.40 per liter, depending on the region9,10. Additionally, global WCO generation is estimated at over 29 million tons per year, highlighting its abundance as a renewable resource for biodiesel production8,11.

Magnetic materials have unique attributes such as low toxicity, simple synthesis, and high specific area. Besides, they can be easily separated from the final products utilizing a simple magnetic field. Various kinds of magnetic materials exist, including Fe3O4, Fe2O3, and MFe2O4 (M = Co, Ni, Cu, Mg, etc.)12. Metal ferrites or MFe2O4 have attracted much attention due to their interesting features, and these types of magnetic materials have been employed by many researchers for biodiesel generation13,14. On the other hand, graphitic carbon nitride (g-C3N4) is a strong material with considerable thermal and chemical stability15,16. Besides, it can be easily synthesized utilizing some materials such as urea, thiourea, and melamine. These substances are found in abundance on earth and are rich in nitrogen. Further, the pore structure, size distribution, functionalization, morphology, and composite formation can be easily adjusted with g-C3N416. Other advantages of g-C3N4 include easy synthesis, high reactive sites, nontoxicity, and low cost15,17.

Moreover, NiFe2O4 exhibits excellent magnetic separability and thermal stability, while g-C3N4 offers a high surface area, robust chemical stability, and numerous active sites. Despite these advantages, each material also has inherent limitations18,19: NiFe2O4 alone tends to have a relatively low surface area and limited catalytic efficiency, whereas g-C3N4 suffers from poor electrical conductivity and weak magnetic properties. However, when these materials are combined, the resulting NiFe2O4@g-C3N4 nanocomposite demonstrates pronounced synergistic effects. The composite structure enhances surface area, promotes better dispersion of nanoparticles, and facilitates more efficient electron transfer19,20. The g-C3N4 matrix effectively prevents the agglomeration of NiFe2O4 nanoparticles and increases the exposure of catalytically active sites, while NiFe2O4 imparts strong magnetic properties, allowing for easy separation and recyclability of the catalyst18,21. This integration not only improves biodiesel yield and reaction kinetics but also enhances catalyst reusability. Thus, the combination of these materials effectively overcomes their limitations and results in a more efficient, sustainable, and recyclable catalyst system for biodiesel production20. Besides, Ferrite-based catalysts, such as NiFe2O4, often face challenges including limited surface area, particle agglomeration, and partial leaching of active sites during repeated use, all of which reduce their long-term catalytic efficiency19,22. Moreover, their moderate catalytic activity may necessitate longer reaction times or higher catalyst loadings to achieve optimal yields. This study addresses these limitations by reinforcing NiFe2O4 with g-C3N4 nanoparticles, which enhance surface area, active site dispersion, and structural stability21. The g-C₃N₄ support offers abundant nitrogen-containing functional groups, improving interactions with reactants and facilitating electron transfer. On the other hand, NiFe2O4@ g-C3N4, though costlier to synthesize than CaO and MgO, offers key advantages like high reusability, magnetic recoverability, and superior catalytic efficiency. Unlike CaO and MgO, which suffer from leaching and low tolerance to moisture and free fatty acids, NiFe2O4@g-C3N4 maintains activity in multiple cycles22,23.

Diverse variables affect the purity of biodiesel production, such as MeOH/oil ratio, the concentration of catalyst, temperature, and contact time. To scrutinize the impact of these factors and their interaction on the purity of biodiesel, statistical techniques like CCD and BBD24,25. Ultrasonic irradiation plays a crucial role in enhancing biodiesel production by promoting better mixing of reactants, accelerating mass transfer, and increasing reaction efficiency, which collectively reduce the overall reaction time while simultaneously improving the biodiesel yield. This technique employs high-frequency sound waves to generate cavitation bubbles within the reaction mixture26. Upon collapse, these bubbles create localized zones of high temperature and pressure, which greatly enhance mass transfer between immiscible reactants such as oil and methanol. Moreover, ultrasound increases the reaction rate27,28. As a result, the reaction proceeds more rapidly and efficiently than under conventional stirring. Ultrasonication also promotes better catalyst dispersion and facilitates the breakdown of oil molecules, increasing the interaction between reactants and catalytically active sites26,29. Overall, this method reduces energy consumption and processing time while maximizing biodiesel yield. For instance, studies have shown that ultrasonic-assisted transesterification can reduce reaction time by up to 50% and increase biodiesel yield by approximately 10–20% compared to conventional mechanical stirring methods30. Compared to microwave-assisted methods, ultrasonication offers superior control over localized heating and bubble-induced micro-mixing, which contributes to improved mass transfer and faster kinetics in heterogeneous systems31.

The purpose of this original work is to synthesize biodiesel from WCO utilizing a strong, highly reactive, and novel catalyst. To this end, NiFe2O4@g-C3N4 nanocatalyst was synthesized through a combination of ultrasound and sol-gel processes and then utilized for improved methyl ester generation. Moreover, CCD was employed to evaluate the influence of diverse characteristics of biodiesel generation employing NiFe2O4@g-C3N4 nanocatalyst. The surface attributes of NiFe2O4@g-C3N4 nanocatalyst were assessed by diverse techniques such as FESEM, TEM, EDX, CO2/TPD, BET, XRD, FTIR, VSM, and Raman. Moreover, the kinetics of the reaction of transesterification in the presence of NiFe2O4@g-C3N4 nanoparticles were investigated. Further, the reusability of NiFe2O4@g-C3N4 nanoparticles in multiple cycles in order to their stability was surveyed. Furthermore, HNMR and FTIR analyses were conducted to confirm the biodiesel structure in the reaction medium. Based on our research, NiFe2O4@g-C3N4 nanoparticles are synthesized and characterized for the first time in this research and studied for biodiesel fabrication.

Chemicals and procedures

Chemicals

In this research, Fe(NO3)3.9H2O (iron(III) nitrate nonahydrate, purity ≥ 98%), N2NiO6.6H2O (nickel(II) nitrate hexahydrate, purity ≥ 98%), g-C3N4, and NaOH were purchased from Merck and Sigma Aldrich companies with high purities and then utilized in these tests.

Catalyst fabrication

NiFe2O4 nanoparticles synthesis

NiFe2O4 nanoparticles were attained by dissolving Fe(NO3)3.9H2O (16.16 g; 0.2 M) and N2NiO6.6H2O (5.82 g; 0.1 M) in 200 ml of water under constant stirring conditions. After that, NaOH (1 M) was added dropwise to this solution and stirred for 60 min to obtain a suspension with pH 9. A magnet stirrer was employed for stirring the mix for 1 h until the solution turned into a thick gel. The resulting gel was centrifuged at 5000 rpm for 20 min. Next, the precipitate obtained was put in an oven at 100 °C for 18 h to dry. Eventually, a furnace was employed to warm up the precipitate at 600 °C for 4 h to obtain NiFe2O4 nanoparticles.

Synthesis of NiFe2O4@g-C3N4 nanocatalyst

2 g of NiFe2O4 was dissolved in 50 cc of distilled water through ultrasonication. On the other hand, g-C3N4 powder was prepared by direct pyrolysis of urea (10 g) at 600 °C for 3 h. Afterward, g-C3N4 was added to the previous solution containing NiFe2O4 and ultrasonicated for 15 min to mix well. Then, NaOH was added to the solution drop by drop, while continuously stirring. This results in preparing a solution with a pH = 9. After that, the solution temperature was enhanced to 70 °C to obtain the desired gel. Next, the resulting gel was centrifuged at 5000 rpm for 20 min. The gel was maintained at 120 °C to dry. Eventually, the resulting substance was calcinated at 650 °C for 3 h to produce NiFe2O4@g-C3N4 nanoparticles.

WCO properties

WCO was prepared from restaurants, and after purification and removal of impurities, it was utilized as a feedstock for methyl ester production. The fatty acids in WCO were identified using gas chromatography-mass spectrometry (GC-MS), and their constituents are listed in Table 1 and illustrated in Fig. 1. GC-MS combines GC with mass spectrometry to identify and quantify the compounds in the oil more accurately. In this analysis, GC separates the compounds of the oil based on their volatility and provides a detailed profile of the fatty acids present. The sample is vaporized and carried by an inert gas through the GC column, where it is separated. The separated components are then ionized in the MS and detected based on their mass-to-charge ratio. In this study, GC-MS (YL6500 model) was applied to identify the fatty acid compositions in biodiesel. As reported, linoleic acid and oleic acid, with percentages of 50.69 and 32.46% are the most prominent compounds in WCO. After these 2 fatty acids, palmitic acid (9.34%) and stearic acid (7.19%) are other constituents of this oil source. Based on the weight percentages of the compounds, the average molar mass of WCO is 278.25 g/mol. Furthermore, the free fatty acid content in the oil was 1.62%, which is less than 2%. Therefore, we proceeded directly with the transesterification method. Additionally, the physicochemical features of WCO can be seen in Table 2. As shown, kinematic viscosity, density, saponification value, acid value, water content, pour point, and cloud point of WCO are 41.23 cSt, 0.909 g/cm3, 225.6 mg KOH/g oil, 6.14 mg KOH/g oil, 0.18%, 0 °C, and 6 °C, respectively. These features show that WCO is suitable for the transesterification process.

Table 1 The combinations reported in the WCO were analyzed using GC-MS.
Fig. 1
figure 1

GC-MS chromatogram of WCO.

Table 2 The physicochemical characteristics of the feedstock.

Biodiesel production process and experimental design

The transesterification reaction is applied to synthesize biodiesel from WCO in the existence of NiFe2O4@g-C3N4 nanocatalyst. In the transesterification process, a mixture of WCO, methanol, and NiFe2O4@g-C3N4 nanocatalyst was placed in a sonoreactor. An Ultrasonic Homogenizer (Topsonic, model UHP-400) was used in all experiments. The ultrasonic frequency, power, and amplitude were maintained at 40 kHz, 280 W, and 50%, respectively. Additionally, the reaction temperature was adjusted using an integrated digital controller. Moreover, the sample volume in each experiment was 50 mL. To do the experiments in the sonoreactor, ultrasonication irradiation was applied. Diverse variables were applied to generate biodiesel such as methanol/WCO molar proportion, nanocatalyst dosage (based on the mass of WCO employed), ultrasonic time, and temperature in the ranges of 10:1–14:1, 1.5–3.5 wt%, 25–35 min, and 55–65 °C, respectively. After converting WCO to biodiesel, there were two phases of glycerine and biodiesel, which were placed at the bottom and top of the test vessel, respectively. Afterward, the product and by-product were separated from each other to achieve biodiesel. To determine the compositions of fatty acids and chemical constituents in biodiesel, GC-Mass was employed. The biodiesel yield (BY) for each test was determined using Eq. 125:

$$\:BY\:\left({\%}\right)=\frac{Biodiesel\:weight\left(g\right)}{Weight\:of\:WCO\:\left(g\right)}\times\:100$$
(1)

By designing a series of experiments based on CCD, RSM facilitates the identification of the most significant factors and their optimal levels, as well as the interaction effects between different variables. The Design Expert Software was used to generate the experimental design matrix, analyze the data, and create response surfaces that illustrate the relationship between the parameters and biodiesel yield. To determine the association between BY and the reaction variables, a second-order polynomial model, as shown in Eq. 2, was used. This model accounts for both linear and interaction effects of the variables on BY24,32. The range of variables in the experimental design by CCD is presented in Table 3. Based on Eq. 2 and Tables 3, 30 tests were designed by the software, and the output is reported in Table 4. In this table, the results of the experiments in each test are included.

$$\:BY={b}_{0}+\sum\nolimits_{i=1}^{k}{b}_{i}{Z}_{i}+\sum\nolimits_{i-1}^{k}{b}_{ii}{Z}_{i}^{2}+\sum\nolimits_{i=1}^{k}\sum\nolimits_{j=i+1}^{k}{b}_{ij}{Z}_{i}{Z}_{j}+\epsilon\:$$
(2)

Where, Zi and Zj are transesterification variables (for example, NiFe2O4@g-C3N4 nanocatalyst dose, MeOH/WCO molar proportion, temperature, and ultrasonic time). Also, bi, bii, bij, b0, and ε are equation constant values.

Table 3 Parameters and their ranges in the experimental design by CCD.
Table 4 The experiments were designed using the CCD-RSM for biodiesel via NiFe2O4@g-C3N4 nanocatalyst.

Kinetics

The reaction kinetics of the transesterification reaction is determined by the kinetic models. In addition to experimental optimization, thermodynamic variables can be further specified by calculating kinetic parameters, such as the reaction rate or the rate constant (k). These parameters provide insight into the reaction’s speed and the catalyst’s effectiveness under varying conditions. To investigate the kinetic behavior of the transesterification reaction, the quasi-first-order kinetic model was employed. The Eq. (3) for the quasi-first-order kinetic model is given by33,34:

$$\:-ln\left(1-{X}_{E}\right)=kt$$
(3)

Here, XE and k are WCO-derived biodiesel yield and the reaction rate constant at time t (min− 1), respectively. In addition, Eq. (4) is applied to measure activation energy or Ea (kJ/mol), where the frequency factor is defined by A in terms of min− 1, R is the universal gas constant (8.314 J mol⁻¹ K⁻¹), and T is the absolute reaction temperature (K)35:

$$\:lnk=lnA-\frac{{E}_{a}}{R}\left(\frac{1}{T}\right)$$
(4)

Other parameters include entropy changes (\(\:{\varDelta\:S}^{o}\)), Gibbs free energy change (\(\:{\varDelta\:G}^{o}\)), and enthalpy changes (\(\:{\varDelta\:H}^{o}\)), which are important variables to investigate thermodynamic behavior. With the help of thermodynamic parameters, the reaction pathway can be cleared. Besides, thermodynamic parameters can determine whether the trans-esterification reaction for biodiesel generation utilizing NiFe2O4@g-C3N4 nanocatalyst is endothermic or exothermic. Moreover, the amount of entropy changes and its sign determines whether the reaction of biodiesel generation is spontaneous or not. Equations 5 and 6 present relationships between thermodynamic parameters36:

$$\:{\varDelta\:G}^{o}={\varDelta\:H}^{o}-T{\varDelta\:S}^{o}$$
(5)
$$\:ln\raisebox{1ex}{$k$}\!\left/\:\!\raisebox{-1ex}{$T$}\right.=\raisebox{1ex}{${\varDelta\:S}^{o}$}\!\left/\:\!\raisebox{-1ex}{$R$}\right.-\raisebox{1ex}{${\varDelta\:H}^{o}$}\!\left/\:\!\raisebox{-1ex}{$RT$}\right.+ln\left(\raisebox{1ex}{${k}_{b}$}\!\left/\:\!\raisebox{-1ex}{$h$}\right.\right)$$
(6)

where R (8.314 J/mol.K), T, h (6.63 × 10− 34 J.s), and kb (1.38 × 10− 23 J/K) are the universal gas constant, temperature, Planck constant, and Boltzmann constant, respectively.

Results and discussion

Nano-catalyst features

The outcomes of BET analysis for the fabricated nanocatalysts are summarized in Table 5, where key parameters such as the surface area, pore volume, and average pore diameter are listed. Regarding the results, the BET specific surface area (SSA) of NiFe2O4 and NiFe2O4@g-C3N4 nanoparticles are 86.73 and 119.55 m2/g, respectively, demonstrating that the inclusion of g-C3N4 in the NiFe2O4 structure has led to improved surface area. The same results were seen for Langmuir SSA, so that this feature for NiFe2O4 and NiFe2O4@g-C3N4 nanoparticles are 161.79 and 305.82 m2/g, respectively. Also, the pore size of NiFe2O4 and NiFe2O4@g-C3N4 nanoparticles is 9.74 and 13.68 nm, which are between 2 and 50 nm, displaying that both are mesoporous catalysts. Besides, the pore volume of NiFe2O4 and NiFe2O4@g-C3N4 nanoparticles is 23.49 and 16.24 cm3/g, respectively. The integration of g-C3N4 into NiFe2O4 can create larger pores within the composite structure, leading to an increased average pore diameter. Despite the larger pore sizes, the overall number of pores may decrease, contributing to a lower total pore volume. Additionally, combining NiFe2O4 with g-C3N4 often results in a more compact structure, which reduces the accessibility and number of smaller pores, further decreasing the total pore volume37,38,39. Figure 2 also illustrates adsorption/desorption diagrams of NiFe2O4 and NiFe2O4@g-C3N4 nanocatalysts. This figure displays a gradual increase in adsorption at low relative pressure, followed by a more pronounced uptake at high relative pressure (p/p₀ → 1), along with a clear H3-type hysteresis loop. These features are characteristic of Type IV isotherms with H3 hysteresis, indicating a mesoporous structure with slit-like pores, typically associated with layered or plate-shaped particles. Accordingly, the manuscript has been revised to clearly state that both NiFe2O4 and NiFe2O4@g-C3N4 exhibit Type IV adsorption–desorption isotherms with H3 hysteresis, consistent with meso-porosity39,40. These outcomes imply that NiFe2O4@g-C3N4 nanoparticles have sufficient surface area and cavities for the transesterification reaction.

Table 5 BET results for NiFe2O4 and NiFe2O4@g-C3N4 nanoparticles.
Fig. 2
figure 2

Nitrogen adsorption–desorption isotherms of the catalysts: (a) NiFe2O4 and (b) NiFe2O4@g-C3N4, revealing the type IV isotherms with H3 hysteresis loops.

Basic sites play a critical role in the transesterification process because they have a great influence on the reaction rate. CO2/TPD curves were applied to specify the total number of basic sites (TNBS) in NiFe2O4 and NiFe2O4@g-C3N4 nanoparticles, and the outcomes are seen in Fig. 3. Based on the results, the TNBS for NiFe2O4 and NiFe2O4@g-C3N4 nanoparticles are 180.6 and 208.5 µmol/g, respectively, which demonstrates that the strength of alkalinity has been enhanced by adding g-C3N4 in the NiFe2O4 structure. Moreover, the CO₂ desorption peaks were primarily observed in the temperature range of 150–350 °C, which corresponds to medium-strength basic sites. A relatively smaller desorption signal appeared above 350 °C, indicating the presence of strong basic sites. The absence of significant low-temperature desorption peaks (< 100 °C) suggests that weak basic sites are minimal. Therefore, it can be concluded that medium-strength basic sites dominate the surface, with a meaningful contribution from strong basic sites both of which are crucial for efficient transesterification24,25. Consequently, the superior catalytic performance of the NiFe2O4@g-C3N4 composite, compared to pure NiFe2O4, can be attributed to the greater number and strength of these basic sites. Therefore, NiFe2O4@g-C3N4 nanocatalyst can be considered a suitable catalyst for transesterification. Dharmasaroja et al. synthesized Al2O3-MgO catalyst and various amounts of cobalt and nickel were added to it. According to their results, the TNBS were obtained in the range of 160–220 µmol/g, which were approximately smaller than NiFe2O4@g-C3N4 nanocatalyst41. In another study, the TNBS of Co3O4@rGO42, CeO2, and 5Co15Ni/CeO243 were obtained as 201, 116, and 195 µmol/g, respectively, which are lower than this study. Therefore, the NiFe2O4@g-C3N4 nanocatalyst synthesized in this study has suitable basic sites.

Fig. 3
figure 3

CO2/TPD curves of NiFe2O4 (a) and NiFe2O4@g-C3N4 (b) nanocatalysts.

The surface morphology and topographical features of NiFe2O4 and NiFe2O4@g-C3N4 nanocatalysts were determined by FESEM analysis. FESEM analysis along with EDX results for both NiFe2O4 and NiFe2O4@g-C3N4 nanocatalysts are revealed in Fig. 4. Besides, the numerical data of EDX analysis are reported in Table 6. According to FESEM analysis, both NiFe2O4 and NiFe2O4@g-C3N4 nanocatalysts have porous structures. There are also numerous bumps and depressions on their surface. Further, as reported in Table 6, the weight% of O, Fe, and Ni elements in NiFe2O4 is 38.21, 33.72, and 28.07%, respectively. After producing NiFe2O4@g-C3N4 nanocatalyst, the weight% of these elements changed to 28.04, 25.83, and 12.08%, respectively. In addition to these elements, two other elements, including C and N with weight percentages of 25.31 and 8.74% were observed. Additionally, the internal structural information of the NiFe2O4@g-C3N4 catalyst was obtained through TEM analysis, and the results are shown in Fig. 5. As observed, there are numerous spherical particles with very small sizes. Accordingly, the particle size of NiFe2O4@g-C3N4 is lower than 50 nm, demonstrating that this catalyst is categorized as a nano-scale.

Fig. 4
figure 4

FESEM/EDX results for NiFe2O4 (a) and NiFe2O4@g-C3N4 (b) nanocatalysts.

Table 6 Numerical data of EDX analysis for NiFe2O4 and NiFe2O4@g-C3N4 nanocatalysts.
Fig. 5
figure 5

TEM analysis for NiFe2O4@g-C3N4 nanocatalyst.

To determine the functional groups in a substance, an FTIR device can be employed. Functional groups in the catalyst structure have impressive impacts on their activity and reactivity. This analysis was done for NiFe2O4 and NiFe2O4@g-C3N4 nanocatalysts, as seen in Fig. 6. In both nanoparticles, a wide and strong peak is seen between 3200 and 3500 cm− 1, which is attributed to OH- stretching vibrations. Besides, a peak around 740 cm− 1 is attributed to the Fe-O stretching vibration or metal-oxygen group. Moreover, a strong band at 1710 cm− 1 is related to OH- bending or hydroxyl group44. The presence of other peaks at 980 and 1360 cm− 1 indicates C–C stretching45 and –CH3 bending46, respectively. After producing NiFe2O4@g-C3N4 nanocatalyst, the location of some peaks was changed. For instance, the peak at 3440 cm− 1 related to NiFe2O4 nanoparticles shifted to 3215 cm− 1 related to NiFe2O4-g-C3N4 nanocatalyst. Moreover, several spectra in the NiFe2O4-g-C3N4 nanocatalyst structure, located at 1280, 1450, and 1650 cm− 1, are attributed to CN heterocycle stretching modes. Another peak at 850 cm− 1 shows the presence of triazine units or N-containing heterocycles47.

Fig. 6
figure 6

FTIR results of NiFe2O4 (a) and NiFe2O4@g-C3N4 (b) nanocatalysts.

Furthermore, Raman spectra are employed to determine chemical structures of materials, and the results of this characterization for NiFe2O4 and NiFe2O4@g-C3N4 heterogeneous catalysts are displayed in Fig. 7. According to the Raman spectra for NiFe2O4, several peaks are observed in different Raman shifts such as 340, 490, 705, and 1320 cm− 1, which confirm the correct synthesis of nickel-ferrite48. The Raman shift at 705 cm− 1 demonstrates A1g symmetry related to the stretching of the oxygen atom. Besides, the peaks at 340 and 490 cm− 1 are attributed to Eg and T1g, respectively49. After the fabrication of NiFe2O4@g-C3N4 magnetic catalyst, some new and strong bands appeared in its structure at 1390 cm− 1 and 1609 cm− 1, which are assigned to D and G bands, respectively. The peaks at 490, 696, and 1390 cm− 1 are also attributed to graphite carbon nitrite50.

Fig. 7
figure 7

Raman results of NiFe2O4 (a) and NiFe2O4@g-C3N4 (b) nanocatalysts.

VSM is a well-known analysis for determining the magnetic strength of materials. This analysis was employed to determine the magnetic feature of NiFe2O4 and NiFe2O4@g-C3N4 nanoparticles. According to Fig. 8, the magnetic strength of NiFe2O4@g-C3N4 is less than NiFe2O4 nanoparticles, which is owing to the existence of non-magnetic materials such as g-C3N4 in its structure51. The results show that the magnetic saturation of NiFe2O4 and NiFe2O4@g-C3N4 nanoparticles is 26 and 8 emu/g, respectively. These quantities of magnetic saturation show that NiFe2O4 and NiFe2O4@g-C3N4 nanoparticles have supermagnetic and paramagnetic attributes, respectively. These magnetic features help to separate them from the solution using a simple magnet with a strength of 1 Tesla52,53.

Fig. 8
figure 8

VSM results for NiFe2O4 (a) and NiFe2O4@g-C3N4 (b) nanocatalysts.

Furthermore, the outcomes of XRD for NiFe2O4 and NiFe2O4@g-C3N4 nanocatalysts are seen in Fig. 9. The purpose of this analysis was to determine the crystal planes in the structure of these materials as well as whether these catalysts have an amorphous or crystalline structure. As shown, both nanoparticles have some sharp peaks, demonstrating the high crystallinity of NiFe2O4 and NiFe2O4@g-C3N4 nanocatalysts. In the NiFe2O4 structure, the strong peaks at 35.7, 43.8, and 63.2 o show (311), (400), and (440) planes, respectively. Also, two weak peaks at 30.5 and 58 o demonstrate the (220) and (511) crystal planes, respectively. The existence of these peaks was approved by previous studies46,54. Besides, these spectra correspond to Card Number 10–032546. After the synthesis of the NiFe2O4@g-C3N4 nanocatalyst, slight changes were seen compared to NiFe2O4 nanoparticles. In addition to the previous peaks, two new peaks are seen at 19 and 27.5 o, which are related to the crystal phases of (111) and (002), respectively. These peaks were proved earlier in the g-C3N4 structure47.

Fig. 9
figure 9

XRD results for NiFe2O4 (a) and NiFe2O4@g-C3N4 (b) nanocatalysts.

Overall, g-C3N4 acts as a nitrogen-rich, high-surface-area support that promotes uniform dispersion of NiFe2O4 nanoparticles, thereby preventing agglomeration and increasing the availability of active catalytic sites19,21. Moreover, the π-conjugated structure of g-C₃N₄ facilitates efficient electron transfer between reactants and the active metal sites, which accelerates the transesterification reaction20,22. The strong interfacial interaction between g-C₃N₄ and NiFe2O4 further contributes to the structural integrity and long-term reusability of the composite catalyst23.

Key variables influencing the biodiesel synthesis

Several variables affect the biodiesel generation purity, including reaction temperature, ultrasonic time, MeOH/WCO molar ratio, and NiFe2O4@g-C3N4 loading. The results of biodiesel yield in different laboratory situations are seen in Table 4. According to these results, the NiFe2O4@g-C3N4 nanocatalyst could generate biodiesel with a purity of 98.83% under optimum conditions such as a temperature of 61.17 °C, NiFe2O4-g-C3N4 loading of 2.83%, MeOH/WCO ratio of 11.72:1, and ultrasonic time of 31.02 min. These results were optimized by the Design Expert Software, and the predicted values via the software can be noticed in Table 4. As reported, the predicted methyl ester yield values and the actual biodiesel yield values are very close, demonstrating the high accuracy of the outcomes. Besides, the statistical data for the interpretation of the results and the influence of each variable on biodiesel yield are reported in Tables 7 and 8. The low amount of p-value demonstrates the positive influence of each variable on the biodiesel purity. As shown, the p-value for each variable (i.e., temperature, ultrasonic time, methanol/WCO molar ratio, and NiFe2O4@g-C3N4 loading), their interaction impacts, and their squares, except for the interaction impact of temperature- nanocatalyst dosage is very small (< 0.05), which demonstrates that all these factors and their interaction are effective on biodiesel yield. Moreover, the high quantity of the F factor for a variable demonstrates the effectiveness of that variable in the performance of the catalyst in biodiesel generation. According to the outcomes, the F-value for the catalyst dosage parameter is higher than other variables, indicating that this parameter has had the highest influence on biodiesel yield using NiFe2O4@g-C3N4 nanocatalyst. Moreover, the interaction between the methanol/oil ratio and temperature parameters has the highest F-value (467.24), which demonstrates impact of this factor on methyl ester purity is significant. A high F-value, for example, for the interaction between the methanol/oil ratio and temperature parameters, indicates that the interaction between these factors is substantial compared to the variability within the data. This suggests that the model explains a significant portion of the variance in the response variable due to this interaction. On the other hand, a low p-value (i.e., < 0.05) indicates that the interaction effect is statistically significant. This provides strong evidence to reject the null hypothesis, confirming that the interaction between the factors is not due to random chance. Conversely, the interaction between the catalyst dosage and temperature parameters shows the highest p-value (0.8062) and the lowest F-value (0.062), demonstrating that there is no relationship between these independent parameters (i.e., temperature and catalyst dosage) and the response variable (i.e., biodiesel yield)55. Furthermore, according to Table 8, the values of R2, predicted R2, and adjusted R2 are high (> 0.97), which demonstrates that this model and the statistical data are reliable. Based on Table 7, the adequate precision proportion is 54.92, which shows a suitable signal for the results (> 4 is favorable). The reliability of this model can be approved by the C.V. quantity (i.e., 0.67%). Moreover, the laboratory data for this study are repeatable at the C.V. amount lower than 10%24,56. The final equation (Eq. 7) proposed by the response surface methodology is given by:

$$\begin{aligned}\:BY\:\left({\%}\right) & =98.21+2.04\times\:A-2.35\times\:B-1.43\times\:C+1.27\times\:D+1.14\times\:A\times\:B\\ & +0.53\times\:A\times\:C +3.19\times\:A\times\:D-0.91\times\:B\times\:C-0.037\times\:B\times\:D\\ & +1.45\times\:C\times\:D-3.64\times\:{A}^{2}-4.49\times\:{B}^{2}-0.64\times\:{C}^{2}-3.69\times\:{D}^{2}\end{aligned}$$
(7)

Also, the normal probability outcomes for WCO-derived biodiesel using NiFe2O4@g-C3N4 nanocatalyst are depicted in Fig. 10(a). Also, the predicted data versus actual results for this reaction are demonstrated in Fig. 10(b). According to these plots, there is a regular distribution between these results, which reveals the significant accuracy of the laboratory amounts. Moreover, Fig. 10(b) reveals that the anticipated value obtained using the CCD model is well-fitted with the laboratory data. As a critical result, the model utilized in this research is very trustworthy, as the laboratory values are fitted well with this model57.

Table 7 CCD-RSM outcomes for scrutinizing the impact of diverse variables on biodiesel purity using NiFe2O4@g-C3N4 nanocatalyst.
Table 8 Statistical values for biodiesel generation using NiFe2O4@g-C3N4 nanocatalyst.
Fig. 10
figure 10

Normal probability against studentized residuals (a) and predicted values vs. actual values (b) for biodiesel generation via NiFe2O4@g-C3N4 nanocatalyst.

Moreover, Fig. 11 shows the impact of diverse factors and their interaction on the efficiency of biodiesel. The influence of temperature on biodiesel purity was examined within the range of 50–70 °C. This temperature range provides insight into the optimal thermal conditions for maximizing biodiesel production while maintaining energy efficiency. According to this figure, the efficiency of biodiesel enhanced with rising temperatures from 50 to 60 °C and then dwindled. As it is clear, the boiling point of methanol is around 65 °C. When the transesterification reaction reaches this temperature, methanol begins to evaporate. As a result, the amount of methanol in the reaction medium decreases, leading to a reduction in biodiesel efficiency. According to the outcomes, the optimal temperature for this reaction occurred at 61.17 °C. This investigation indicates that the biodiesel generation process using NiFe2O4@g-C3N4 nanocatalyst requires less energy than previous studies58.

The MeOH/oil ratio is another critical factor in biodiesel generation. Previous research has shown that the amount of this factor for homogeneous catalysts is low, while its ratios are high for heterogeneous catalysts. In this article, the impact of methanol/WCO molar proportion in the range of 8:1–16:1 on the methyl ester purity in the presence of NiFe2O4@g-C3N4 magnetic nanocatalyst was studied, and the output is revealed in Figs. 11 (a, d, e). The yield of biodiesel, based on Figs. 11 (a, d, e), enhances with raising methanol/WCO ratio from 8:1 to 12:1. According to the results, the optimal ratio of methanol/WCO is 11.72:1. At higher proportions of MeOH/WCO, biodiesel efficiency dwindled because alcohol particles in the reaction medium occupy the active sites of the NiFe2O4@g-C3N4 nanocatalyst, which will deactivate the nanocatalyst pores. Besides, it will be more difficult to separate glycerin and methyl ester with higher amounts of methanol25.

Reaction time can be considered one of the most important factors in the transesterification process. Traditional methods such as utilizing a magnetic stirrer for mixing solutions, require a long time to complete the reaction, while the utilization of ultrasound is efficient to reduce the reaction time. Besides, the transesterification process utilizing ultrasound irradiation decreases energy consumption59,60. On the other hand, ultrasonic irradiation generates acoustic cavitation, which leads to localized microturbulence, high shear forces, and transient hot spots. These effects significantly improve the contact between immiscible reactants (oil and methanol), thereby enhancing mass transfer and accelerating reaction kinetics61. Figures 11 (b, d, f) displays the effect of ultrasonication time, ranging from 20 to 40 min, on biodiesel purity utilizing the NiFe2O4@g-C3N4 nanocatalyst. According to the results, an increment in ultrasonic time increases the efficiency of biodiesel, with the highest efficiency achieved at 31.02 min based on the RSM design. At times greater than 31.02 min, a reduction in biodiesel purity was noticed. As an extraordinary result of this study, it is worth mentioning that obtaining a purity of 98.83% after 31.02 min can be an amazing achievement. The transesterification reaction beyond the optimal time (e.g., 31.02 min) decreases the biodiesel generation efficiency because the reverse reaction occurs and esters produce soap60,61.

The final parameter investigated on biodiesel yield is the concentration of the NiFe2O4@g-C3N4 nanocatalyst. The amount of the utilized catalyst in the reaction is a key factor and affects the process cost. Also, it affects the hydrolysis process and formation of soap62. The influence of nanocatalyst loading in the range of 0.5–4.5 wt% was surveyed on biodiesel efficiency utilizing NiFe2O4@g-C3N4 nanocatalyst. As indicated, the efficiency of biodiesel increases with an enhancement in the concentration of NiFe2O4@g-C3N4 and then reduces. The utmost yield of biodiesel occurred at 2.85 wt% of the nanocatalyst, and beyond this concentration, the yield declined. The slight decline in biodiesel yield observed beyond the optimum catalyst dosage can be attributed to several factors. While increasing the catalyst amount typically enhances the number of active sites and accelerates the reaction rate, excessive NiFe2O4@g-C3N4 nanocatalyst loading may introduce adverse effects60,61. These include increased viscosity of the reaction mixture, which hampers efficient mixing and creates mass transfer limitations. Furthermore, an excessive amount of catalyst may promote undesirable side reactions such as soap formation, particularly in the presence of free fatty acids or moisture. This not only complicates product separation but also reduces the effective biodiesel yield25,62. Additionally, the broad optimum region in Figs. 11 (a, b, c) signifies significant quadratic effects, which are well-captured by the CCD12,26.

Fig. 11
figure 11

Influence of various factors on biodiesel yield employing NiFe2O4@g-C3N4 nanocatalyst.

Figure 12 shows the optimal situations of biodiesel synthesis employing NiFe2O4@g-C3N4 nanocatalyst. As shown, the utmost yield of biodiesel using these nanoparticles (98.83%) was attained at the ultrasonic time of 31.02 min, NiFe2O4@g-C3N4 loading of 2.85 wt%, reaction temperature of 61.17 °C, and methanol/WCO molar proportion of 11.72. The outcomes show that the NiFe2O4@g-C3N4 nanocatalyst has a very high reactivity because its biodiesel generation efficiency is significant during the fast reaction time. Table 9 highlights key catalysts studied for WCO conversion and emphasizes differences in yield outcomes, offering insight into each catalyst’s efficiency and effectiveness in promoting biodiesel synthesis. Furthermore, their operating conditions are seen in this table. As reported in Table 9, CuFe2O4 nanocatalyst showed a biodiesel yield of 90.24% after 30 min63, which is much lower than our study. In another study, Gardy et al. synthesized SO4/Mg-Al-Fe3O4 catalyst for biodiesel production from WCO, achieving a biodiesel yield of 98.5% after 300 min64. Additionally, Salimi and Hosseini studied the performance of K2O/BaFe2O4 in biodiesel production from WCO. According to their outcomes, the yield of biodiesel was 97.63%, which was obtained after 180 min65. Moreover, Sundaramahalingam achieved a biodiesel yield of 97.6% from Annona squamosa seed oil using KOH, with a sonication reaction time of 113 min66. In another study, researchers achieved a biodiesel yield of 98.7% from canola oil using CaO after a sonication reaction time of 2.5 h67, which is significantly longer than the reaction time in our study. Besides, Gupta et al. used CaO in producing biodiesel from WCO using ultrasonication, and they found a biodiesel yield of 93.5% after 30 min68, which was lower than this study. These outcomes reveal the significant reactivity of NiFe2O4@g-C3N4 nanocatalyst in biodiesel generation.

Fig. 12
figure 12

Optimum circumstances of biodiesel synthesis utilizing NiFe2O4@g-C3N4 nanocatalyst.

Table 9 Investigation of different catalysts in producing Methyl ester from WCO.

Reusability of NiFe2O4@g-C3N4

The reusability of a catalyst is primarily determined by its stability under reaction conditions, which includes resistance to deactivation, structural integrity, and the ability to maintain catalytic activity over successive cycles. Furthermore, the high reusability of catalysts contributes to their commercial applications25. The recyclability and stability of NiFe2O4@g-C3N4 nanocatalyst were investigated over seven consecutive transesterification cycles under optimal conditions, including a catalyst dosage of 2.85 wt%, a temperature of 61.17 °C, a methanol/oil ratio of 11.72:1, and an ultrasonic time of 31.02 min. After each reaction, the catalyst was efficiently recovered via magnetic separation, thoroughly washed with n-hexane to remove residual impurities, and subsequently dried at 80 °C for 24 h to prepare it for the next stage. The results of the reusability of NiFe2O4@g-C3N4 nanocatalyst are shown in Fig. 13. As shown, the yield of biodiesel using NiFe2O4@g-C3N4 nanocatalyst declines from 98.75 to 90.07% after seven cycles, which reveals that the nanocatalyst is still active and has a significant yield for biodiesel generation. The decline in nanocatalyst activity, resulting in reduced biodiesel yield, is attributed to several factors that affect catalyst performance over time. Key issues include the deactivation of active sites essential for transesterification, which leads to slower reaction rates and lower conversion efficiency24,78. Additionally, the accumulation of by-products like glycerol within the catalyst’s pores obstructs the structure, limiting reactant access and reducing the available surface area for the reaction. Impurities from the feedstock, such as free fatty acids and metals, also accumulate on the catalyst surface, causing further deactivation. Rashid and coworkers synthesized the Zr-AC-HSO3 catalyst and investigated its reusability in several cycles. According to their outcomes, the yield of biodiesel after 5 steps declined from 96.1 to 80%, indicating a 16.8% diminish during five reuse rounds. The reusability of the catalyst employed in this paper, i.e., NiFe2O4@g-C3N4 nanocatalyst, is higher than that studied by Rashid and coworkers78. Additionally, Fan and coworkers investigated the recoverability of ZrO2–TiO2–SO3H nanorods in 5 cycles of biodiesel production. After 5 steps of reusing the nanocatalyst, biodiesel efficiency declined from 98.6 to 85.1% (i.e., 13.5% decrease), indicating a lower stability of ZrO2–TiO2–SO3H nanorods than in our study79.

Fig. 13
figure 13

Reusability of NiFe2O4@g-C3N4 nanocatalyst in multiple steps.

SEM analysis was employed to examine the surface morphology of the NiFe2O4@g-C3N4 nanocatalyst in both fresh and used states (Fig. 14). The fresh nanocatalyst exhibited a uniform and porous structure, with NiFe2O4 nanoparticles well-dispersed over the g-C3N4 matrix. The layered morphology of g-C₃N₄ provided a large surface area and supported the even distribution of magnetic nanoparticles, minimizing agglomeration and enhancing the exposure of active sites. The nanoscale integration between NiFe2O4 and g-C3N4 indicated strong interfacial interactions, contributing to the catalyst’s high activity. In contrast, the used catalyst, analyzed after multiple transesterification cycles, revealed slight morphological changes. Some degrees of particle agglomeration and surface roughening were observed, likely due to the accumulation of organic residues and thermal stress during repeated use. Nevertheless, the overall structural integrity and porous framework remained largely intact, demonstrating good morphological stability and reusability. The preservation of key surface features supports the sustained catalytic performance of the NiFe2O4@ g-C3N4 composite, reinforcing its potential for long-term application in biodiesel production.

Fig. 14
figure 14

SEM images of the fresh and used NiFe2O4@g-C3N4 nanocatalyst.

XRD analysis was performed to investigate the crystallographic structure of the fresh and used NiFe2O4@g-C3N4 nanocatalyst (Fig. 15). The fresh catalyst displayed sharp, well-defined diffraction peaks corresponding to the spinel structure of NiFe2O4, along with the characteristic (002) plane of g-C₃N₄, confirming high crystallinity and successful composite formation20. After multiple transesterification cycles, the XRD pattern of the used catalyst retained similar peak positions, indicating that the crystalline phases of both NiFe2O4 and g-C3N4 remained largely intact21,22. However, a slight reduction in peak intensity and marginal broadening were observed, which may result from minor structural distortions, surface fouling, or a decrease in crystallite size due to repeated thermal and mechanical stresses. These findings confirm the structural robustness of the catalyst, reinforcing its stability and reusability for biodiesel production with minimal degradation24,25.

Fig. 15
figure 15

X-ray diffraction patterns for fresh and used NiFe2O4@g-C3N4 nanocatalyst.

Kinetics

The rate of reaction in the transesterification process, which converts fatty acids to methyl ester or biodiesel, is critical for evaluating the success of the process. For doing so, the quasi-first-order kinetic model is suitable for this assessment. In this survey, this model was employed to assess the kinetic behavior of the biodiesel generation transesterification process using the NiFe2O4@g-C3N4 nanocatalyst under experimental conditions, such as a catalyst dosage of 2.85 wt% and a methanol/oil ratio of 11.72:1, and the outcomes are described in Fig. 16. In this plot, the influence of ultrasonic time on the variation of –Ln(1-XE) is seen. From the slope of the curves at different temperatures, the kinetic rate constant enhanced from 0.026 to 0.0779 min− 1 as the temperature was raised from 328.15 to 338.15 K. Therefore, conducting the transesterification reaction at high temperatures, for instance, 65 °C in this study, is preferred as the reaction rate is higher. On the other hand, the results are trustworthy as the quantities of R2 are close to 1. This study is consistent with the study done by Maleki and coworkers25.

Moreover, Fig. 17(a) (Lnk vs. T− 1) and b (Lnk/T vs. T− 1) show the thermodynamic behavior of transesterification for WCO-derived biodiesel in the existence of NiFe2O4@g-C3N4 nanocatalyst. According to Fig. 17(a), the quantity of activation energy for performing the transesterification reaction utilizing NiFe2O4@g-C3N4 nanocatalyst is 101.2 kJ/mol, which is a huge amount compared to previous studies36. An activation energy of 101.2 kJ/mol in biodiesel generation suggests that the transesterification reaction requires a moderate to high energy input to proceed efficiently. This value represents the energy barrier that must be overcome for the conversion of reactants typically oil and methanol into biodiesel and glycerol in the presence of NiFe2O4@g-C3N4 nanocatalyst. The value of this magnitude indicates that the reaction is chemically controlled, implying that the rate-limiting step occurs at the catalyst’s active sites owing to the intrinsic chemical transformation, rather than being constrained by mass transfer or diffusion limitations36,80. Compared to conventional catalysts such as CaO (65–80 kJ/mol) or MgO-based systems (70–90 kJ/mol)81, the slightly higher activation energy observed in our study may be attributed to the multi-component nature of the NiFe2O4@g-C3N4 nanocatalyst and the stronger interaction between the reactants and the active sites on its surface. Despite this, the catalyst exhibited excellent biodiesel yield, likely due to its enhanced surface area, basicity, and the synergistic effects between NiFe2O4 and g-C3N4. Further, the frequency factor of NiFe2O4@g-C3N4 nanocatalyst is 31.4 × 1010. These outcomes demonstrate that the energy of NiFe2O4@g-C3N4 nanocatalyst is considerable to carry out the biodiesel generation process82. Moreover, the pseudo-first-order kinetic model was employed under the condition that methanol was present in large excess relative to the oil, ensuring that its concentration remained effectively constant throughout the reaction. This assumption was experimentally validated, as the plot of ln(1 – X) versus time exhibited a linear relationship with a high correlation coefficient (R2 > 0.98), confirming the suitability of the pseudo-first-order kinetic model36,81.

Based on R2 quantities for both diagrams (Figs. 17a, b), the experimental data are properly fitted with thermodynamic parameters. Table 10 also gives thermodynamic parameters like entropy, enthalpy, and Gibbs free energy changes. The enthalpy changes (98.5 kJ/mol) kJ/mol.K) display that the reaction of methanol and WCO in the presence of NiFe2O4@g-C3N4 heterogeneous catalyst is endothermic. On the other hand, the positive ΔS° value indicates an increase in disorder during the formation of the transition state, suggesting that the reaction may involve the desorption or release of smaller, more mobile molecules (e.g., methanol or methyl esters) from the catalyst surface as the reaction progresses79,81. This behavior implies that the transesterification reaction benefits from molecular freedom at the transition state, which can be attributed to the porous structure and high surface area of the NiFe2O4@g-C3N4 nanocatalyst. These structural features facilitate better reactant mobility and product diffusion, contributing to enhanced catalytic activity82. Thus, the positive ΔS° supports the idea that the reaction mechanism involves dynamic surface interactions, which are favorable under the ultrasonic and thermal conditions applied. Further, the Gibbs free energy changes (ΔG°), as presented in Table 10, indicate values ranging from 90.38 to 90.62 kJ/mol. The positive ΔG° confirms that the transesterification reaction is non-spontaneous under standard conditions, meaning that external energy input such as heat or the presence of a catalyst is necessary to overcome the energy barrier36,80.

Fig. 16
figure 16

Kinetic behavior of methyl ester generation through NiFe2O4@g-C3N4 nanocatalyst.

Fig. 17
figure 17

Thermodynamic behavior of methyl ester generation through NiFe2O4@g-C3N4 nanocatalyst.

Table 10 Thermodynamic results of WCO-derived biodiesel via NiFe2O4@g-C3N4 nanoparticles.

Biodiesel characterization

After generating biodiesel from WCO using NiFe2O4@g-C3N4 nanocatalyst in optimum circumstances, its physical features were evaluated by several characterizations. GC-MS was utilized to determine the existence of fatty acids in its structure, as given in Table 11. As indicated, there are several compounds in the structure of biodiesel, such as C18:2 (51.48%), C18:1 (30.96%), C16 (9.87%), and C18 (6.75%), respectively. As shown in Table 10, the biodiesel produced under optimal conditions achieved a high purity of 99.03%, indicating a highly efficient conversion process. Furthermore, the physical attributes of the produced biodiesel can be seen in Table 12. Based on the results, the quantity of kinetic viscosity, density, flashpoint, acid value, water content, pour point, cloud point, cetane number (CN), and heating value are 4.53 cSt, 0.872 g/cm3, 161 °C, 0.29 mg KOH/g oil, 0.16 wt%, −1 °C, 5 °C, 53, and 40.19 MJ/kg, respectively. These features of biodiesel illustrate that the fabricated methyl ester is suitable for utilization in diesel engines.

Table 11 GC-MS analysis to identify and quantify compounds present in biodiesel.
Table 12 Physicochemical attributes of WCOME.

FTIR and HNMR analyses were employed to find out the existence of a methoxy group or methyl ester in the structure of WCO-derived biodiesel. By comparison of chemical bonds in the structures of WCO and biodiesel, it is possible to understand whether the transesterification process of WCO to biodiesel utilizing NiFe2O4@g-C3N4 nanocatalyst is successful. The outcomes of FTIR analysis to determine functional groups and chemical compounds in WCO and WCO-derived methyl ester are demonstrated in Fig. 18. Several peaks exist in the structure of both WCO and methyl ester. Also, almost similar peaks are observable in both oils. The peak around 3049 cm− 1 can be assigned to -CH3 tensile vibration. Also, the uptake peak at 1819 cm− 1 shows the C = O stretching vibration, which is dedicated to fatty acids. Further, the uptake peak at 710 cm− 1 shows the –CH group. Moreover, 2 feeble peaks at 1190 and 1500 cm− 1 indicate -OCH3 and -CH2 functional groups83,84. After biodiesel generation using NiFe2O4@g-C3N4 nanocatalyst, the peaks of 1820 and 3049 cm− 1 in WCO were transferred to 1800 and 3070 cm− 1, and their intensities also increased. Also, the robust peak at 1190 cm− 1 appeared in methyl ester, which demonstrates the stretching vibration of the -OCH3 group. This peak in WCO has a lower intensity83,85.

Fig. 18
figure 18

FTIR spectra of WCO (a) and methyl ester (b).

The H-NMR spectra for WCO and WCO-derived biodiesel, presented in Fig. 19, illustrate the complex hydrogen environments within these molecules, each comprising long-chain fatty acids with various functional groups. The WCO spectrum exhibits a range of peaks, with both small and prominent signals that capture its structural diversity. A distinguishing feature in the biodiesel spectrum is a strong peak at around 3.63 ppm, absent in the WCO spectrum. This peak corresponds to methyl esters, a functional group unique to biodiesel, confirming that transesterification has successfully converted WCO triglycerides into biodiesel by forming methyl esters. Both spectra share several other peaks, indicating common structural elements in WCO and biodiesel molecules. For example, a peak at approximately 0.86 ppm is visible in both spectra, representing terminal methyl protons typically located at the ends of long fatty acid chains. A peak at 1.22 ppm, indicative of methylene protons within hydrocarbon chains, is another shared feature, reflecting the fatty acid backbones in both WCO and biodiesel. Additional significant peaks appear at 1.62, 2.01, 2.31, and 5.33 ppm, each attributable to specific hydrogen environments25,83. The peak at 1.62 ppm signifies β-methylene protons within the –CH2–C–CO2 framework. The 2.01 ppm peak represents methylene protons near double bonds in fatty acid chains, while the 2.31 ppm peak corresponds to α-methylene protons adjacent to ester groups, confirming ester linkages. The peak at 5.33 ppm corresponds to olefinic (-CH = CH-) protons, highlighting unsaturated bonds within fatty acids25,86. After biodiesel synthesis, slight shifts in these peaks are noted: peaks initially at 0.86, 1.22, 1.62, 2.01, 2.31, and 5.33 ppm in the WCO spectrum shift to 0.86, 1.2, 1.59, 2.04, 2.27, and 5.32 ppm in the biodiesel spectrum34,52. These shifts arise from electronic changes due to the conversion of triglycerides into methyl esters, affirming the chemical transformation into biodiesel.

Gelbard et al. suggested that the percentage conversion of oil into biodiesel can be easily determined by HNMR analysis. Equation 8 presents the yield of biodiesel using this method87.

$$\:\text{B}\text{Y}=\frac{2\times\:{A}_{1}}{3\times\:{A}_{2}}\times\:100$$
(8)

Where A1 and A2 are the areas of the methoxy and methylene protons, respectively. According to our results, the values of A1 and A2 were 24.68 and 16.75, respectively. Based on these values and Eq. 8, the yield of biodiesel using the NiFe2O4@g-C3N4 nanocatalyst is 98.22%, which is slightly lower than the experimental data (i.e., 98.83%).

The 13C NMR spectrum of the produced biodiesel is presented in Fig. 19c, providing detailed insight into its molecular structure. The spectrum clearly confirms the successful formation of fatty acid methyl esters (FAMEs), which are the main components of biodiesel. Characteristic resonances were observed at δ = 174 ppm, corresponding to the carbonyl carbon of the ester group, δ = 51 ppm for the methoxy carbon, δ = 29 ppm for the methylene carbons along the fatty acid chain, and δ = 14 ppm for the terminal methyl carbon41,88. The presence of these signals aligns well with the expected chemical shifts for biodiesel and verifies the complete transesterification of the feedstock oil. Furthermore, the 13C NMR data are consistent with the 1H NMR results, providing complementary structural information and reinforcing the conclusion that high-purity biodiesel was successfully synthesized under the applied reaction conditions.

Fig. 19
figure 19

HNMR spectra of WCO (a) methyl ester (b), and 13C HNMR of biodiesel (c).

Mechanism and scalability

Mechanism

Incorporating g-C3N4 nanoparticles into NiFe2O4 significantly improves catalytic performance by increasing the surface area and providing more active sites for the reaction47. The use of ultrasound in the reaction process aids in the dispersion of nanoparticles and enhances the interaction between the catalyst and the reactants, leading to better mixing and higher reaction rates88. In the NiFe2O4@g-C3N4 catalyst system, NiFe2O4 is a mixed metal oxide material that significantly impacts the reaction mechanism of biodiesel. The positive metal ions in the binary metal oxide structure exhibit Lewis acidity, while the negatively charged oxygen ions act as Brønsted bases and are susceptible to nucleophilic attack. During the methanolysis of oil, the catalyst’s surface active sites facilitate the cleavage of O-H bonds in methanol, resulting in the formation of hydrogen cations and methoxide anions89. However, g-C3N4 particles play a different role in the transesterification reaction. The g-C3N4 components are known for their electron-rich nature, which enhances the transfer of electrons necessary for the reaction. The g-C3N4 nanoparticles provide numerous active sites that facilitate the adsorption and activation of methanol molecules. When methanol is adsorbed onto the surface of g-C3N4, the catalyst promotes the separation of the proton from methanol, resulting in the formation of methoxide (CH3O⁻)47,90. The combination of NiFe2O4 and g-C3N4 creates a synergistic effect, where the active sites on g-C₃N₄ facilitate the adsorption of reactants, while NiFe2O4 provides stability and enhances overall catalytic activity47.

The main reactions for converting triglycerides into biodiesel in the presence of the catalyst and methanol are demonstrated in Fig. 20. As shown, the proton on methanol is separated by the catalyst to generate MeO⁻ (methoxide) or CH3O⁻. Briefly, the triglyceride is first converted to diglyceride, which is then converted to monoglyceride. Overall, the triglyceride reacts with three moles of methanol to generate biodiesel and glycerol89,91.

Fig. 20
figure 20

The proposed mechanism for producing methoxide ions on the NiFe2O4@g-C3N4 surface (a) and converting triglycerides into biodiesel and glycerol (b)89,91.

Scalability

WCO is an economical and sustainable feedstock for biodiesel production. It reduces production costs and minimizes competition with food resources92. Studies have shown that using WCO can reduce production costs by up to 30% compared to virgin oils93. Techniques like ultrasound-assisted transesterification enhance the interaction between the catalyst and reactants, leading to better mixing and higher reaction rates. Besides, ultrasonication offers greater energy efficiency compared to magnetic stirrers, mainly because it shortens the reaction time, reduces the product purification interval, and eliminates mass transfer resistance76. This method can increase the reaction rate by up to 50% compared to conventional stirring92,93. Additionally, the incorporation of g-C3N4 nanoparticles into NiFe2O4 increases the surface area and provides more active sites, enhancing the catalytic performance and energy efficiency of the biodiesel generation process. The scalability of this process is supported by the robustness and reusability of the NiFe2O4/g-C3N4 catalyst, the efficient energy consumption of the ultrasonic process, and the low cost of WCO as feedstock, making it suitable for large-scale biodiesel production92.

Conclusion

In this paper, NiFe2O4@g-C3N4 nanocatalyst was synthesized as a novel and strong catalyst for generating biodiesel from WCO. To determine the characterization of this nanocatalyst as well as NiFe2O4 nanoparticles to compare their attributes, FESEM, EDX, FTIR, XRD, TEM, EDX, VSM, BET-BJH, and CO2/TPD analyses were employed. Furthermore, the CCD statistical approach was applied for methyl ester synthesis optimization to investigate the effect of fundamental parameters like ultrasonic time, temperature, dosage of the nanocatalyst, and methanol/WCO molar proportion on the yield of methyl ester. After generating biodiesel, its physicochemical attributes were analyzed by HNMR, GC-MS, and FTIR. Furthermore, the kinetics of the transesterification process were surveyed to determine the reaction rate of WCO biodiesel in the presence of NiFe2O4@g-C3N4 nanocatalyst. After 31.02 min, the highest biodiesel yield was achieved at 98.83%, which is a remarkable amount. Besides, NiFe2O4@g-C3N4 nanocatalyst showed remarkable reusability, and its yield of biodiesel was higher than 90% after seven cycles. The kinetic studies showed that the reaction between alcohol and WCO in the presence of NiFe2O4@g-C3N4 nanoparticles is endothermic and non-spontaneous. Moreover, thermodynamic parameters like activation energy and frequency constant demonstrate that the transesterification process has more energy for biodiesel generation. Overall, this study highlights the industrial relevance of using WCO as a low-cost and sustainable feedstock. It highlights the promising potential of the NiFe2O4@g-C3N4 catalyst as a magnetically recoverable, reusable, and eco-friendly alternative to traditional catalysts. This study also demonstrates the feasibility of ultrasound-assisted transesterification under mild conditions. This approach reduces energy consumption and reaction time, which are critical factors for scalable biodiesel production. Additionally, it addresses important considerations for catalyst durability and regeneration in commercial applications. Further, recommendations for future work include enhancing catalyst stability, evaluating and minimizing metal leaching, scaling up the transesterification process, and integrating techno-economic and life cycle assessments to support commercial viability.