Introduction

With the rapid advancements of the past centuries, global energy needs have skyrocketed. This demand continues to grow yearly, but the overreliance on oil and its excessive consumption (105 times faster than its formation in nature (Netravali and Chabba 2003)) has led to increased prices in the global market. The urgency to overcome dependence on fossil fuels is further underscored by their significant contribution to the current environmental crises, particularly the alarming increase in greenhouse gas (GHG) emissions. Since the Industrial Revolution, the use of fossil fuels has caused the concentration of carbon dioxide in the atmosphere to rise from 280 to 390 ppm, primarily due to the combustion of coal, oil, and natural gas (OEHHA 2023).

The European Union (EU) Directive 2009/28/EC, drawn up in 2009, issued the so-called “Climate-Energy Package 20 20 20” to combat climate change and increase energy efficiency through the 2020 targets to reduce GHG emissions by 20%, increase energy savings to 20% and increase the share of energy produced from renewable sources in each Member State compared to the total energy consumption of the EU.

Finding clean and renewable energy sources thus becomes one of the most significant challenges for man, with repercussions in the medium to long term for economic development, global stability, prosperity, and the quality of human life. So far, several more or less successful options have been studied and implemented, such as the use of solar energy (both thermal and photovoltaic), hydroelectric, geothermal, wind, and biofuels, whose production could offer new opportunities for income diversification, promote employment in rural areas, develop a complete long-term replacement of fossil fuels and reduce GHG emissions.

Biofuels are different forms of fuel, whether in gas or liquid forms, obtained from biomass such as food crops, crop residues, forest residues, animal wastes, and landfills (Khan et al. 2021). Biofuels are renewable for less than one year for those based on crops, crop residues, and animal wastes, or about 35 years for those based on forest residues, compared to the hundreds of millions of years for fossil fuels. Among them, the most promising are bioethanol and biodiesel. Alcohols have higher octane numbers, enduring a higher compression ratio before the engine starts knocking, and higher oxygen content, making combustion cleaner and more efficient than gasoline. Moreover, their single boiling point makes them suitable for a spark-ignition engine, pure or blended with gasoline and preferably with reduced water content (Awad et al. 2017a, 2017b, 2018a; Abdalla et al. 2019). Biodiesel is a valid alternative to fossil diesel as one of the most promising renewable energy sources in liquid form available on the market. As ethanol, methanol, butanol Dimethyl Ether (DME), Ethyl tert-butyl ether (ETBE), and Methyl tertbutyl ether (MTBE), biodiesel is an oxygenated fuel (Awad et al. 2018b), consisting of a mixture of energy-rich hydrocarbon compounds chemically similar to the diesel fraction refined from crude oil, derived almost entirely from animal or vegetable oils (Perona 2017). It is renewable, biodegradable, safe, clean-burning, and efficient, with excellent performance for transport, machinery, and electricity production in vehicles and heating systems, where it can be used immediately, pure or blended at any level with petrodiesel. Therefore, on the one hand, it does not inject new carbon dioxide into the atmosphere (thus not altering the natural carbon cycle); on the other hand, it does not require new technologies and new engines but only minor modifications, therefore promoting its use and economic sustainability. These factors have made biodiesel use more adaptable and attractive to the current energy scenario, which ensures energy security, environmental sustainability, and rural development by shifting power from petro-based conventional refineries to agro-industry (Hassan and Kalam 2013).

The EU Commission, in the report “EU Agricultural Outlook 2021–2031” (European Commission 2021), predicts that in 2031, the consumption of the two fossil fuels, gasoline and diesel, will be down by 32% compared to 2022, bringing it to 139 billion litres (diesel) and 62 billion litres (gasoline), as shown in Fig. 1 from the report.

Fig. 1
figure 1

Use of conventional fossil fuels and biofuels in the European Union (billion litres), according to forecasts in the report “EU agricultural outlook 2021–2031” by the EU Commission (European Commission 2021)

It is estimated that biodiesel will have a peak of consumption in 2023 to 18.9 billion litres and then decline by 24% to 14.3 billion litres in 2031. Another study estimated that biodiesel production in Europe would reach 16 billion litres in 2023 and 18.7 billion litres by 2028, with the market primarily dominated by Germany (3 billion litres produced and 2.6 billion litres consumed in 2019) and the use of rapeseed oil as a raw material (39% of the total in 2018, decreased from 72% in 2008) (Mordor Intelligence 2024).

In Italy, 31% of the annual energy consumption, equal to 35 Million tonnes of oil equivalent (Mtoe), is attributable to transport. Of this percentage, fossil fuels represent more than 90%, although this share decreased by 26% from 2005 to 2021. In the same period, on the other hand, the use of biodiesel and organic petrol increased by 701%, from 177 to 1145 kilo tonne equivalent of petroleum (ktep), and today, more than 1.7 million tonnes of biofuels are consumed in Italy over 12 months. Biodiesel (91%) makes up the majority, with more than 1,500,000 tons, followed by biomethane with 7%, bio-ETBE, and ethanol with marginal contributions. Looking at the type of biofuels allowed for consumption, 86% is part of the so-called double counting, that is, produced from waste or residues, non-food cellulosic materials, and lignocellulosic materials that, therefore, may account for a double energy contribution. However, of this percentage, only 38.7% can be defined as “advanced”, which is not in competition with the agricultural sector and food (Verme et al. 2022).

The scenario in Italy has excellent potential for development and dissemination, as well as the observation of the trend of biofuel consumption in other countries of the Union. Although Italian values are generally lower than Germany and France above all, Italy is the first EU market for double counting fuels with about 950 ktep or 22% of the European total (in absolute values), and the first EU market for “advanced” fuels with a share of 33% for more than 400 ktep (Fig. 2) (Bureau Veritas 2023).

Fig. 2
figure 2

Sustainable biofuels released for consumption in 2020 and 2021 (ktons) by country of production (dal Verme et al. 2022)

Looking at the individual raw materials in the field of biodiesel, it is expected that the demand for palm oil will record the most significant decline because this type of oil will most likely have greater difficulty in obtaining the necessary certifications of environmental sustainability. On the other hand, the consumption of rapeseed oil will remain broadly stable in 2021–2031, with a share of about 50% of the total, while the use of sunflower and soybean oils will increase. The production of advanced biodiesel from waste oils and fats should also increase, thanks to double counting in mixing obligations with traditional diesel.

In the last decades, thousands of publications have analysed the production of biodiesel, starting from raw materials to the characteristics of the final product, passing through the different types of reaction that lead to its formation with various catalysts (more or less commercially usable) and all possible plant and process configurations.

Nevertheless, this paper is an overview of biodiesel production aimed at making it an integrative energy source with low renewable and economically advantageous potential. There is a transformation of the existing conventional methods of producing electricity by fossil fuel-based generation units and a global desire to rely more on renewable energy resources (RERs). Due to their intermittent availability and geographically distributed nature, RERs need to be integrated into an intelligent electricity grid, the so-called smart grid. Specifically, the development of innovative value-added technologies, solutions, and systems for the combined and distributed production of electricity and heat, mainly from renewable sources, aims at the development of distributed storage systems of different technologies, even in hybrid configurations, for the efficient and integrated management of energy carriers within the smart grid. Depending on the size and components of the network, we talk about macrogrid, microgrid, and nanogrid. This paper is focused on nanogrids.

Extensive prior work has investigated the integration of distributed energy resources and renewable energy resources into a smart grid from different perspectives (Sioshansi 2012; Zhong and Hornik 2013; Moreno-Munoz 2015; Rehmani et al. 2016; Ahmad et al. 2017). For instance, Yu et al. discussed the communication systems for grid integration (Yu et al. 2011). Farhangi outlined a road map for integration (Farhangi 2014). Chen et al. discussed the critical technologies for integrating multiple types of RERs (Chen et al. 2016). Adefarati and Bansal considered the integration of renewable distributed generators into a smart grid (Adefarati and Bansal 2016). Rehmani et al. provided an up-to-date overview of the communication aspects of integrating RERs into the smart grid (Rehmani et al. 2018).

However, to the author’s knowledge, no other comprehensive overview has been published about integrating biodiesel into a nano-sized grid. This overview covers all aspects of biodiesel properties, production processes, and integration with other renewable resources to obtain an efficient nanogrid managed by small communities, with the main objectives of exploiting local resources and making communities energetically independent. By collecting and recycling waste cooking oil appropriately, people help reduce the environmental impact of the food industry, promote a circular economy, conserve natural resources, and create a more sustainable future. This is desirable and applicable anywhere in the world, both in industrialised areas and under-developed regions, in the scale of a city, a neighbourhood, or a single restaurant.

This paper is not a systematic review of the relative literature but rather an overview of the main aspects to be considered in producing biodiesel and integrating it with other renewable energy sources into a nano-sized smart grid. The literature survey was performed using keyword searches on Google Scholar and Scopus. The keywords included “biodiesel production”, “biodiesel properties”, “biodiesel environmental impact”, “biodiesel small plants”, “small communities”, “smart grid”, “biodiesel nanogrid”, and “distributed energy resources”. Articles were selected after reading the titles and abstracts. After carefully reading the research background and objectives, we selected 128 articles, which have been read thoroughly to extract useful information and conduct a comprehensive overview. We covered more recent literature (91 papers in the last decade, from 2013 to 2024) but also relevant less recent literature about general findings cited in recent papers (37 from the previous years, from 1999 to 2012). This overview is organised into two main Sections. Sect. "Biodiesel: general aspects" provides an overview of biodiesel as a renewable energy source, while Sect. "Biodiesel for small communities" presents the perspective of integrating biodiesel in a smart grid. Finally, the conclusive part outlines future research directions.

Biodiesel: general aspects

What is biodiesel?

The intuition to use vegetable oil as an alternative fuel to that of fossil origin dates back to the late nineteenth century thanks to the ingenious Franco–German chemist and engineer Rudolf Diesel (1858–1913), who first used peanut oil during the 1900 Paris World Exhibition to power a powertrain he invented and built a few years earlier. During a speech in 1912, he said: «[…] The use of vegetable oils for engine fuels may seem insignificant today, but such oils may become in the course of time as important as petroleum and the coal tar products of the present times» (Agarwal and Das 2001). These words were revolutionary at a time when energy for all the industrial societies was still supplied by coal. Research on vegetable oils to be used as fuels intensified in periods of energy need such as World War I and II and the crisis of the seventies of the twentieth century. In fact, despite being a good fuel with a calorific value of about 90% of that of diesel, vegetable oil did not provide satisfactory performance due to its low volatility and high viscosity and led, following combustion, the formation of carbon deposits on the injection system resulting in deterioration of the piston seals. It is, therefore, worked to lower the viscosity of oils/fats of vegetable or animal origin to make them directly suitable as fuels in diesel engines through appropriate conversions, the subject of extensive research in recent decades with the production of thousands of patents and scientific publications.

The topical theme has catalysed attention even during the first two decades of the present century. The EU Directive 2003/30/EC defined biodiesel as a “methyl ester produced from vegetable or animal oil, of diesel quality, to be used as a biofuel”. According to the American Society for Testing and Materials (ASTM) standard, the term “biodiesel” refers to an apolar mixture of alkyl esters (usually Fatty Acid Methyl Esters, FAME) with long chains of fatty acids obtained from biological sources such as vegetable oils and animal fats by transesterification of triglycerides with an alcohol (usually methanol) and a catalyst (Vasudevan and Briggs 2008; Singh et al. 2020).

From an engineering point of view, biodiesel has better engine lubrication than diesel, significantly reducing maintenance costs and extending its life. The careful choice of oil (fatty acid composition), alcohol, and process technology allows the production quality of biodiesel to improve engineering and environmental performance significantly. However, the most significant barrier to the commercialisation of biodiesel is the higher cost compared to fossil diesel, mainly because almost all the sources used for the production of biodiesel come from edible oils of high quality, which contribute 95% to the production of biodiesel globally (Mathew et al. 2021). The use of non-edible oils is also not without problems; in fact, most of these oils contain a high amount of free fatty acids, and this could increase the levels of complexity of production processes by requiring, for example, alternate different approaches or adding additional steps, which increase the cost of production and reduce the yield below standards. On the other hand, animal fats contain more saturated fatty acids and usually exist in solid form at room temperature, which can cause problems in the production process. Despite this, Italy is the EU country with the largest share of consumption of biofuels produced with animal fat, almost 400 thousand tons of oil equivalent, corresponding to 50% of total EU consumption. The consumption of animal fat for biofuel has increased by 40 times from 2006 to 2021; it is expected to grow because it is very convenient from the perspective of aviation decarbonisation but should be limited, according to the recommendations of a new study commissioned by the association Transport & Environment for fear that high demand has already triggered fraud and creates an opportunity for new violations in the future. As a result, cheaper raw materials, such as waste oils (Zhang et al. 2003) have a high potential to produce low-cost biodiesel, which is competitive with diesel from a price point of view.

Different biodiesel generations

Based on its origin, biodiesel can be classified into four generations (Bashir et al. 2022).

First-generation biodiesel is produced from edible vegetable oils as raw materials. The cultivation of plants to produce fuels requires large areas. The race to acquire land for energy crops has affected vast regions of Latin America, Africa, China, India, and Southeast Asia in the last ten years. If Europe wants to replace only 5% of fossil fuels with first-generation biofuels, it should allocate 20% of the arable land to energy crops. A scenario that pushes to resort to extra-EU productions. All at the expense of spontaneous vegetation and forests or replacing traditional crops for food production. Although the use of palm oil for food purposes is declining in favour of other oils, the European Commission has planned to abandon the use of palm oil for biodiesel production by 2030, as the use of biodiesel derived from palm oil has a climate impact three times worse than that of fossil diesel, primarily due to indirect emissions generated by deforestation in the countries of origin (mainly Indonesia and Malaysia) (https://www.rinnovabili.it/mobilita/olio-di-palma-ue-biodiesel). The same applies to other oils derived from dedicated crops: either the current production is diverted from food to energy, or new crops must be implemented with consequent deforestation. The competition of first-generation biofuels with food crops immediately appeared as the element that put the whole agricultural system in crisis and affected food security. Therefore, first-generation biodiesel presents big ethical problems, both the inevitable food vs. fuel competition and the high environmental impact given by deforestation and increasing demands for water and fertilisers. Consequently, using such oils can only make sense as a source of triglycerides to optimise processes at the laboratory level, but barring the way to a subsequent implementation on an industrial/commercial scale.

Due to the criticalities posed by first-generation biodiesel, the research focused on second-generation biofuels from inedible raw materials. Their use does not compete with the food sector, may result from the land of low agro-forestry interest, is subject to desertification, and does not involve high production costs. However, these raw materials have low oil yields and are not easily accessible as they are highly localised globally and require additional methanol to obtain acceptable biodiesel yields. Some classifications include second-generation biodiesel derived from vegetable oils and waste fats (Ramos et al. 2019). In this case, anything of animal or vegetable origin not intended for human consumption is considered second-generation. If, on the other hand, the soil necessary for the cultivation of plants—even if not edible—and their restricted location in some regions of the planet are taken into account, then it becomes more appropriate to consider waste oils in the third generation category, as has been done in this research work.

Third-generation biodiesel is conventionally obtained from microalgae, a promising source that does not compete with food and arable lands, proliferates with photosynthesis, could reach high lipid content and reduces GHG and carbon emissions. Nevertheless, despite the vast literature of the last two decades, there are still many challenges to overcome, such as high production costs, low lipid productivity, as well as difficult large-scale cultivation, harvesting and extraction (Neeti et al. 2023; Gaurav et al. 2024). Waste oils and fats may also be considered among third-generation biodiesel sources. A particular interest is addressed to the so-called Waste Cooking Oils (WCO) or Used Frying Oils (UFO), all those oils and fats of vegetable or animal origin residues after food cooking processes in food industries, restaurants, fast food, or domestic users. Their use, in fact, not only does not compete with the food industry and does not involve high costs of raw materials, but, at the same time, makes possible the reduction of liquid waste and solves the problem of its disposal. Fried oil is one of the planet’s most dangerous pollution sources (Kulkarni and Dalai 2006). Unfortunately, there are still many people who, especially at home, improperly dispose of the oil used without thinking enough about how the easy superficiality of this gesture causes harm to the seas today, which is in constant danger of an ecosystem with precarious balances.

A viable alternative is the use of microalgae. Replacing all transport fuel consumed in the USA would require 0.53 billion m3 of biodiesel annually at the current consumption rate. Satisfying half of the current demand for transport fuels in the USA with biodiesel would require areas for cultivating oilseed plantations with unsustainable extensions, up to more than times the territory of the USA (Chisti 2007). Microalgae would appear to be the only renewable source of biodiesel capable of meeting global demand for fuels and completely replacing petro-diesel without competing with the production of food, forage, and other agricultural crop products because they cannot be used as a direct source of food for man and can grow in salt water and in areas that are not fertile and inefficient for agriculture. There have been thousands of publications over the last decade. However, there is still a long way to go before the economic feasibility of processes using microalgae and their effective commercialisation.

Finally, fourth-generation biodiesel is obtained by converting solar energy, a source of high energy content that is available, inexhaustible, and economical. Artificial and direct solar photosynthesis are the leading technologies that allow photosynthetic water to split through solar energy. This conversion can occur thanks to the action of microorganisms, possibly engineered from the metabolic point of view, with photovoltaic systems or inorganic catalysts. These are promising technologies, but they are still at a technologically embryonic stage and require a high initial investment (Singh et al. 2020).

Applications of biodiesel

Biodiesel finds its main applications as a fuel for heating systems and, above all, as a fuel for transport. Using biodiesel for heating and producing thermal energy for industrial use presents no particular technical problems. In general, it is sufficient to modify the boiler pulverising augers and increase the pressure at the delivery pump (1–1.5 atm) for pure biodiesel to be used. Very often, especially in multi-stage boilers, it is necessary to significantly reduce the amount of combustion air-fed due to the high oxygen content of the biofuel.

Regarding the use of biodiesel as a transport fuel, the need to ensure maximum compatibility with current engines has led to the marketing of biodiesel mixed with diesel up to 30% (BD30) and pure biodiesel (BD100) (Vasudevan and Briggs 2008).

Other applications of biodiesel, but in much smaller volumes than that of fuel, include use as heating oil, for energy generation, as a lubricant, as a plasticiser, as a high-boiling adsorbent to reduce industrial gaseous emissions, as a solvent (Knothe and Razon 2017) and even more recently as a phase change material (PCM) in the area of refrigeration thanks to medium/low temperatures at which phase change occurs (De Paola and Lopresto 2021).

Properties of biodiesel as a biofuel

Biodiesel is a transparent liquid, generally amber-coloured, composed of a mixture of alkyl esters of fatty acids, broadly similar to the diesel obtained from the fractional distillation of crude oil. The quality of biodiesel can be influenced by many factors affecting its physical and chemical properties. These properties must be within the range of values and verified by methods established by standardisation bodies, such as the European Committee of Standardization (ISO) and the ASTM, as summarised in Table 1. In Europe, the requirements for the recognition of biodiesel were collected and defined in EN 14214, approved by the European Committee for Standardisation on 14 February 2003.

Table 1 Specifications of biodiesel (fatty acid methyl esters) used as automotive fuel in diesel engines according to ASTM D6751 and EN 14214 (Ramos et al. 2019)

From a chemical point of view, oils from different sources have different acidic compositions in terms of length and degree of unsaturation of the fatty acids present (Table 2).

Table 2 Acid composition of certain vegetable oils (Pinto et al. 2005)

Since the starting oil comprises triglycerides formed by different fatty acids, the mixture of esters produced will also have various mechanical and physical characteristics (Ramos et al. 2019).

Generally, cetane number, combustion heat, melting point, and viscosity increase as chain length and unsaturation increase. Consequently, it is reasonable to consider enriching biodiesel with fatty acid esters that have properties that improve the biofuel.

A comparison of fossil biodiesel and diesel (Table 3) shows that the main advantages of biodiesel are biodegradability, non-flammability, low toxicity, renewability, increased combustion efficiency, increased cetane number, higher flash point temperature, making it safer to use and store, the possibility of being mixed with diesel in any proportion and the excellent lubricating properties. However, biodiesel has disadvantages compared to diesel, such as lower calorific value, higher pour and cloud point, higher viscosity, lower oxidation stability, corrosion to copper and brass, the ability to degrade plastic and natural rubber, and excessive engine wear (Ramos et al. 2019). Biodiesel has a point of cloudiness at a higher temperature than diesel, so biodiesel at low temperatures tends to form waxes, which are harmful to pumps and pipes. Research is focused on overcoming these problems by changing the type of raw materials, using additives, and changing the engine.

Table 3 Comparison of the main properties of biodiesel and fossil diesel (Ruhul et al. 2015)

Environmental impact of biodiesel

Biodiesel differs substantially from diesel in pollutant emissions from the exhaust pipe and contributes significantly to reducing GHG and global climate effects (Singh et al. 2020).

The amount of carbon dioxide emitted is similar between biodiesel and fossil diesel. However, the substantial difference between the two cases is given by the different origin of the pollutant: in the case of biodiesel, the carbon dioxide released corresponds in large part to that absorbed by the crop necessary for the production of the oil during its growth, while in the case of fossil diesel, it is the one stored in oil deposits over geological eras. It is, therefore, clear that while the crops destined for the production of biodiesel ensure a clear reduction of emissions in a short time, for diesel, this is not true because of such long reabsorption times (millennia), which makes it a full-fledged source of carbon dioxide.

Combustion of biodiesel, both pure and blended with diesel, leads to lower carbon monoxide, particulates, hydrocarbons, and sulfur compounds and zero emissions of aromatic compounds and sulfur oxides. Carbon monoxide in the exhaust gases indicates poor combustion, as it occurs in the case of a defect in the air or insufficient mixing. The greater quantity of oxygen present in fuels of plant origin than those of fossil origin, about 10% against 2%, contributes to significantly improving the quality of combustion, leading to a reduction in carbon monoxide emissions ranging from 15% for biodiesel to 20% (BD20) up to 40% in the case of pure biodiesel (BD100). Unburned hydrocarbons, in addition to representing a loss of calorific value, are hazardous substances for human health, being in some cases also carcinogenic, especially in the case of aromatic hydrocarbons. Using biodiesel leads to a reduction in unburned hydrocarbon emissions of about 15–20% for BD100. Moreover, since the percentage of aromatic hydrocarbons is almost nil, the danger of the emission is relatively low. Since it does not contain sulfur, biodiesel does not have sulfur dioxide in its flue gases. Nitrogen oxides are dangerous air pollutants because, in addition to their irritating effect on humans, they contribute to the so-called “photochemical smog” in case of strong solar radiation (volatile organic compounds, VOCs, react with nitrogen oxides NOx in the presence of sunlight and OH radicals, forming photo-oxidants), and the formation of acid rain in the presence of moisture. This type of pollutant is the primary environmental disadvantage due to the use of biodiesel because, due to the more significant amount of oxygen present, there is an increase in their emission of about 13%. However, NOx reductions ranging from 4 to 26% compared to diesel were also observed in some works (Pinto et al. 2005).

The danger of particulate matter, a cause of respiratory diseases and potentially carcinogenic, is strongly linked to the average size of the particles that compose it and to the substances adsorbed on their surface. Fine particulates, which are particularly dangerous because they are easily inhalable, form in quantities of less than 20–60% in the case of biodiesel-fuelled engines and are also less carcinogenic due to the lower presence of aromatic hydrocarbons.

Storage of biodiesel

Biodiesel is much safer to store and handle than diesel. It has, in fact, a higher flash point, fixed by the EN14214 standard at the minimum value of 120 °C, which is higher than the diesel flash point (72 °C). Moreover, the biodegradability is 95% for biodiesel and 40% for diesel. However, double bonds in many fatty acid chains increase the possibility of auto-oxidation, resulting in a high tendency for biodiesel to oxidise and be chemically unstable. For example, allyl hydroperoxides are produced by the oxidation of biodiesel and, being unstable, tend to form a series of secondary oxidation products. In addition, double bonds can also be subject to polymerisation reactions, resulting in the formation of high molecular weight products and increased viscosity. In addition to oxidation caused by exposure to air, biodiesel is also potentially subject to hydrolytic degradation due to the presence of water. To determine the oxidative stability of biodiesel, a Rancimat apparatus is used, in which an air flow is passed at a constant speed through a sample collected inside a sealed and heated container at a high temperature (110 °C). The flue gases are collected in a second container filled with distilled water, where an electrode continuously measures conductivity. When the sample dissociates, a rapid increase in conductivity can be observed, and the time required to reach this point is defined as the induction period (IP) (Focke et al. 2016). Samples of biodiesel produced from different oils were stored at room temperature in a transparent glass container and a non-transparent glass container. Samples were taken at regular intervals for 30 months, and a decrease in iodine number and an increase in acidity, peroxide number, viscosity, and impurity values were observed. The differences between the two containers were not appreciable during the first 12 months but became significant after that period (Bouaid et al. 2007).

Production of biodiesel

Vegetable oils, when used directly in diesel engines, produce severe damage in the long term, such as dirty injectors, carbon deposits, and gelling of lubricating oils. These consequences are attributable to high viscosity (10–20 times compared to diesel), low volatility, and highly reactive unsaturated hydrocarbons. In particular, high viscosity is a factor that significantly affects performance because the first combustion stage in the diesel engine is the process of atomising the fuel. To overcome these problems and make vegetable oils fuel suitable for diesel engines, oil could be diluted, micro-emulsified or chemically converted by many technologies from more traditional pyrolysis and transesterification (Demirbas 2009; Leung et al. 2010) to less conventional methods such as reactive distillation and the use of supercritical conditions, microwaves, ultrasound, membrane, plasma, etc. (Stoytcheva and Montero 2011; Babadi et al. 2022). The advantages and disadvantages of some of these technologies are summarised in Table 4.

Table 4 Advantages and disadvantages of biodiesel production technologies (Singh et al. 2020; Bashir et al. 2022; Babadi et al. 2022)

The transesterification or alcoholysis reaction of oils is the most widely used for biodiesel production and involves the conversion of one ester into another by reaction with an alcohol. This reaction reduces the viscosity compared to the starting oil since the linear esters remain by removing the glycerol from the product mixture, which has lower viscosities than the triglycerides. This improves the atomisation of the fuel and, consequently, its combustion characteristics. Going into detail, the overall transesterification reaction can be represented with a scheme of series–parallel reversible reactions. Specifically, triglycerides are converted into diglycerides by releasing alkyl ester chains; diglycerides are converted into monoglycerides and further alkyl esters; finally, the glycerol molecule and the last ester chain are liberated from monoglycerides (Kulkarni and Dalai 2006; Demirbas 2009). In the overall reaction, three moles of methanol react with a mole of triglyceride, producing one mole of glycerol and three moles of methyl ester, without considering the intermediate stages with the formation of diglycerides or monoglycerides (Gumba et al. 2016; Orege et al. 2022), as described in Fig. 3. In addition, the contribution of inverse reactions is disregarded, considering their velocities to be zero (Stoytcheva and Montero 2011; Issariyakul and Dalai 2012).

Fig. 3
figure 3

Overall transesterification and series–parallel glyceride conversion reactions (Nieves-Soto et al. 2012)

Generally, short-chain alcohols such as methanol and ethanol are used, forming methyl and ethyl esters, respectively. Methanol is usually used in industrial processes thanks to its low cost and chemical-physical characteristics. This is so much so that the technical legislation and current legislation indicate biodiesel as a mixture of methyl esters of fatty acids (FAME, Fatty Acid Methyl Esters). However, ethanol experimentation continues to attract much interest for its potential renewable origin within totally green processes.

The other product of the reaction is glycerin or glycerol. This polar compound is separated from the biodiesel-rich phase of the reaction mixture to have a viscosity of the order of magnitude of diesel. After separation, the raw glycerol contains unreacted methanol, so purified glycerin needs to be obtained post-treatment for different industrial applications. Glycerol is a valuable by-product used in the organic chemical, pharmaceutical, and cosmetic industries and as a food additive (identified by the abbreviation E422). Glycerol has important new applications in emerging sectors, such as Phase Change Material (PCM) (De Paola and Lopresto 2021).

Due to the reversibility of the reaction, it is preferred to push the balance towards the products by operating in a net excess of alcohol or by separating glycerin while it forms (De Paola et al. 2009; Calabrò et al. 2010). In addition, for the reaction to occur within a reasonable time and with acceptable yields in terms of esters and glycerol, it needs a catalyst. The most widespread process currently involves using an alkaline catalyst. However, in certain circumstances, it is preferred to work with acid catalysts; enzymatic production and heterogeneous catalysis are also becoming increasingly attractive.

The alkaline catalyst production process involves using alkaline hydroxides, which include sodium and potassium hydroxides, due to their high availability and cost-effectiveness. The rate of base-catalysed reaction is about 4000 times higher than that of acid catalysis, with the same amount of catalyst used, which is why it is used more for industrial applications. The molar oil/alcohol ratio can vary from 1:1 to 1:6, while the temperature range includes values between 25 and 120 °C. This type of catalysis is more efficient and less corrosive than acid. Still, at the same time, it has technological limits related to the “sensitivity” of the process to the purity of the reagents and the presence of water in the starting oil. In fact, in the presence of water, a part of the reagent (in particular, the free fatty acids, FFA) can be consumed for obtaining soaps instead of the desired products, thus leading to the formation of an emulsion that downstream of the process makes the recovery and purification of the target compound more difficult and costly (Shimada et al. 2002; Marchetti et al. 2007)In addition, water, either from oils or fats or formed during the saponification reaction, delays the transesterification reaction through the triglyceride hydrolysis reaction to produce diglycerides and FFA. Therefore, using an alkaline catalyst requires the oil to be anhydrous and contain no more than 0.5% by weight of FFA.

Transesterification supported by acid catalysis mainly involves sulfuric acid, phosphoric acid, and organic sulfonic acids. Due to the low reaction rate and the high alcohol/oil molar ratio required of 30:1, acid-catalysed esterification has not gained the same attention as the alkaline process. Specifically, the acid-catalysed reaction requires a time and a higher reaction temperature (55–80 °C) than the base-catalyzed reaction. However, it is much more effective when the amount of free fatty acids in the oil exceeds 1%. Acid catalysts do not give rise to the unwanted saponification reaction in the presence of FFA and water in the starting oil. Therefore, it is advisable to use acid catalysis with oils containing a high FFA content, possibly at a preliminary stage of the reaction. Studies carried out on an economic analysis have shown that acid catalysis, being a single step, is cheaper than the alkaline process, which requires a further step to convert free fatty acids into alkyl esters, thus avoiding the saponification reaction. In a study on acid-catalytic transesterification of soybean oil, the yield in esters increased as the molar methanol/oil ratio and the catalyst amount increased (Canakci and Van Gerpen 1999). In addition, water in the oily phase inhibits the transesterification reaction, so it is necessary to operate with high molar methanol/oil ratios to complete the reaction. Among the negative aspects, the corrosion of equipment, valves, and pipes in contact with the reaction mixture is added, resulting in a request for more constructive measures.

Enzymes are biological catalysts in the form of globular proteins that drive the chemical reactions in living organisms’ cells. The enzyme used for the production of biodiesel by transesterification is lipase (triacylglycerol ester hydrolase EC 3.1.1.3) (Marchetti et al. 2007; Lopresto et al. 2015), which catalyses the breakdown of triglycerides, releasing free fatty acids, diacylglycerols, monoacylglycerols, and glycerol. Like any other catalyst, the enzyme does not influence the free energy of the reaction, thus leaving the thermodynamic equilibrium unchanged, nor is it consumed during the process. Unlike typical synthetic catalysts, however, the complex structure of enzymes results in high selectivity. Moreover, thanks to their biological origin, enzymes are active under very mild temperatures (30–40 °C) and pH conditions but require adequate plant design so that the high cost of the enzyme does not negate the economic advantage resulting in energy savings. Given these significant advantages, enzymes suffer from a greater loss of activity over time and a generally higher cost. In general, it is necessary that the chosen lipase leads to high yields in esters, has relatively low costs, and can be easily reused after each reaction cycle. Scientific research efforts shall focus on identifying lipases that can be reused for a more extended period and on operational conditions that facilitate reuse (Lopresto et al. 2019). Genetic engineering also investigates the possibility of producing lipases from recombinant microorganisms, promising reduced lipase costs.

Although conventional alkaline homogeneous transesterification quickly leads to high triglyceride conversions, energy demand is high, and product purification and catalyst recovery processes are complex. Such critical issues can be overcome with heterogeneous catalysis, which avoids the formation of soaps during the reaction and makes the catalyst easily recoverable, but with lower yields at higher times, higher temperatures, low scalability, and high total costs (Stoytcheva and Montero 2011). For this reason, research is very active in finding heterogeneous catalysts that guarantee adequate performance, including immobilised enzymes, zeolites, clay, ion exchange resins, oxides, calcium carbonate, etc. (Pinto et al. 2005). Zeolitic alkaline catalysts Li/Nay, with various Li2CO3 and Nay compositions, have been used to catalyse the production of biodiesel from castor oil and ethanol, with the advantages of having selective catalysts for both reagents and products by varying the size of the pores and of making both the esterification and transesterification reaction co-occur within the microporous and crystalline structure (Li et al. 2019). Also, heteropolyacids (HPA)—hydrogen and oxygen compounds, adding molybdenum, vanadium, tungsten, arsenic, phosphorus, or silica—are very interesting. Thanks to their oxidising power, acidity, and thermal stability, HPA are “green” and versatile catalysts for various situations, and they are classified as Keggin or Well-Dawson HPA. The difference consists in the availability of surface area, which can be improved by immobilising a support material (e.g., carbon, silica, resins, zeolites, and metal oxides). Such support increases the catalyst’s surface, reduces solubility and leaching (leaching) in reaction, and improves thermal stability. HPA catalysts of the Keggin type have also been used in the transesterification process, resulting in an effective catalyst active in the presence of FFA and tolerant to water, achieving a conversion of over 90% (Morin et al. 2007; Da Silva et al. 2017). However, this requires a reaction time of many hours. Finally, another category that deserves attention is industrial waste, such as marble dust from the same processing waste, blast furnace slag, limestone sludge, rocky debris, etc. Such waste has a high content of MgO and calcium-based components, such as CaO and CaCO3, and can be used in biodiesel production (Orege et al. 2022).

Biodiesel for small communities

Biodiesel in Distributed Energy Resources

Distributed Energy Resources (DER) are small-scale plants that produce energy near users, such as homes or workplaces, presenting themselves as a valid, optimisable alternative to the classic electricity networks. Thanks to their small size, with power ranging from a few kW to some MW, such networks have lower costs and can have higher electricity transmission rates along their lines. The distributed generation allows the penetration and distribution of closed energy cycles based on renewable sources with zero waste formation and no environmental impact (Orecchini and Santiangeli 2011). The combination with green power makes the DER an eco-sustainable alternative, using wind, geothermal, biomass, hydroelectric, or photovoltaic energy. The energy outputs of these networks vary from 3 kW to 50 MW and are to be considered in parallel with the electricity utility or autonomous units. Usually, they function as backup generators or for on-site energy production. Sometimes, they are also present in cogeneration processes and have energy storage units. Among the various innovative technologies of the DER are microturbines that produce up to 500 kW of power, fuel cells that exploit electrochemical processes, photovoltaic systems, wind systems, and hybrid systems (Capehart 2016). The DER’s continuous evolution has influenced various world countries differently depending on their technological development. The first result was to have smaller and more easily manageable energy production centres, both logistically and technologically, instead of larger energy plants. The division into small production plants has also made it possible to have more storage systems in such small DER, both to provide energy to consumers in the vicinity of such plants and to exploit the accumulated energy as an energy backup (Bistline and Blanford 2021; Huynh et al. 2022).

Smart grid, nanogrid, and energy communities

An essential and emerging way of energy management is the smart grid, a novel electric grid merging information and communication technologies and control systems with the power grid. This system includes electrical-digital connections and allows you to connect possible users belonging to the network, trying to meet the energy demand of the network itself, to power generation plants (Hossain et al. 2016). A smart grid must have at least one power input and output, while the electricity storage may or may not be present. Conventional grids have unidirectional power flows designed for large centralised power plants with concentrate generation and no consumer participation (Orecchini and Santiangeli 2011). Instead, a smart grid has two possible flows: two-way energy flows and two-way information flows. In the first case, energy can be generated by power generators and delivered to the customers or generated by the customers and injected back into the power grid. Instead, in the second case, utilities have access to real-time information, and customers control dynamic energy flows to meet their electricity demands (Rehmani et al. 2018). Depending on the size and components of the network, we talk about macrogrid, microgrid, and nanogrid. This paper is focused on nanogrids. Usually, a nanogrid for domestic use is a smaller microgrid under direct current (DC) with a power of less than 5 kW, which allows to connect more energy generation plants such as photovoltaic systems, micro-CHP (Cogeneration Heat and Power) powered by Stirling or natural gas microturbines, fuel cells, etc. (Fig. 4).

Fig. 4
figure 4

General scheme of a nanogrid (ComESto 2021)

The basic structure of a nanogrid consists of the following:

  • A local renewable energy plant, such as solar or wind energy, or non-renewable, such as diesel generators;

  • Local loads, household appliances, and items in a dwelling that require power to operate;

  • An accumulation system, the presence of which is considered optional but, generically, is an integral part of the nanogrid since it provides more excellent stability;

  • A controller that verifies the behaviour of the nanogrid according to the specified objective; the selection of the operating mode of each converter (a device that interfaces the energy production sources, storage systems, and loads to the standard direct current DC or alternate current AC bus of the nanogrid), allows the coordination of the different systems optimising the production, storage, and consumption of electricity;

  • A gateway, which is a bidirectional connection that allows the transmission of measurement data and information with other nanogrids, microgrids, or the national network.

A key feature of nanogrids is their ability to be interconnected, operating, and communicating within the microgrid and connected to the macrogrid. Nanogrids have allowed people and entire communities who did not have the opportunity to use electricity to take advantage of the latest mobile phone technology without switching from fixed telephony. Using innovative devices such as nanogrids that combine local generation sources, loads, and energy storage systems (ESS) represents the link between energy efficiency and the development of the renewable energy community (REC). The interface with the network features a DC/AC converter called Power Electrical Interface (PEI), a two-way power converter that regulates the power flows between the nanogrid and the network. It can absorb or deliver power when the nanogrid is connected. In addition, the PEI allows the nanogrid to operate as a single system, providing auxiliary services to the network when required. The nanogrid makes the interconnection between different renewable sources easier, and the ESS has a central role because it compensates for load variations and can absorb or release energy, allowing the control of the power required to increase self-consumption or services (Nordman 2010; Menniti et al. 2020).

Biodiesel as energy storage and energy supply

Biodiesel can be considered a non-conventional energy storage system and an energy supply for a renewable energy community. Biodiesel production can be powered by solar energy obtained through photovoltaic panels, and the biofuel produced can be stored to be helpful when solar panels do not make the required energy. Therefore, biodiesel becomes an energy storage system used in an internal combustion engine in cogeneration and integrated with the nanogrid (Fig. 5).

Fig. 5
figure 5

Biodiesel as energy storage and energy supply for the combined production of thermal and electrical energy (Falbo et al. 2022)

Transesterification involves energy consumption that can be provided when there is a surplus of production from renewable sources. The accumulated energy is returned, except for conversion losses, when biodiesel powers the internal combustion engine and produces electricity fed into the grid for the community’s consumption phase and network services to meet internal and external demand. Usually, wind and solar energies are primary renewable sources, while the biodiesel generator works as secondary sources in case of bad weather conditions and consequent power failure (Martin and Chebak 2016).

Maleki et al. modelled a hybrid energy system consisting of photovoltaic panels, a battery storage system and a diesel generator as a backup power source. They used various biodiesel fuels to generate electricity for a typical Iranian village household. Specifically, they produced biodiesel by transesterifying oil from indigenous Norouzak (Salvia leriifolia) seeds. Ultrasound-assisted alkaline transesterification was performed at 45 °C, with a methanol-to-oil ratio of 6:1 and 1% potassium hydroxide as a catalyst. The results indicated that the biodiesel produced in the hybrid energy system satisfies the electrical needs of a rural house (Maleki et al. 2016).

Mehrppoya et al. proposed an integrated cogeneration process to produce biodiesel and power in an Organic Rankine Cycle using solar collectors to supply the required process power. They comprehensively analysed the solar system, the biodiesel production by alkaline transesterification and their integration in a cogeneration plant for power and heat generation. Specifically, methanol, sodium hydroxide and pre-heated oil are pumped into the transesterification reactor, where 95% of the oil is assumed to be converted to biodiesel and glycerol. The product stream is introduced to the methanol distillation column: pure methanol is recycled to the transesterification reactor, and the bottom stream is pressurised, cooled and entered into a washing column. Then, biodiesel is separated from glycerol, methanol, sodium hydroxide, and water. Ultimately, separate glycerol and biodiesel streams are further purified. An Organic Rankine Cycle generates power by converting liquid Re-113 to hot vapour and successive expansion in a turbine. Finally, parabolic trough solar collectors supply the required thermal energy for biodiesel production and the Organic Rankine Cycle (Mehrpooya et al. 2020).

Algieri et al. analysed the integration of biodiesel, solar, and wind energy to produce combined heat and power for small-scale residential applications. An Organic Rankine Cycle fuelled by biodiesel and an auxiliary backup boiler produce thermal energy. In the Organic Rankine Cycle system, the working fluid (toluene) is pressurised by a pump, preheated and vaporised by an evaporator, expanded in a turbine until the condensation pressure, and finally condensed. Biodiesel feeds a boiler, producing thermal energy for the Organic Rankine Cycle system through a thermal oil circuit. At the same time, a wind turbine and a photovoltaic unit operate in parallel to produce electricity to be exchanged with the grid. Such an integrated system overcomes the intermittent nature of wind and solar renewable sources (Algieri et al. 2020b).

An important example of local self-production and biodiesel consumption in an energy community is in a condominium in the metropolitan region of São Paulo, Brazil, consisting of 23 floors, with four apartments per floor of about 53 m2 each, as well as common areas, you have an average monthly energy consumption of 7300 kWh and opting for a smart grid, with a specific rate, through an electric generator connected to the “grid” you can compensate for the costs due to the hours when the peak of energy required is at most. This generator uses a blend of 10% biodiesel and 90% vegetable oils, satisfying the demand, producing additional biodiesel, and allowing users of the smart grid to have lower consumption costs for energy. In addition, the generator contributes to the reduction of power outages and blackouts, allowing awareness of the environmental impact of energy consumption, reduction of GHG emissions (even more clearly if cogeneration plants are used), and the advertising of such benefits to other persons who could form a possible new energy community (Guerhardt et al. 2020).

Small-scale plants for biodiesel production from waste cooking oils

The possibility of exploiting biodiesel in a smart grid as an eco-sustainable source for energy storage and its subsequent use in nanogrids opens up the possibility of building small-scale plants. Waste Cooking Oils (WCOs) from the daily frying and cooking of food in domestic kitchens or the catering sector are economical and sustainable raw materials since waste that would otherwise be destined for complex disposal could be valorised to produce energy. Small-scale plants have many social, economic, and environmental advantages. They also contribute to making renewable energy and rural development. Small-scale plants are mainly intended for small communities, whether individual families or groups of families, whether they are businesses, villages, or catering and food distribution activities (De Paola et al. 2021). Small communities can use local resources and independently manage the biodiesel production process to exploit waste and become as independent as possible and self-sufficient in energy.

Equipment for small-scale biodiesel production is available in many sizes, with varying accessories and different qualities of construction materials. Some systems are labour-intensive, while others are highly automated, adding to the total cost. Oliveira et al. designed and constructed a mobile biodiesel production unit (100 L/h) destined for small-scale oil producers and equipped with some systems for the extraction and purification of vegetable oils from seeds; various storage tanks for the reagents, products and washing water; one 18 kW power generator fuelled with biodiesel; two 180-L reactors for the transesterification; two settler containers for the product separation; an evaporation column for the unreacted alcohol removal; a heat exchanger operating in counter-current mode; a water washing column and an evaporation column under vacuum pump for the final biodiesel purification (Oliveira et al. 2010). For example, the possibility of building a small plant in rural and underdeveloped areas has been studied for the village Mango’o in Cameroon, where biodiesel could be produced from palm oil, available in large quantities, to meet the energy needs of the local population, reduce dependence on fossil fuels and prevent further depletion and depopulation. This plant consists of a batch reactor producing 180 L of biodiesel per batch for a maximum of four batches daily, reaching 150,000 L of biodiesel produced locally yearly. Preliminarily, oil is de-acidified by acid-catalysed esterification. Then, the pre-treated oil is transesterified with sodium methoxide at 55 °C for 1 h. Finally, biodiesel is separated from glycerine by sedimentation, washed with water and dried by atmosphere exposure for 12 h. However, the integration of biofuel technologies in rural areas should be studied further to determine the correlation between sustainability and scale of production and estimate their potential (Sarantopoulos et al. 2009). A similar small-scale plant (10 L/h) was investigated in Morocco to transesterify local WCO at a relatively high acidity content with methanol (molar ratio 6:1) and 1.2 wt% KOH at 65 °C (Ouanji et al. 2017). Similarly, the possibility of building a small plant can be a trump card in decentralised areas, as in the island of Crete, where the production of 10 thousand tonnes of biodiesel per year from local biomass was feasible and economically competitive (Skarlis et al. 2012). Small plants become a promising strategy even where the disposal of waste oils is not regulated at the government level, as is the case with the tourist island of Langkawi in Malaysia. A technical feasibility study has shown that in that region, it is possible to convert about 78.5% of the waste oils from the catering sector, otherwise destined for improper disposal with severe environmental damage, into biodiesel (Kumaran et al. 2011). Another delicate situation is when national or international conflicts and political instability make the supply of fossil energy resources difficult. One of the cases studied is related to the long civil war in Yemen, which began in 2015 and led to a severe humanitarian crisis and the total lack of diesel in many large cities, resulting in interruptions of all activities and utilities. In small and medium-scale plants, producing 600 and 2000 L per day of biodiesel from waste oils, respectively, was technically and economically feasible. However, profit margins are lower on a smaller scale. In a medium-scale plant (2000 L/day), 100 L of WCO should be transferred to a 150 L tank at each iteration, where a 9 kW heater should heat the oil to 70 °C; sodium methoxide should be prepared by dissolving NaOH in methanol in a 20 L tank and, then, poured into the oil tank under stirring for about 5 min. The reaction mixture should be filtered and stored in a 3000 L tank. After glycerol separation, biodiesel should be washed with high-pressure purified water and heated to evaporate residual water. In a smaller-scale plant (500–600 L/day), oil should react in a 15 L tank with methoxide, previously prepared into a 5 L container, and the biodiesel produced should be filtered, stored in a 1000 L tank and washed in a 200 L washing tank. Many processes can be done manually, and the labour employment rate is higher but with reduced capital costs. After a techno-economic analysis, the small-scale process is feasible, only lowering the purchase price of waste oils to 0.07 US$/litre or increasing the selling price of biodiesel to 0.7 US$/litre (Al-attab et al. 2017).

The production of biodiesel for small communities from waste oils generated in campus dining facilities has gained a particular interest in literature. Waste oils from the dining facilities on Auburn’s main campus were processed in a 208 L batch plant with methanol and NaOH at 57 °C. After oil was collected in 114-L drums and settled in proper containers for about two weeks to remove water and particulates, it was transesterified, dry washed with AMBERLITE™ BD10 and stored for future use (Mullenix 2011). Different research works also investigated biodiesel from frying oil from campus dining halls at the University of Cincinnati. Agnew et al. investigated the production of 54–64 L/week of biodiesel via alkaline transesterification at 60 °C in a 250-L reactor with NaOH and methanol-to-oil ratio of 5:1, successive separation from glycerol by settling, repeated washing with 1:1 water in two 114-L tanks to remove the catalyst, unreacted methanol and residual glycerol, and filtration into clean, dry containers (Agnew et al. 2009). Tu et al. assessed the technical, economic and environmental aspects of converting 3682 L/year of WCO from the University of Cincinnati campus dining facilities to 3712 L/year of biodiesel. The process involves the following phases: preheating oil in the main 189-L batch reaction tank, mixing NaOH (3.5 g/L) and methanol (alcohol-to-oil molar ratio of 6:1) in the mixing tank, adding the methoxide into the reactor, keeping the reaction going for 2.5 h, recovering the unreacted methanol by distillation, separating biodiesel and glycerol by 24-h decantation and water washing of biodiesel. The biodiesel produced can potentially replace the 19% of the diesel consumed by the university fleet, with a payback period of 16 months, lower capital and operational costs for on-site WCO conversion, and reduced GHG emissions of 9.37 tonnes CO2-eq/yr (Tu et al. 2015).

An important step is the definition of the logistics in the collection of waste oils, which requires interaction with individual subjects in the units belonging to the smart grid so that the oils are taken and supplied to the plants that will transform them before analysis and pretreatment, in biodiesel applicable to the nanogrid as energy supply. Awareness of biodiesel as a fuel is crucial and must rely on its biodegradability, low environmental impact, and increased safety for human health.

Conclusion and future trends

The introduction of alternative fuels is dictated by a strictly energetic aspect of the depletion of fossil resources and other non-negligible geographical, social, and political factors. For example, in the case of the Mediterranean basin, there is a significant imbalance in the allocation of natural resources on the three sides—northern, southern, and eastern—but this situation can be extended to the global level, with consequent energy dependence between different countries. In this context, domestic production of biofuels could help certain countries to increase the security of their energy systems by exploiting locally available resources, potentially reducing the impact of energy price volatility linked to international geopolitical instabilities and combining sustainability with the principles of security and equity. The introduction of biofuels could have a positive effect on the circular economy. For example, from a socio-economic point of view, it could stimulate growth and employment, particularly in rural, decentralised, or developing areas. As a renewable energy source, biodiesel offers a promising solution to climate change and the environmental impact of fossil fuels. Its potential to significantly reduce GHG emissions addresses the current crisis and instils hope for a greener, more sustainable future. In Mediterranean Europe, France has the highest level of consumption of biodiesel and biogasoline, at a constant level of about 2500 ktep/y for biodiesel and with a growing trend for biogasoline, from 430 ktep/y in 2015 to about 650 ktep/y in 2019. Spain almost doubled its biodiesel consumption in the same period, reaching just under 1400 ktep/y in 2019, while it reduced its biogasoline consumption to 130 ktoe/y in 2019. Italy has a reasonably constant consumption of biodiesel (about 1100–1200 ktep/y) and a relatively low consumption of biogasoline, about 30 ktep/y (Bastioli et al. 2023).

Several scientific communities have widely studied biodiesel production in recent decades, and several industrial realities are operating in this field. However, efforts are still being made to make biodiesel economically competitive with fossil diesel. Homogeneous alkaline transesterification of waste cooking oils seems the most feasible path for biodiesel production, whose profitability is very sensitive to the price of the feedstock. Scientific evidence shows that the reaction aspect has been quite studied and optimised for biodiesel production, so little can be done to improve this process stage. However, the transition from the currently used homogeneous catalysis at the industrial level to heterogeneous catalysis would lead to easier recovery and possible reuse of the catalyst, which is why this aspect deserves proper attention as a future development. Nevertheless, currently, the heterogeneous process is infeasible, and the oil price should be reduced by 27.5% to gain profit (Al-Sakkari et al. 2020). In addition, a further challenge to overcome is the development of more efficient pre-treatments and post-treatments to lower the cost of biodiesel production further and make it even more competitive with fossil diesel from an economic point of view. The main problem to consider is the processing cost of raw material, including production, transport, storage and pre-treatments. Indeed, the quality of oils affects the quality of biodiesel, the post-treatments and the total cost of the process. Proper WCO collection, aimed at improving the quality of the stored oil, is a first attempt to reduce the problem. In addition, suitable storage systems must be identified for waste oils as raw materials and biodiesel as a final product to avoid the deterioration of their properties as much as possible. Finally, the enhancement of glycerol, which has an entirely different market than biodiesel and would be produced in large quantities together with esters in the trans-esterification reaction, requires adequate attention in the future.

Despite this, the innovative element addressed in this article is the context in which biodiesel production fits. Biodiesel production can be aimed at developing distributed storage systems of different technologies, even in hybrid configurations, for the efficient and integrated management of energy carriers within a smart grid. Indeed, a sustainable future requires energy source diversification, without the predominance of one source over the others but with a proper energy integration based on locally available resources and needs. The trinomial production-demand-distribution networks used within a hybrid system, according to the concept of nanogrid, can be optimised and made smart by creating an interface to integrate generation systems from renewable sources, micro-cogeneration, storage, and generation from fossil sources. This is possible by making production operations continuous and automated, from the storage of reagent oil to the storage of the biodiesel product. In this way, biodiesel can be placed in the context of smart grids as a sustainable energy source for energy communities, serving as an eco-sustainable source for energy storage. A multi-objective optimisation of a renewable multi-source integrated energy system for combined heat and power applications suggested the integration of a 12.6 kWel biodiesel-fuelled Organic Rankine Cycle with a 10 kWel wind turbine and a 6.3 kWel photovoltaic unit. It significantly improves the global system efficiency (+ 7.5%), self-consumption (+ 15.0%), and electricity surplus injected into the grid (from 8.8 to 30.8% of the yearly electric demand) compared to the sole Organic Rankine Cycle apparatus for a residential smart electric grid (Algieri et al. 2020a).

The following challenges to face are the development of technological solutions and the optimisation of methodologies, algorithms, and conversion processes to implement a renewable community that reaches energy self-sustainability by exploiting waste products of the community itself, encouraging innovative waste recycling processes, and promoting the integration of networks. The research foresees future development of the design, implementation, and management of a real community whose citizens are directly involved and act as protagonists at all stages. This can be done practically by building a truly operational small-scale waste oil biodiesel plant connected to a nanogrid and manageable by the small community it is destined for. All this would create a localised industrial network integrated with the national and international ones and create new local production chains. Long time and coordination difficulties for the prototype development of the different modules of the system are critical issues that characterise most integrated systems and are closely linked to the characteristics of smart technological solutions in the residential area that require, in some cases, a strong interrelationship and integration between different competencies. Moreover, quantifying production costs is complex because technologies are immature and subject to continuous investments to improve their technical and functional performances. In addition, the local and international regulatory environment focuses mainly on the incentive of individual solutions, neglecting the aggregation of more technologies and users, especially in the residential area. Therefore, energy management and distribution recently appeared on the national and international scene and are subject to continuous evolution linked to changes in the regulatory framework in the energy sector. Finally, consumers resist innovative technologies because it is difficult to perceive the added value of enabling technologies that fit into innovative production models.