Introduction

The growing global concern about water quality is a fact. Rapid population growth, constant urbanization, poor quality of fresh water and, in turn, its expensive treatment are just some of the issues that worry environmental and governmental organizations, as well as population in general, both in the short and long term. Industries such as distilleries, oil mills, textiles, food and chemical processing, soft drinks, paper and metallurgical are known to produce a large amount of wastewater difficult to treat before its final disposal and/or reuse. In South America, wastewater contaminated with different types of pollutants are becoming an environmental threat as a result of the rapid growth of several industries in the food sector, including coffee brewing. Instant coffee is one of the most widely consumed drinks worldwide. Its global market reached a value of ca. USD 13.2 billion in 2023. Looking ahead, the instant coffee market is expected to grow at a rate of ca. 5% during 2024–2032 to reach USD 20.3 billion in 2032 [1]. The term instant coffee, also known as coffee powder, refers to the granules obtained after removing water from the coffee extract. Its industrial production begins with the roasting of green coffee beans that allows the formation of sugars and the characteristic dark brown color of coffee. Then, the roasted bean is ground and a concentrated solution of volatile components and soluble solids is extracted, with the characteristic aroma and flavor of coffee. Finally, instant coffee is obtained through a drying process (generally by spray-drying or freeze-drying) [2].

Any industrial scheme used to produce instant coffee generates wastewater with dark brown color and high organic load that presents a considerable level of contamination [3]. Its composition includes a mixture of complex substances such as polysaccharides, proteins, melanoidins, tannins (in low concentrations), alkaloids (as caffeine or trigonelline), and chlorogenic acids. These wastewaters, when discharged into the environment without adequate treatment, delay the natural degradation process of the organic matter that composes them [4]. Consequently, its discoloration and mineralization become a priority for the protection of water resources.

Different methods have been evaluated for the treatment of wastewater from the instant coffee industry. Primary methods (such as chemical coagulation, CC) do not allow the degradation of the organic load present in these wastewaters. On the other hand, some secondary treatments have shown some effectiveness, mainly UASB reactors with mesophilic or thermophilic microorganisms [5,6,7]. However, the presence of inhibitory components limits their applicability. Furthermore, their operation can be unstable due to slight disturbances in the process variables and usually require long residence times [8]. Diverse alternative treatments were also proposed in the open literature, mostly based on photochemical technologies such as: UV/H2O2 and UV/O3 [9]; Fenton assisted by UV [10], and Photo-Fenton using sunlight [11]. They reported high color reduction, moderate Chemical Oxygen Demand (COD) degradation, and low operation time when compared to biological processes. It should be noted that these processes required the application of CC as a first step of the treatment. However, electrocoagulation (EC) could be a more efficient and economical alternative than CC. In fact, EC enhances the chemical coagulation process and integrates other phenomena that can effectively decrease the presence of various contaminants (from heavy metals to persistent organic pollutants, while reducing the generation of solid waste) [12]. EC allows to remove suspended matter of sub-micron size, break emulsions such as oils and fats, oxidize and eliminate heavy metals without the external addition of chemical substances. In fact, according to the UN Sustainable Development Goals, EC has the potential to play an essential role in the development of the sustainable industrial wastewater treatment strategy, specifically within the framework of goals number 6 (Clean water and sanitation), number 7 (Clean and affordable energy), number 9 (Industry, innovation and infrastructure) and 13 (Climate action) [13].

EC uses a current to dissolve Fe, Al or other metals (M, sacrificial anode submerged in contaminated water) to generate in situ an active coagulant (e.g., \({\text{M}}_{(\text{aq})}^{\text{n}+}\): Fe2+, Al3+, Eq. (1)) [14].

$$\text{M}\to {\text{M}}_{(\text{aq})}^{\text{n}+}+{\text{ne}}^{-}$$
(1)

When EC is applied, Faraday’s law is followed: e.g., the concentration of electrodissolved metal in the treated solution (v.g., the coagulant dose) increases linearly with the amount of electrical charge passed.

\({\text{M}}_{(\text{aq})}^{\text{n}+}\) species act as coagulant or destabilization agents, helping to separate contaminants from wastewaters. In parallel, water molecules are split by electrolysis producing small bubbles of oxygen at the anode (Eq. 2) and hydrogen at the cathode (Eq. 3) with a speed velocity proportional to the electric current in the cell. These bubbles allow a certain portion of fresh flocs to float to the surface of the solution (forming the buoyant material).

$$2{\text{H}}_{2}\text{O}\to 4{\text{H}}_{(\text{aq})}^{+}+{\text{O}}_{2(\text{g})}+4{\text{e}}^{-}$$
(2)
$${\text{nH}}_{2}\text{O}+{\text{ne}}^{-}\to {\text{nOH}}_{(\text{aq})}^{-}+\frac{\text{n}}{2}{\text{H}}_{2(\text{g})}$$
(3)

The significant production of \({\text{OH}}^{-}\) from reaction (3) causes an increase in pH during electrolysis leading to the formation of different metal hydroxocomplexes in solution. \({\text{M}}^{\text{n}+}\) ions and \({\text{OH}}^{-}\) ions react to form charged polymeric complexes or amorphous hydroxides with a large surface area. They are considered responsible for the destabilization and/or removal of colloidal substances. The formation of these species depends on the pH of the solution, the concentration of metal ions, the \({{\text{OH}}^{-}/\text{M}}^{\text{n}+}\) ratio, and the type of ions in solution [15].

Other side reactions may occur during the EC process. For example, if the treated solution has a high concentration of chloride ions and the electrical potential of the cell is high, active chlorine can be generated under neutral or acidic conditions according to the following reaction scheme [16]:

$${2\text{Cl}}_{(\text{aq})}^{-}\to {\text{Cl}}_{2(\text{g})}+2{\text{e}}^{-}$$
(4)
$${{\text{Cl}}_{2(\text{g})}+\text{H}}_{2}\text{O}\to {\text{HClO}}_{(\text{aq})}+{\text{H}}_{(\text{aq})}^{+}+{\text{Cl}}_{(\text{aq})}^{-}$$
(5)
$${\text{HClO}}_{(\text{aq})}\to {\text{H}}_{(\text{aq})}^{+}+{\text{OCl}}_{(\text{aq})}^{-}$$
(6)

The formation of active chlorine can improve the performance of the EC process because it can oxidize a certain proportion of the organic substances present in the wastewater. However, the production of active chlorine in wastewater with high concentrations of humic or fulvic acids can lead to the formation of trihalomethanes. These compounds represent a high toxicity for the effluent and are generally more recalcitrant than the initial molecules from which they come [17].

Considering its characteristics, the EC process presents several advantages over the conventional CC treatment approach, including: (i) more effective separation of organic matter, (ii) high-purity electrogenerated coagulant that improves contaminant removal, (iii) a lower amount of chemicals used, (iv) a lower amount of sludge produced, (v) lower operating costs. On the other hand, the main drawbacks that must be faced during an EC process lie in: (i) the passivation of the anode, (ii) the deposition of sludge on the electrodes, (iii) the residual presence of metal ions (e.g., Fe or Al) in the treated effluent that hinders its direct discharge into the environment, (iv) electrical energy requirement, (v) the need to periodically replace sacrificial anodes.

EC performance can be optimized and drawbacks overcome through proper control of different operating variables. In fact, among others, the performance of the EC depends on the following factors or parameters [18,19,20]:

Current density (J)

It is a fundamental variable for the efficiency of the EC and is the only operating parameter that can be directly controlled. This variable expresses the relationship between the applied electric current (I) and the total area of ​​the anode (A) (J=I/A). Its value defines the amount of metal ions that are delivered from the anode to the solution (according to Faraday's law) and the rate of production of gas bubbles (which improves the mixing inside the cell and allows turbulent zones to be obtained near the electrodes to increase mass transfer). J controls the electrochemical reactions that take place in solution, as well as their extent and kinetics. When high values of current density ​​are used, contaminants preferentially float and settle on the surface of the treated wastewater. A low current density prioritizes the aggregation of substances and their subsequent sedimentation, converting the EC cell mainly into an electrochemical dosing reactor. Excessive current density ​​can cause a waste of energy, cell heating, promote undesirable secondary reactions, and excess coagulant can recharge the surface of the colloids with their consequent restabilization. The current density is strongly linked to the operating costs of the EC process. In fact, finding high efficiencies in contaminant removal while minimizing operational costs is one of the challenges of this type of treatment. In general, direct current (DC) is most widely used in CE applications. However, the anodic surface can be isolated by the formation of stable oxide layers that promote corrosion phenomena and generate passivation effects. The use of alternating current (AC) can become an alternative since continuous polarity changes can avoid and/or reduce the formation of passivation layers and increase the operational life of sacrificial anodes.

pH

It determines the type of hydrolyzed species that are formed after dosing the metal ions and the solubility of the reaction products. pH also affects solution conductivity, zeta potential, and chemical dissolution of the electrodes. Therefore, EC removal mechanisms and their efficiency are strongly influenced by the pH of the treated effluent. The pH value varies in the course of the EC process depending on the generation rate of \({\text{H}}^{+}\) and \({\text{OH}}^{-}\) ions (Eqs. (2) and (3), respectively). It can increase when the initial pH is in the range of 4 to 9, while it can decrease when the initial pH is basic (pH > 9). The decrease in pH can also be caused by the formation of hydroxide precipitates that consume \({\text{OH}}^{-}\) ions from the solution. Although the pH value is a key parameter for the formation of coagulant species and solubility regions as mentioned above, a clear relationship between the pH changes of the treated solution and the EC efficiency has not been established. Another notable effect is related to changes in the chemical structure of contaminants due to pH (e.g., protonation/deprotonation of functional groups of contaminants directly affects the net charges of contaminants and their electrostatic interactions). Therefore, the pH must be optimized according to the nature of the target contaminant and the conditions of the effluent.

Solution conductivity

It is an important factor affecting the efficiency and energy consumption of the EC cell. For high conductivity values, electrical energy consumption is low when galvanostatic conditions are used, since the increase in the conductivity of the treated effluent reduces the ohmic overpotential. Conductivity can be improved by adding a supporting electrolyte that prevents migration effects, reduces the ohmic drop and the energy consumption. Supporting electrolytes include NaCl, KCl, Na2SO4, CaSO4, NH4Cl, (NH4)2SO4, NaHCO, FeSO4. Although the list of supporting electrolytes used is extensive, probably the most commonly used salt in EC is sodium chloride, mainly because it is a natural component in water and due to its relatively low cost. Furthermore, chloride ions, due to their high corrosive power, can degrade the surface layers of the anode that tend to passivate. This ensures unlimited release of cations from the anode even when the cell operates at low electrical potentials or low current densities. It is recommended that at least 20% of the anions present in wastewater be chlorides to avoid the passivation process. Additionally, high concentrations of chloride ions can lead to the generation of active chlorine species, as previously shown in Equations (4) to (5), which allow the oxidation of organic compounds.

Electrode material

The electrode material determines the set of reactions that will take place in the EC cell. Classically, Fe and Al are used as electrodes due to the coagulant properties of multivalent ions, but also their wide availability and relatively low cost. Considering the electrodissolved species, it is considered that Al3+ has a greater capacity to neutralize charges and generate hydrolyzed complexes. However, an electrolyte with greater coagulation power is produced when the Fe2+ ion change to Fe3+ due in principle to its size (10-30 µm for Fe3+ compared to 0.05-1 µm for Al3+) and its high capacity for formation of insoluble hydroxides. Another aspect to take into account is that iron electrodes can add a pale color to treated water over time, due to the combination of Fe3+ with hydroxyl group to form Fe(OH)3. That is one of the reasons why water purification is carried out preferentially with aluminum electrodes.

Stirring velocity

When agitated tanks are used as EC cells, mechanical agitation promotes the transfer of coagulating agents to the solution and prevents the formation of concentration gradients in the vicinity of the electrodes. This agitation also leads to temperature homogenization. With optimal agitation, the mobility and collision of ions, metal complexes and contaminants increase allowing efficient formation of settleable aggregates. If mechanical agitation is performed excessively, the effectiveness of the EC may decrease because the shear stresses of the agitator may destroy the fresh flocs and redisperse the colloids in the solution. An adequate stirring speed velocity also reduces passivation of the external surfaces of the electrode. It even allows to remove oxygen or hydrogen bubbles trapped on the electrodes. The accumulation of these bubbles on the electrodes may represent a greater resistance to current flow and therefore an increase in the electrical energy expenditure.

Although EC has more than a century of important applications in water treatment, the science and engineering behind EC reactor design remains empirical and heuristic [14]. This means that there is no fully established methodology for contaminants removal, sedimentation/flotation rate, reactor design (interelectrode gap, electrode arrangement, etc.), process scale-up, and economic optimization. A few studies have reported on the high efficiency of EC for the treatment of wastewater originated from both coffee processing and pulping ([21,22,23,24,25,26] Table 1) and instant coffee production ([27, 28], (Table 1). However, only a few authors have used the Response Surface Methodology and/or design of experiments to determine optimal operating conditions [21, 27]. This methodology allows identifying the relationship between independent variables (controllable factors) and the dependent variables of the system (the responses), as well as determining the conjugate/combined effect that can occur between the factors. Thus, by fitting the experimental data to polynomial models it is possible to optimize the performance of the process. Furthermore, to the best of our knowledge, only one report informed on the operational costs involved in EC treatment of this type of effluent [28]). However, in this case the authors considered only the costs of energy consumption and electrode material and ignored both the costs of reagents (e.g., for acidification) and the costs of transportation, treatment and disposal of the sludge. Finally, and no less important from the point of view of environmental sustainability, none of the cited works (Table 1) reported on the toxicity of both raw wastewater and effluents treated by the EC. Effective methodologies to determine the operating conditions that generate the greatest EC efficiency combine experimental design, statistical modeling, and the Response Surface Methodology [21,22,23]. Thus, in the scope of this study, In this work, the EC process was examined as an alternative, in environmental and economic terms, for the treatment of a toxic and non-biodegradable effluent originated from an industrial instant coffee plant an instant coffee industrial plant, located in the coffee region of Colombia. The goal of this treatment was to produce a cleaner effluent that can be disposed of without harming the environment. To reduce treatment costs (v.g., energy and operation costs), the EC process was analyzed using low-cost and easily-available electrodes. The effects of main operating parameters on Color removal, total operating costs, and COD and TOC degradation were studied using experimental design and analysis of variance (ANOVA). They were optimized using the response surface methodology and constrained optimization algorithms. The fate of pollutants was studied by molecular weight distribution analysis and acute toxicity tests. Thus, in general, we sought to comply with discharge standards by applying EC method under optimal conditions.

Table 1 Summary of some relevant works reported in the open literature on the treatment of wastewater originated from coffee processing and pulping as well as the production of instant coffee using EC process

Materials and methods

Wastewater samples

The effluent samples were taken manually directly from the wastewater stream of an instant coffee freeze-drying plant, located in the coffee region of Colombia (South America). To determine its physicochemical characteristics, bimonthly sampling was carried out for 18 months. The protocols for sampling, conservation, handling and characterization of wastewater samples considered the guidelines of the International Organization for Standardization [29], the Colombian Institute of Hydrology, Meteorology and Environmental Studies [30, 31] and Standard Methods [32].

Analytical methods

To determine the physicochemical representative characteristics of the raw and treated wastewater under study and thus establish the contaminant removal efficiency achieved during the EC process, 10 physicochemical and biological parameters were selected to be monitored (Table 2). This is in accordance with the provisions of Resolution 0631 of 2015 of the current Colombian environmental legislation in force for the discharge of effluents originating from the production of instant coffee production [33]. The raw and post-treatment treated samples were analyzed, in triplicate, using following the respective procedures of the Standard Methods resumed in (Table 2).

Table 2 Summary of average physicochemical characteristics of raw effluent, along with the permissible discharge according to current Colombian legislation for instant coffee production [33]. Also included is the efficiency of Chemical Coagulation (for comparison) and Electrocoagulation treatments (under optimized operation conditions)

All reagents were used as received from suppliers (CoCl2.6H2O, 99 wt.%, Merck; K2PtCl6, 99 wt.%, Sigma-Aldrich; C8H5KO4, 99 wt.%, Merck; NaCl, 99 wt.%, Merck). When necessary, ultrapure water (Milli-Q system, Billerica, Massachusetts; conductivity = 1 μS/cm) was used to prepare their aqueous solutions. After each EC test, a 2 ml sample was taken and centrifuged at 2000 rpm for 10 min before analysis.

Sludge generation and electrode consumption were measured as a function of electrolysis time. The amount of sludge formed during the treatment was determined by filtering the treated effluent (using a medium retention paper (11 µm) grade 1 (Whatman®) and a pressure of 750 mbar). The filtered solid was dried to constant weight. Electrode consumption was then determined by the difference in weight before and after each EC test.

To analyze the molecular weight distribution (MWD) of the wastewater and supernatant from the EC process, membrane ultrafiltration was performed. A stirred cell (Amicon, Model 8400) was used with cellulose ultrafiltration membranes (EMD Millipore, Nominal Molecular Weight Limits (NMWL) of 30, 10, 5 and 1 kDa). Membranes were washed for 30 min with 0.1 M NaOH and deionized water before each use. The pressure of the ultrafiltration process was 0.2 MPa, provided by a constant supply of high purity N2 (99.999 vol. %, Praxair). Finally, TOC was analyzed for each molecular weight fraction.

To obtain information on the possible fate of the treated effluent, Molecular Weight Distribution (MWD) and acute toxicity analyzes were carried out. For comparison, raw wastewater was also examined. MWD analysis was performed by membrane ultrafiltration and evaluated in terms of TOC concentration. A stirred cell (Amicon, Model 8400, Merck KGaA, Darmstadt, Germany), containing cellulose ultrafiltration membranes (44.5 mm diameter discs, Millipore® Ultracell, Merck KGaA, Darmstadt, Germany) with Nominal Molecular Weight Limits (NMWL) of 30, 10, 5 and 1 kDa, was used. The pressure required for the ultrafiltration process (0.2 MPa) was provided by the constant supply of high purity N2 (99.999 vol.%, Praxair). Before each test, the membranes were washed with NaOH (0.1 M) for 30 min and then extensively rinsed with deionized water, according to manufacturer's instructions. The test consisted of performing multiple successive filtrations, each time using a smaller pore size membrane, in order to determine the size distribution of the molecules that generate the organic load as well as other measurable properties. The TOC concentration of the permeates of each molecular weight fraction was quantified. The difference between the TOC concentration measured before (retentate) and after (permeate) passing through the membrane allowed the preparation of a histogram of the distribution of molecular weights in fractions of the analyzed sample.

Acute toxicity tests of wastewater and EC effluent were performed with Artemia salina (Carolina Biological Supply Company).

Acute toxicity tests of raw and treated wastewater were performed using the crustacean Artemia salina (supplied by the Carolina Biological Supply Company, Burlington, NC, USA) according to the procedures of ISO 6341:2012 [34] and NTC-ISO 5667–16 [35]. The methodology proposed by Lieberman [36] and Maurer-Jones et al. [37], as well as the recommendations of Vanhaecke et al. [38] and the Carolina Biological Supply Company on procedures for sterilization and cleaning, were followed. The bioassay consisted of preparing an artificial medium (37 g/L of sea salt) for the cultivation of Artemia salina in a beaker (250 mL). About 40 mg of Artemia salina eggs were incubated there, which were and irradiated with a 6-W lamp (3500 lm light intensity) for 48 h. These conditions allowed the hatching of the eggs and the maturation of the nauplii. To determine the median lethal concentration (LC50) of an analyte (i.e., the concentration which causes the death in 50% of the population tested), 10 sterilized test tubes (16 mm diameter) were used. Between 8 and 12 nauplii (N0) were transferred to each using a Pasteur pipette. A volume of the same saline solution where the nauplii were originally developed was added to each tube until adjusted to 5 mL. Subsequently, a dilution of analyte and saline solution was added to each to obtain a specific concentration of analyte. A blank was included in the measurements to determine if there was any significant effect of external factors on the nauplii. 24 h later the number of dead individuals was reviewed (a nauplii was considered dead when no movement of its appendages was observed for more than 10 s). Finally, the lethality percentage of Artemia salina was determined as follows:

$$\text{Lethality }({\%})=\left(\frac{{\text{N}}_{0}-{\text{N}}_{\text{t}}}{{\text{N}}_{0}}\right)\text{x}\;100$$
(7)

The COD and TOC values were used to evaluate the Carbon Oxidation State (COS) of raw and EC treated samples. It takes a value between -4 (for the most reduced state of carbon, CH4) and + 4 (for the most oxidized state of carbon, CO2). COS was calculated as follows [39]:

$$\text{COS}=4-1.5\times \frac{{\text{C}}_{\text{COD }}(\text{mg }{\text{O}}_{2}/\text{L})}{{\text{C}}_{\text{TOC},0}(\text{mg C}/\text{L})}$$
(8)

Experimental set-up and procedure

An EC reactor, on a laboratory scale, jacketed batch undivided cell, made of borosilicate glass, with a working volume of 200 ml, magnetically stirred, with two vertical plate electrodes, was operated in monopolar mode with the electrodes connected to the terminals of a DC power supply (BK-Precision) that provides stabilized current from 0 to 20 A and voltage from 0 to 30 V (Fig. 1). Cell voltage and current were measured with a multimeter (FLUKE 76 True RMS). The electrodes materials were 4 cm height × 5 cm width (effective surface area of 20 cm2). All experiments were performed at 293 K. A PT-100 sensor (± 0.01 K) was placed on the top of the cell to measure the solution temperature. The temperature was kept constant, ± 0.05 K, using a thermostat water bath (F-12, Julabo—Germany), supplying water to the cell jacket with a rate of 10 dm3/min. The EC process started when the DC power supply was turned on.

Fig. 1
figure 1

Scheme of EC batch process

Different electrode materials were tested as anode (iron (content of pure iron > 99.5%), stainless-steel electrode (ss-316), and aluminum (1100 grade, content of pure aluminum > 99%)) and cathode (iron (content of pure iron > 99.5%), stainless-steel electrode (ss-316), and aluminum (1100 grade, content of pure aluminum > 99%), and graphite (12 grade)).

To clean the surface of the electrodes before each EC test, they were rubbed with sand paper and dipped in an HCl solution (35 v/v %) for approx. 5 min. Before each EC test, the surface of the electrodes was first cleaned using sandpaper and then immersed in HCl solution (35 v/v%) for approx. 5 min. Next, they were rinsed with distilled water. Subsequently, electrodes were dried in an oven (Thermo Scientific™) at 105 °C until constant weight. Before each experiment the weight of the electrodes (anode and cathode) was determined. Once the electrolysis was over, the quantification of the control variables of the treated effluent was carried out following the corresponding Standard Methods [27]. To determine the amount of sludge generated, the Standard Method 2540-D [27] was used. The EC process started when the DC power supply was turned on. The cell voltage and current were monitored every five minutes with a multimeter (FLUKE 76 True RMS) to determine the power consumption during the treatment process. Once the defined electrolysis time had finished, the cell content was filtered using a medium retention glass fiber filter (11 µm, grade 1, Whatman®). The solids generated were dried at 103–105 °C until their constant weight was obtained (Standard Method 2540-D [32]). Finally, the supernatant obtained was analyzed using the corresponding Standard Methods [32] (Table 2).

Economic evaluation of the treatment process

The Total Operating Cost (\(\text{TOpC}\)) was calculated, in terms of US dollars per cubic meter of treated effluent, as follows:

$$\text{TOpC}\left[\frac{\text{USD}}{{\text{m}}^{3}}\right]={{\$}}_{\text{Electricity}}\;{\times\;\text{E}}_{\text{Electricity}}+{{\$}}_{\text{Electrode}}\times {\text{G}}_{\text{Electrode}}+{{\$}}_{\text{Sludge}}\times {\text{G}}_{\text{Sludge}}+\frac{{{\$}}_{\text{Electrolyte}}\times {\text{C}}_{\text{Electrolyte}}}{0.99}$$
(9)

where: \({{\$}}_{\text{Electricity}}, {{\$}}_{\text{Electrode}},{{\$}}_{\text{Sludge}}\text{ and }{{\$}}_{\text{Electrolyte}}\) are the current market prices of electricity (0.17 USD/kWh), electrode material (iron: 0.705 USD/kg; stainless steel: 1.343 USD/kg; aluminium: 1.195 USD/kg), transportation, treatment and disposal of sludge (0.0420 USD/kg) and supporting electrolyte (NaCl 99% purity, 0.073 USD/kg), respectively;\({\text{G}}_{\text{Electrode}}\): electrode material consumption = kg of electrode/m3 of treated effluent; \({\text{G}}_{\text{Sludge}}\): amount of sludge formed during treatment = kg of sludge/m3 of treated effluent; \({\text{C}}_{\text{Electrolyte}}\): the concentration of supporting electrolyte = kg of NaCl/m3; and \({\text{E}}_{\text{Electricity}}\): electrical energy consumption = kWh/m3 of treated effluent, which was evaluated as follows:

$${\text{E}}_{\text{Electricity}}=\frac{\text{U}\times \text{I}\times \text{t}}{\text{V}}$$
(10)

where \(\text{U}\) is the average voltage (in V), \(\text{I}\) is the current (in A), \(\text{t}\) is the EC operating time (in h) and \(\text{V}\) is the volume of solution (in L).

Experimental design and statistical data analysis

Response Surface Methodology (RSM) was used to optimize the operational conditions of the EC process. RSM involves of a set of mathematical and statistical techniques based on the adjustment of empirical models to the experimental data obtained according to the selected matrix. Its application as an optimization tool involved the following steps:

  1. (i)

    Choice of independent variables (factors, Xi) with important effects on the system studied and definition of their experimental range: Considering the information discussed in the introductory section, the following factors were chosen: current density (J, X1), supporting electrolyte concentration (\({\text{C}}_{\text{NaCl}}\), X2), and stirring velocity (SV, X3). According to the literature, the current density range used for EC processes is wide. Values of 10 to 2000 A/m2 have been reported. If long-term continuous, maintenance-free operation is desired, it is recommended to use densities between 20–25 A/m2, unless there is a regular program to clean the electrode surfaces. However, a high percentage of scientific publications mention values in the range of 10 to 150 A/m2 [40]. On the other hand, determining the appropriate concentration of NaCl for EC treatments has been the subject of several works [19, 20]. The interval evaluated in each case changed depending on the nature of the wastewater. Concentrations of up to 8 g/L have been proposed, with the aim of increasing the conductivity of the wastewater and reducing electrical energy consumption. However, an excessive amount of NaCl increases reagent costs and can lead to high chemical corrosion of the electrodes and cell structure. It also causes secondary pollution that can affect chloride-sensitive organisms in the final water body where the treated effluent will be disposed of [41]. Therefore, the NaCl concentration must be limited and optimized. Finally, different stirring velocity from 100 to 1000 RPM have been reported in the open literature to study EC wastewater treatment [42]. Szpyrkowicz [43] reported that high color removals and high sedimentation rates are achieved with a stirring velocity close to 500 rpm for EC wastewater treatment using iron electrodes. Therefore, based on these literature reports and preliminary trials (not presented here), the levels of chosen factors are summarized in Table 3.

    Table 3 Factors and their levels for the experimental design
  2. (ii)

    Selection of dependent variables (response variables, Yi): To evaluate the performance of the EC process, COD degradation percentage (%DCOD), Color removal percentage (%RColor), and \(\text{TOpC}\) were selected. From the experimental data, the %DCOD and %RColor were calculated as follows:

    $$\%{\text{D}}_{\text{COD}}=\frac{({\text{C}}_{\text{COD}}^{0}-{\text{C}}_{\text{COD}}^{\text{t}})}{{\text{C}}_{\text{COD}}^{0}}\times 100$$
    (11)
    $$\%{\text{R}}_{\text{Color}}=\frac{({\text{C}}_{\text{Color}}^{0}-{\text{C}}_{\text{Color}}^{\text{t}})}{{\text{C}}_{\text{Color}}^{0}}\times 100$$
    (12)

    where \({\text{C}}_{\text{COD}}\) and \({\text{C}}_{\text{Color}}\) represent the concentrations of COD (g/L) and Color (U. Pt–Co), respectively. The superscripts 0 and t correspond to the concentrations at the beginning or at the time t of the treatment. \(\text{TOpC}\), as a response variable, was calculated as detailed in "Economic evaluation of the treatment process" section.

  3. (iii)

    Selection of the experimental design and its experimental running: A Box–Behnken experimental Design (BBD) was selected. It is considered less expensive than the corresponding full-factorial experimental design. The number of experiments (N) necessary for the development of a BBD is defined as N = 2 k(k − 1) + CP (where k is number of factors and CP is the number of central points). Another characteristic of BBD is the lack of combinations at which all factors are simultaneously at their highest or at their lowest levels, which makes it possible to avoid conducting experiments under extreme conditions. This property can be useful if the researcher must avoid extreme combined factors. It also prevents possible data loss in these cases. Thus, 15 random experiments were carried out, each of which was replicated twice to avoid any systematic error. They were programmed using Statgraphics Centurion XVIII® (30-day trial version is available at http://www.statgraphics.net). The total electrolysis time was set at 40 min.

  4. (iv)

    Mathematical and statistical treatment of the obtained experimental data (fitting to a polynomial function): The following second-order polynomial function was used to evaluate the interaction between factors and optimize the operating conditions for each response variable (Yi).

    $${\mathrm{Y}}_{\mathrm{i}}={\upbeta}_{0}^{\mathrm{c}}+\sum_{\mathrm{i}}=1^{\mathrm{n}}{\upbeta}_{\mathrm{i}}^{\mathrm{c}}{\mathrm{X}}_{\mathrm{i}}+\sum_{\mathrm{i}}=1^{\mathrm{n}}{\upbeta}_{\mathrm{ii}}^{\mathrm{c}}{\mathrm{X}}_{\mathrm{i}}^{2}+\sum_{\mathrm{i}}=1^{\mathrm{n}}\sum_{\mathrm{j}}=1^{\mathrm{n}}{\upbeta}_{\mathrm{ij}}^{\mathrm{c}}{\mathrm{X}}_{\mathrm{i}}{\mathrm{X}}_{\mathrm{j}}$$
    (13)

    where n is the number of factors, Xi and Xj are the experimental factors, \({\upbeta }_{0}^{\text{c}}\) is the coefficient of the intercept, \({\upbeta }_{\text{i}}^{\text{c}}\) is the linear coefficient for the factor i, \({\upbeta }_{\text{ii}}^{\text{c}}\) is the quadratic coefficient for its corresponding factor i and \({\upbeta }_{\text{ij}}^{\text{c}}\) is the interaction coefficient between factor i and j. These coefficients were adjusted based on the results obtained in the experimental design.

  5. (v)

    Evaluation of the fitted model: Using the experimental data and the fitted models, analyzes of variance (ANOVA) were performed and Pareto diagrams were constructed. ANOVA involved classification and cross-classification of statistical results by (i) the Fisher’s F test was used to evaluate the existence of significant differences in the response variables and calculated standard errors; and (ii) P values were used to identify the significant influence of the factors on a particular response variable [44]. Additionally, Pareto analysis (graphically represented as a series of bars) was used to identify factors that have the greatest cumulative effect on the response variables. Thus, the effect of each factor (PEi), in percentage, was determined according to Eq. (14):

    $${\text{PE}}_{\text{i}}=\left(\frac{{\text{b}}_{\text{i}}^{2}}{\sum {\text{b}}_{\text{i}}^{2}}\right)\times 100$$
    (14)

    where bi represents the value of each i factor. Thus, statistically important factors correspond to all those values that exceed the t value in the student's t distribution, with 95% confidence and a specific number of freedom degrees. This is represented graphically as a vertical line on the Pareto diagram. Thus, from ANOVA and Pareto analysis, the statistically significant factors for each response variable were determined.

  6. (vi)

    Optimization analysis: Using the fitted polynomial models to calculate the %RColor and TOpC, a constrained optimization analysis was performed: e.g., minimization of TOpC and maximization of %RColor, linked to a COD reduction greater than or equal to 72.4% (to meet the discharge limits of Colombian environmental legislation). Mathematically, the optimization problem can be described as follows:

    $$\text{Minimize TOpC}\left({\text{X}}_\text{i}\right)$$
    $${\text{Maximize R}}_\text{Color}\left({\text{X}}_\text{i}\right)$$

    Subject to:

    $$\%{\text{D}}_\text{COD}({\text{X}}_\text{i})\geq72.4$$
    (15)

    The solution to this optimization problem was found using the Matlab® software (fmincon function).

  7. (vii)

    Model validation: Optimization results (e. g., EC experimental conditions) were verified experimentally, in triplicate, with independent EC runs.

Results and discussion

Industrial effluent characterization

Table 2 presents a summary of the main average physicochemical characteristics of the raw effluent from the production of instant coffee, along with the permissible discharge limits, established by Colombian legislation. Some parameters of the analyzed industrial wastewater present values above the permissible limit (v.g., pH, COD, BOD5). The high COD value infers the presence of excess organic matter (> 3.5 times higher than the discharge limit) with a low biodegradability index (BOD5/COD = 0.201). The COS value (-0.096) suggests that the wastewater is composed of reduced compounds. In addition, the wastewater had an intense dark brown color mainly due to the high load of organic compounds.

Chemical Coagulation treatment – a base line

Chemical coagulation (CC) is a primary process for industrial wastewater treatment. CC is effective to reduce color, total suspended solids, and organic content. Its efficiency and the quality of the treated effluents depend largely on the chemical nature of the contaminants, the type of coagulant, the coagulant dose and the pH [45]. An insufficient dose of coagulant or its overdose can cause poor performance of the CC and its high cost. On the other hand, the pH value influences the surface charge of the coagulants and the stabilization of the suspension. Furthermore, the solubility of the coagulant in aqueous solution is also influenced by the pH level. Following the standard method (ASTM D2035-19, the jar-test, [46]), FeSO4.7H2O was tested and optimized operating conditions were determined (not shown here). In a multi-target approach, the performance of the coagulant was improved by synergistic combination with slaked lime. It was concluded that the best CC performance was achieved with the pair FeSO4.7H2O + slaked lime (Ca(OH)2) at doses of 11.35 g/L + 6.15 g/L, respectively. A significant improvement in wastewater quality was observed, equivalent to 87% color, 60% of COD and 63% of TOC removals (Table 1). However, CC failed to reach the permissible COD discharge limits according to current Colombian legislation. The BDO5/COD biodegradability ratio increased from 0.201 to 0.257. However, it still has a low biodegradability index value and the CC supernatant cannot be considered biodegradable (< 0.40). Furthermore, it remains toxic (LC50 for Artemia salina of 649.1 mg/L).

Electrocoagulation treatment

Electrode material selection – preliminary tests

Electrode material selection is a key parameter for the EC process. To comparatively evaluate the selected electrode materials ("Experimental set-up and procedure" Sect.), a series of one-hour preliminary tests were carried out at the original wastewater pH (4.7), current density of 100 A/m2, supporting electrolyte (NaCl) concentration equals to 3.5 g/L, stirring velocity at 350 RPM and an electrode separation equals to 3 mm.

For the electrodes tested, EC proved to be effective in removing color from the treated solution (Fig. 2a). Under experimental conditions, EC reduced color by more than 85%. This shows that the monomeric and polymeric species of iron or aluminum have a strong affinity for the pigments and melanoidins present in instant coffee wastewater to finally be eliminated as precipitates. However, iron anodes showed the best performance for %DCOD (Fig. 2b). This was probably due to the fact that most of the dissolved iron was converted to the ferric form (Fe3+) whose coagulant power is greater than that of Al3+. Ferric ions stand out for being the precursors of hydrolyzed species that ultimately lead to the formation of insoluble compounds such as Fe(OH)3 or FeOOH with high contaminant adsorption capacity. The highest %DCOD was achieved with iron-iron or iron–graphite anode–cathode pairs. This shows that the influence of chemical corrosion on aluminum cathode has no significant effect when the anode is iron, probably because most of the unstable particles have already precipitated with the iron coagulating agents. According to the TOpC results, stainless steel anode is the least suitable (Fig. 2c). This is a consequence of the higher cost of this material and its low electrical conductivity, which causes high energy consumption in the cell. Although aluminum is a more expensive material than iron, EC cells with iron anodes had higher operating costs because a greater mass of material is consumed when iron is used. In contrast, the cathode material does not have a significant effect on costs when experimental deviations are considered, except in the cases of Al-Al and stainless steel-Al. This is the consequence of almost negligible wear of the iron and steel cathode during the entire process. However, cathodic corrosion is the main cause of the increase in the costs of the Al-Al pair.

Fig. 2
figure 2

The influence of electrode material on the EC performance on: a) %RColor, b) %DCOD, and c) TOpC

Therefore, considering both the high %DCOD and the low TOpC results, the anode–cathode pair selected for further analysis was iron-stainless steel. It is important to note that the wear of the stainless -steel cathode during electrolysis was negligible. Pitting corrosion was also not observed, possibly due to the presence of supporting electrolyte and sulfate ions in the treated effluent. As a criterion for its selection, the marked resistance of stainless steel to chemical corrosion was also decisive, which prevents its continuous cleaning or replacement.

Effect of EC operation parameters

Table 4 presents the results of the Box-Behnken experimental Design for the selected response variables. The trials were arranged in the table according to the increasing order of their factors, although they were carried out randomly. The highest %DCOD was achieved in test 12 and the highest %RColor in test 13. Both tests have in common the use of the highest current density. These reduction values correspond to low or intermediate NaCl concentrations and stirring velocities. The lowest costs were obtained with the lowest current density, the highest stirring velocity and at the average of NaCl concentration level; however, under these conditions the minimum color reduction value was obtained.

Table 4 The experimental results on %RColor, TOpC, and %DCOD according to the Box-Behnken experimental Design for the EC process

The following second order polynomial models were correlated for \(\%{\text{R}}_{\text{color}}\), \(\%{\text{D}}_{\text{COD}}\), and \(\text{TOpC}\):

$$\begin{aligned}\%{\text{R}}_{\text{color}}=\;&0.67805-7.5032\times {10}^{-5}\times \text{SV}+8.89198\times {10}^{-3}{\text{C}}_{\text{NaCl}}\\&+3.7068\times {10}^{-3}\times \text{J }+1.0408\times {10}^{-7}\times {\text{SV}}^{2}-7.9365\\&\times {10}^{-8}\times \text{SV}{\times \text{C}}_{\text{NaCl}}+2.5714\times {10}^{-8}\times \text{SV}\times \text{J }\\&+ 2.36497\times {10}^{-3}{{\times \text{C}}_{\text{NaCl}}}^{2}-5.69444\times {10}^{-5}{\times \text{C}}_{\text{NaCl}}\\&\times \text{J}-1.2895{\times 10}^{-5}\times {\text{J}}^{2}\end{aligned}$$
(16)
$$\begin{aligned}\%{\text{D}}_{\text{COD}}=\;&0.1703-2.11778\times {10}^{-4}\times \text{SV}+6.46965\times {10}^{-3}\times {\text{C}}_{\text{NaCl}}\\&+3.34678\times {10}^{-3}\times \text{J }+9.6081\times {10}^{-6}\times {\text{SV}}^{2}-1.5873\\&\times {10}^{-6}\times \text{SV}{\times \text{C}}_{\text{NaCl}}+1.1543\times {10}^{-6}\times \text{SV}\times \text{J }+ 1.36317\\&\times {10}^{-4}{{\times \text{C}}_{\text{NaCl}}}^{2}-1.8889\\&{\times 10}^{-5}{\times \text{C}}_{\text{NaCl}}\times \text{J}-5.1167{\times 10}^{-6}\times {\text{J}}^{2}\end{aligned}$$
(17)
$$\begin{aligned}\text{TOpC }\left(\frac{\text{USD}}{{\text{m}}^{3}}\right)=\;&-0.49775-2.1157\times {10}^{-3}\times \text{SV}+\;0.2131\;{\times\;\text{C}}_{\text{NaCl}}\\&+1.6831\times {10}^{-2}\times \text{J }+2.2702\times {10}^{-6}\times {\text{SV}}^{2}-1.0706\\&\times {10}^{-4}\times \text{SV}\;{\times \;\text{C}}_{\text{NaCl}}+1.2686\times {10}^{-6}\times \text{SV}\times \text{J }\\&+ 9.6204\times {10}^{-2}{{\;\times \;\text{C}}_{\text{NaCl}}}^{2}-4.0758\times {10}^{-3}{\times \text{C}}_{\text{NaCl}}\\&\times \text{J}-4.597{\times 10}^{-5}\times {\text{J}}^{2}\end{aligned}$$
(18)

The implemented models were evaluated using the Fisher test for analysis of variance (ANOVA, Table 5). In the ANOVA table, ​​F ratio values equivalent to 39.35, 40.99 and 21.27 can be observed for \(\%{\text{R}}_{\text{color}}\), \(\%{\text{D}}_{\text{COD}}\), and \(\text{TOpC}\), respectively. They indicate that most of the variations in the response can be explained by fitted equations [44]. Considering the coefficients of determination (R2 and R2adj) of the models, it was found that these are greater than 0.95, which indicates a high correlation between the observed and predicted values. In fact, a value of R2adj may be acceptable if it is greater than 0.80 [44]. On the other hand, it was found that all the proposed models are statistically significant with a high level of probability since their p-value is less than 0.01. From the p-value it can also be concluded that the model for the \(\%{\text{D}}_{\text{COD}}\) is the most statistically significant followed by the model corresponding to the \(\%{\text{R}}_{\text{color}}\) and finally that of \(\text{TOpC}\). Furthermore, p-values ​​greater than 0.01 were obtained for the lack of fit of all the proposed models, which implies that it is not significant and that the chosen models, with a second order polynomial form, was appropriate.

Table 5 ANOVA for the %RColor, %DCOD, and TOpC models for the EC process

To determine the effect of the factors on each response variable, their respective Pareto diagrams were constructed (Fig. 3). Note that the current density was statistically significant for the \(\%{\text{R}}_{\text{color}}\), \(\%{\text{D}}_{\text{COD}}\), and \(\text{TOpC}\) because their standardized effect is much larger than 4.3 (critical t value for 95% of confidence level.). On the other hand, the NaCl concentration, in the range studied, was only statistically significant for \(\text{TOpC}\). The relative importance percentages for each model parameter (estimated from Eq. (14)) were additionally included in the Pareto diagrams. Consequently, it is evident that the most important factor for EC performance was current density. This has a relative importance of 80.8%, 96.8%, and 78.3% on \(\%{\text{R}}_{\text{color}}\), \(\%{\text{D}}_{\text{COD}}\), and \(\text{TOpC}\), respectively. The predominance of this factor in EC performance is consistent with the direct relationship of current density with many important phenomena within the cell, such as anode dissolution rate, pH change, and even the rate of gas generation. This high dependence of EC with J has also been observed elsewhere for the treatment of other types of wastewater [19, 47]. On the contrary, the stirring velocity did not statistically affect any response variable in the range studied. This is possibly due to the high stability of the flocs formed and the extensive arrangement of coagulant agents that generated a large number of effective collisions for the formation of macro-flocs even at low agitation levels. Regarding operating costs, the support electrolyte concentration has an inverse effect (Fig. 3c). Its high concentrations favor charge transfer and therefore reduce resistance to current flow. However, this decrease, in the range studied, seems to have a slight effect on the overall energy consumption of the cell.

Fig. 3
figure 3

Pareto diagrams for: a) %RColor, b) %DCOD, and c) TOpC

To determine the synergistic effect of the evaluated factors on the response variables, three-dimensional response surface plots were prepared from Eqs. (16) to (17). Because these models depend on three factors, to build them, the value of the stirring speed velocity was kept constant at the central point of the experimental interval (525 RPM), considering that it is the variable with the least impact on the response variables. In Fig. 4, it can be seen that the highest current density results in the highest \(\%{\text{R}}_{\text{color}}\) and \(\%{\text{D}}_{\text{COD}}\), but also the highest \(\text{TOpC}\). If the current density is high, large anode dissolutions and high availability of ionic iron species are promoted to trap contaminants. It also generates a high bubble production rate that helps in phase separation. However, the anode and electrical power consumptions are higher. Once again, it is evident that the effect of NaCl concentration on \(\%{\text{R}}_{\text{color}}\) and \(\%{\text{D}}_{\text{COD}}\) is low (Fig. 4a and b). For example, at the highest current density tested, a decrease from 4 to 0.4 g/L of NaCl reduce only ca. 2% in \(\%{\text{R}}_{\text{color}}\) and \(\%{\text{D}}_{\text{COD}}\). On the other hand, it can be observed that the NaCl concentration has a high impact on TOpC, mainly when the current density is high (Fig. 4c). The TOpC increases with the decrease in NaCl concentration due to the increase in the ohmic resistance of the medium when there is a low availability of electrolytic substances. However, high concentrations of NaCl imply an increase in purchase costs and additionally produce greater chemical corrosion of the anode. Both aspects are only perceptible when current densities are low and are the reasons why the minimum operating cost is not located at the upper end of NaCl concentration.

Fig. 4
figure 4

Surface response plot for the interactive effect of J and NaCl concentration on a) %RColor, b) %DCOD, and c) TOpC. Stirring velocity = 525 RPM

Multiobjetive optimization

To determine the optimal EC operating conditions, the constrained dual minimization-maximization problem, Eq. (15), was solved. Thus, they correspond to: J = 150 A/m2, CNaCl = 1.78 g/L, and SV = 350 rpm which allow \(\%{\text{R}}_{\text{color}}\) = 93.5% and TOpC = 2.36 USD/m3. Furthermore, under these operating conditions, it was possible to achieve \(\%{\text{D}}_{\text{COD}}\) of 55%. The results of its experimental verification, carried out by triplicate, in independent runs of 60 min, showed: %RColor = 94.7 ± 0.9; %DCOD = 55.4 ± 2.3; and TOpC = 2.06 ± 0.2 USD/m3.

Kinetic analysis

Under the optimized EC operating conditions, a kinetic study was developed. Color, pH, COD and TOC were monitored during 180 min electrolysis (Figs. 5 to 7). According to Faraday's law, the dissolution of the anode is directly proportional to the electrolysis time. Thus, at the beginning of the EC, the concentration of iron species in the treated effluent is low and their oxidizing power is also low. The increase in electrolysis time favors the formation of iron species (Eq. (1)), as well as different products of reactions (2) and (3), which occur at the anode and cathode, respectively. Thus, regarding color variation over time, three zones were distinguished (Fig. 5). In the first zone (zone I) the color suddenly increased. This can be attributed to both the formation of iron species and their subsequent interactions with polyphenol and/or melanoidin molecules, present in raw wastewater, which can lead to the formation of dark-colored soluble complexes [10]. Similar behavior was observed during the wastewater treatment, of synthetic instant coffee solution, using the Fenton process [11]. In this same period of time (zone I, first 5 min of electrolysis) a constant increase in the pH of the treated solution was observed (Fig. 6). This may indicate that the cathodic reaction (3), which involves the formation of OH ions, predominates over the anodic reaction (2), which involves the formation of O2 and H+. Note that in zone I of the EC, sludge formation was not detected. In zone II, 5–15 min of electrolysis, the concentration of color decreased slowly with time. This probably due to the oxidation of the ferrous ion to ferric ion by the oxygen present in the reactive medium and formed at the anode (Eq. (19)). Note the increase in the pH value of the treated solution to a value of 7.15 for approx. 10 min of electrolysis (Fig. 6). In this period of time, no significant sludge production was also observed.

Fig. 5
figure 5

Color evolution during the EC process

Fig. 6
figure 6

pH evolution during the EC process

$$4{\text{Fe}}_{(\text{aq})}^{2+}+{2\text{H}}_{2}\text{O}+{\text{O}}_{2}\to 4{\text{Fe}}_{(\text{aq})}^{3+}+4{\text{OH}}^{-}$$
(19)

We believe that the degradation mechanism of the contaminants was initially favored by the formation of iron species in the solution rather than by the destabilization of the colloids. Furthermore, in the presence of oxygen in the reaction medium and at neutral or alkaline conditions, the ferrous ion can be oxidized to Fe3+ according to the Eq. (20). Note that a decrease in pH value was detected in the period of time between 15 and 20 min of electrolysis.

$$4{\text{Fe}}_{(\text{aq})}^{2+}+10{\text{H}}_{2}\text{O}+{\text{O}}_{2}\to 4\text{Fe}{(\text{OH})}_{3}+8{\text{H}}^{+}$$
(20)

From minute 15 of electrolysis onwards, the decolorization rate increased, so that more than 6000 U. Pt–Co were reduced in only 5 min (zone II), and the formation of the first insoluble hydroxides also began. In this zone the rate of discoloration is was initially rapid. The formation of first insoluble hydroxides, at the end of the first zone, was also noted. Then, a period of slow color reduction begins where the charges of some colloids are possibly neutralized and the first metallic hydroxides begin to form. In zone III, electrolysis time: 20–30 min, the decolorization rate decreased, reaching a constant value close to 180 U. Pt–Co. Note that after 30 min of electrolysis color changes were almost negligeable. Therefore, if the goal of the treatment process was only to decolorize the effluent, 30 min of electrolysis could be considered sufficient. Note that after 30 min of electrolysis, the color changes become minimal, reaching a constant value close to 180 U. Pt–Co. Likewise, from minute 20 of electrolysis, the pH of the treated effluent increased from 6.8 to the constant value of 9.2 after approx. 60 min. For Fe3+, the precipitation of Fe(OH)3 takes place for pH values > 1.0. This solid is in equilibrium with different monomeric species depending on the pH value: Fe3+ (a pH ≈ 2.0), Fe(OH)2+ (2 < pH < 3.8), Fe(OH)2+ (3.8 < pH < 6.2) y Fe(OH)4 (pH > 9.6). However, in the range 6.2 < pH < 9.6, Fe(OH)3 is the only species present in the solution. On the other hand, for Fe2+, the precipitation of Fe(OH)2 takes place at pH > 5.5 and it remains in equilibrium with Fe2+ up to pH = 9.5 or with other monomeric species, such as Fe(OH)+ in the range 9.5. < pH < 11.4 and as Fe(OH)3 in the pH range from 11.8 to 14.0. The formation of Fe(OH)2 favors the generation of flocs. However, it is the Fe3+ species that, due to a higher charge density, more efficiently reduce the electrical double layer and favor the coagulation-flocculation process. Thus, high availability of coagulation precursors and their consequent formation of flocs let to remove colloidal substances and some soluble organic compounds from the solution. Thus, at times greater than 30 min, and the removal capacity of flocs formed was not enough to reach total discoloration. are were ineffective in removing them from the solution. The color (159 U Pt–Co) of the treated effluent after 180 min of electrolysis is possibly due to the presence of residual iron species.

The evolution of COD and TOC concentrations over time defines two steps (Fig. 7). At first, during ca. 12 min, the COD reduction is slow (Fig. 7, zone I) probably due to the oxidation of Fe2+ to Fe3+. Note that the duration of COD reduction in zone I corresponds to the times (zone I + zone II) during decolorization. Keep in mind that the duration time of zone I, corresponding to the COD reduction, is equivalent to the times of zone I and zone II of the color variation. In the first EC zone, no sludge formation was also detected. Thus, the degradation mechanism of the contaminants can be promoted by iron species present in solution and not by the destabilization of colloids. At the beginning of the EC process, the iron species are in low concentration, according to Faraday's law, and their oxidizing power appears to be low. Therefore, the rate of the degradation process is also low. Already in zone II for the reduction of COD and TOC, the degradation rate is faster (exponential COD decay) as a result of the high concentration of coagulants. However, the process slows down after 120 min of electrolysis and, although most of the soluble organic substances and colloids were removed, even the flocs manage to trap a minimum number of suspended substances. Thus, it takes around 180 min to comply with current environmental legislation regarding COD concentration with a TOpC of ca. 6.26 USD/m3. Finally, note that just 60 min of electrolysis yielded significant removals of color (approx. 95%), COD (approx. 55%), and TOC (approx. 58%) with total operating cost of ca. 2.1 USD/m3. However, these efficiencies were not high enough to guarantee compliance with the requirements of current national environmental regulations.

Fig. 7
figure 7

Evolution of (a) COD and (b) TOC during the EC process Experimental (symbols) and fitted model (lines)

Different expressions of the kinetic power law were tested to fit both COD and TOC data. The parameters with the highest R2adj defined the following rate expressions for the EC processes (presented as lines in Fig. 6):

$$\frac{d\text{C}_\text{COD}^\text{Zone I }}{d\text{t}}=\left(0.002562\pm6.8\times10^{-4}\right)\text{C}_\text{COD}^2\;{\text{ R}^2}_{\mathrm{adj}}\text{ = 0.9439}$$
(21)
$$\frac{d\text{C}_\text{COD}^\text{Zone II}}{d\text{t}}=\left(0.002492\pm5.4\times10^{-4}\right)\text{C}_\text{COD}^{3.641\pm0.291}\;{\text{R}^2}_{\mathrm{adj}}\text{ = 0.9966}$$
(22)
$$\frac{d{\text{C}}_{\text{TOC}}^{\text{Zone I}}}{d\text{t}}=\left(0.00775 \pm 4.3\times {10}^{-4}\right){\text{C}}_{\text{COD}}^{2}\;{\text{R}^2}_{\mathrm{adj}}\text{ = 0.9993}$$
(23)
$$\frac{d{\text{C}}_{\text{TOC}}^{\text{Zone II}}}{d\text{t}}=\left(0.0453 \pm 82\times {10}^{-4}\right){\text{C}}_{\text{COD}}^{4.445\pm 0.82}\;{\text{R}^2}_{\mathrm{adj}}\text{ = 0.9924}$$
(24)

Characterization of the treated effluent

The effluent obtained after the EC treatment (carried out under optimal operating conditions for 60 and 180 min of electrolysis) was characterized in terms of the physicochemical parameters contemplated by current Colombian environmental legislation. The results are presented in Table 2. Compared to raw wastewater, 180 min of electrolysis reduced COD and TOC by more than 72% and 65%, respectively. This demonstrated that the EC process was effective in terms of organic matter removal. Note that the biodegradability index (IB = BOD5/COD) rises from 0.201 (raw sample) to 0.437 (EC effluent), representing a significant increase in the biodegradability of the effluent studied. At the end of EC process, COS reached the value of 2.87, indicating carbon oxidation and mineralization of the studied effluent. This characteristic usually improves wastewater biodegradability. It is noteworthy that the concentration of Cl ions (initial Cl- concentration of 0.142 g Cl/L + 1.08 g Cl/L corresponding to 1.78 g NaCl/L) decreased approx. 28% during the electrolysis process. This may indicate that during EC the formation of active chlorine species occurs which may contribute to the degradation of organic matter (Eqs. (46)). Moreover, in the presence of ferrous ions, the chloride ions can participate in the formation of Fe(OH)3, contributing to the removal of contaminants through precipitation and adsorption (Eqs. (25) and (26)) [48].

$${\text{Fe}}^{2+}+2{\text{Cl}}^{-}\to {\text{FeCl}}_{2}$$
(25)
$${\mathrm{FeCl}}_2+3\mathrm {OH}^-\to\mathrm{Fe}{\left(\mathrm{OH}\right)}_3+2\mathrm{Cl}^-$$
(26)

However, conductivity and Cl concentration increased in comparison with their respective values for the industrial effluent. This is due to the use of supporting electrolyte (NaCl).

The results of the MWD analysis for raw and treated effluents are compared in Fig. 8. For the raw wastewater, ca. 60% of the TOC concentration comprised high molecular weight compounds (> 5 kDa) due to the presence of macromolecules (e.g., melanoidins, proteins and lipids) in coffee grains. During the EC process, for 60 and 180 min, large molecules were mainly destabilized or adsorbed on the surface of the precipitated hydroxides. Therefore, molecules larger than 10 kDa are not present in EC supernatant treated for 180 min. Apparently, part of this group of molecules was not mineralized but rather transformed to smaller molecules. Therefore, the concentration of molecules with MW < 1 kDa represents the higher number of residual contaminants. For the supernatant of the CC process, the majority of the organic load is made up of molecules with a molecular weight of less than 5 kDa. On the other hand, contrary to the EC treated effluent (for 180 min), macromolecules (with molecular weights > 10 kDa) are still present.

Fig. 8
figure 8

MWD analysis in the terms of TOC of raw and treated effluents by CC and EC, the latter at different electrolysis times (60 and 180 min)

The toxicity of raw and treated effluents was evaluated for Artemia salina (24 h test) for different analyte concentrations (Fig. 9). Note that the lethality decreased from LC50 of 126.43 ppm for raw wastewater to 649.1 ppm (still toxic) and 0.0 ppm for effluents treated by CC and EC, respectively. In the specific case of effluents treated with EC, both for 60 and 180 min, no dilutions of the treated wastewater were found that would cause the death of individuals in the population. Consequently, they can be disposed in a body of water without representing a danger to organisms similar to Artemia salina, contrary to the supernatant of CC.

Fig. 9
figure 9

Evaluation of the toxicity of raw and treated effluents by CC and EC, the latter at different electrolysis times (60 and 180 min)

Electrocoagulation vs. Chemical Coagulation

It is revealed from Table 2 that EC and CC proved a high removal efficiency in terms of color and turbidity. However, the EC method is more effective in removing COD and TOC than the CC. Furthermore, the amount of sludge produced by EC is less than that of CC (footnote to Table 2). Bearing in mind the toxicity of raw effluent, the sludge generated in both processes should be considered potentially dangerous if it has corrosive, reactive, explosive, toxic, flammable, infectious or radioactive characteristics that may cause risk or damage to human health and the environment. Thus, its treatment and disposal must be carried out in accordance with its main characteristics. From this reason, its lower amount, generated during EC process, can be beneficial for the environment (minor carbon footprint). Although it is important to achieve a high efficiency of organic matter removal, the quality of the treated effluent in terms of the type of residual molecules and its toxicity must be also considered. Furthermore, regarding operating costs, note that to achieve similar color and COD removals, at optimal operating conditions, the EC treatment was significantly more economic (Table 2, electrolysis time of 60 min). In addition, 60 min of electrolysis yielded a non-toxic (for Artemia salina) effluent, free of macromolecules. Thus, in order to comply with environmental regulations, the application of the sequential treatment, through biological and/or oxidative processes (e.g., an advanced oxidation process), is a viable alternative to conventional CC treatment. On the other hand, 180 min of electrolysis allows compliance with the requirements of Colombian environmental legislation. Consequently, the EC provides a path for sustainable wastewater management, articulating environmental protection as well as the needs of instant coffee producers, providing a solution depending on specific needs (specifically in the frame of various UN-SDGs: Clean water and sanitation, Affordable and clean energy, Industry, innovation and infrastructure and Climate action).

Conclusions

The EC process was evaluated as an alternative for the treatment of an effluent containing complex mixtures of organic macromolecules resulting from the industrial production of instant coffee. The potential of electrocoagulation for the treatment of an effluent containing complex mixtures of organic macromolecules resulting from the industrial production of instant coffee was evaluated in terms of environmental and economic criteria. Optimum operational conditions were defined from the Box-Behnken experimental design, Response Surface Methodology and multi-objective optimization tools, were: anode and cathode materials: iron and stainless steel, respectively; support electrolyte = 1.78 g of NaCl/L; current density = 150 A/m2; gap between electrodes = 3 mm; stirring velocity = 350 RPM; and pH0 = 4.7 (as in the raw sample). The following optimal operating conditions were established through a series of preliminary experiments, a Box-Behnken design of experiments, Response Surface Methodology application, and multi-objective optimization analysis: the pair of Fe (anode)-stainless steel (cathode) electrodes, supporting electrolyte = 1.78 g of NaCl/L; current density = 150 A/m2; electrode gap = 3 mm; stirring velocity = 350 RPM; and pH0 = 4.7 (that of raw industrial effluent). The kinetic analysis allowed determining the operation time of ca. 180 min required to meet permissible discharge limits for effluents originated from soluble coffee production, in terms of COD concentration, established by current Colombian legislation. The kinetic study allowed defining the electrolysis time of ca. 180 min required to comply with the maximum permissible discharge limits for the production of instant coffee, in terms of COD concentration, established by current Colombian legislation. The EC reached ca. 97% decolorization, as well as 72% and 69% of COD and TOC removal, respectively, with total operation costs of 6.26 USD/m3. EC treatment improved considerably the biodegradability and toxicity characteristics of the raw wastewater, producing an oxidized (COS = 2.87), biocompatible (BOD5/COD = 0.437) and non-toxic effluent, free of contaminants with molecular weight > 30 kDa. Upon these findings, This electrocoagulation appears as an effective alternative for the treatment of industrial wastewater from instant coffee production. within the framework of different Sustainable Development Goals, specifically number 6 (Clean water and sanitation), number 7 (Clean and affordable energy), number 9 (Industry, innovation and infrastructure) and 13 (Climate action).