1 Introduction

The exhaustion of natural energy resources forces researchers to find new alternative solutions. In the last decade, immense kinds of renewable energy resources have been developed, such as biomass, hydrodynamic, and solar energy (Nishiyama et al. 2021; Pagliaro 2019; T Hisatomi 2019; Takata 2020). Such resources successfully substitute natural sources and limit their hindrances. Indeed, several disadvantages of a few natural sources, like the combustion of fossil fuels, have been avoided in terms of harmful effects on plants, animals, and humans related to the intensive production of hazardous gases, such as COX, NOX, and SOX (Asmaa M. Elsayed, Mohamed Rabia, Mohamed Shaban, Arafa H Aly 2021; Mohamed et al. 2020; Shaban et al. 2019).

Water splitting reaction becomes one of the most promising renewable solar energy routes ensuring high hydrogen production. Such energy depends mainly on sunlight effectuate through photochemical or photoelectrochemical. The source produces hydrogen gas at the working electrode. However, an appropriate semiconductor like oxides, nitrides, or sulfides is required to accomplish the splitting process. (Kang et al. 2019; Lee et al. 2018). However, these semiconductors have few hampers as photocatalytic-based material. This opens the door for researchers to develop new materials, like polymers. These latest usages ensure a cost-effective good quality, large surface, and simple synthesis way (Bec and Huck 2019; Chen et al. 2022; Kim et al. 2022; Koh et al. 2021; Yuan et al. 2020; Zhang et al. 2022).

In this regard, a good synthesis optimization of polymer material will favor its application(Rahmah 2023b; Rahmah 2023a; Rahmah et al. 2022; Rahmah and Garallah 2022; Sabry and Al-Mosawi 2017). This was realized by combining polymers with materials with high optical properties. Indeed, scientists recently succeeded in producing a material mixture of a combined material with a small bandgap of 1.3 to 2.5 eV (Shaban et al. 2017b).

Polyaniline (PANI) and its derivatives are considered one of the most investigated polymer categories so far. This polymer owns unique advantageous properties. It is known for its good stability, porosity, small bandgap, and low cost. (Abukhadra et al. 2018; Shaban et al. 2018). On the other hand, Cr2O3 material proceeds with particularly promising optical and electrical properties. Also, it has a small band gap of about 1.6 to 2.5 eV, which encourages its application in various domains like optoelectronics and water splitting (Rabia et al. 2018; Shaban et al. 2017a). Nowadays, limited research is interested in polyaniline derivatives' applications in water-splitting process. Some studies prepared Ni/PANI for hydrogen gas evolution using H2SO4 using artificial light (Dalla Corte et al. 2012). Furthermore, Belabed et al. (2013) had studies PANI/TiO2 as a simple composite for this application. Moreover, the other literature developed PANI/MoS2 for H2 generation from an H2SO4 solution (Zhang et al. 2015). However, several disadvantages associated with such photocatalytic polymers have been established, such as their low efficiency (2%) due to the low amount of H2 formed, poor cell performance, electrode corrosion, and the destruction of natural water sources. (Acar et al. 2016; Mishra and Chun 2015; Teixeira et al. 2019). Nonetheless, the PANI material preparation method is simple and cost-effective when compared to metal oxides or sulfides material preparation methods such as vapor deposition and RF sputtering (Chiang et al. 2011; Guo et al. 2014).

Furthermore, other materials like g-C3N4-CuO (Ragupathi et al. 2020), CuO−C/TiO2 (Huang et al. 2019), and TiN−TiO2 (Naldoni et al. 2017) have been investigated as photoelectrodes for hydrogen generation. These studies involved measurements conducted under strong acidic or basic conditions. However, the resulting Jph values obtained from these materials were relatively low, with values of 0.01 mA.cm−2, 0.012 mA.cm−2, and 0.0003 mA.cm−2, correspondingly. These findings highlight the challenge of achieving efficient hydrogen generation using these materials in the given experimental conditions.

The materials that have been used in the past for the hydrogen gas evolution reaction have had certain limitations, such as the need for expensive techniques and additional electrolytes. These limitations have restricted the efficiency and rate of the hydrogen gas evolution reaction. However, it suggest that the Cr2O3-Cr(OH)3/P2CA nanocomposite photoelectrode overcomes these limitations, as it does not require any man-made electrolyte and can efficiently produce hydrogen gas at a high rate.

Herein, we present hydrogen gas fuel by solving polymer usage limitations. For a Cr2O3− Cr(OH)3 nanocomposite prepared by polymer-assisted ionic adsorption, we used P2CA-assisted deposition; this composite is decorated over a Ppy seeding layer. The large surface area and porosity of P2CA help Cr2O3 deposition. The Cr2O3−Cr(OH)3/P2CA nanocomposite photoelectrode was created by depositing the composite late into the glass. This latest was demonstrated as a photocathode in a electrochemical cell using wastewater (Beni-Suef city, Egypt). The H2 gas evolution rate is evaluated through the produced Jph value under various parameters such as on/off light illumination, and under monochromatic wavelengths; 340, 540, and 730 nm.

1.1 Materials

Pyrrole and 2-chloroaniline are obtained from Sigma Aldrich (Japan) and Merk (Germany(, correspondingly. While dimethyl sulfoxide is obtained from Sigma Aldrich (USA). Winlab (UK) provides us with K2S2O8, while El Naser Co (Egypt) supplies K2Cr2O7 and HCl.

1.2 Polypyrrole thin film’ preparation

Pyrrole monomer can be oxidized and polymerized at room temperature to form polypyrrole, which has a characteristic dark green color. For performing this process, 0.12 M (0.32 ml) pyrrole is dissolved in 0.5 M hydrochloric acid. A solution of 0.15 M (1.7 g) K2S2O8 is prepared separately and then added suddenly to the pyrrole solution. The stoichiometric ratio of the oxidant to monomer is 1: 1.25. This triggers the polymerization process, resulting in the formation of the dark green polypyrrole polymer, After the preparation process, we thoroughly cleaned the polymer film with distilled water and dried it at 60°C for 20 min. the polymerization reaction is mentioned in Scheme S1, while a mobile photo of polypyrrole thin film on a glass slide is illustrated in Fig. S1.

1.3 Cr2O3−Cr(OH)3/P2CA nanocomposite photoelectrode preparation

Cr2O3−Cr(OH)3/P2CA nanocomposite photoelectrode preparation is performed by the oxidation of 2-chloroaniline using K2Cr2O7 as an oxidant. Both of monomer and the oxidant are dissolved separately in which 0.6 M HCl solution is the solvent. The greenish-brown color of the Cr2O3−Cr(OH)3/P2CA nanocomposite is formed by the reaction of K2Cr2O7 and the monomer. In this reaction, the seeded polypyrrole/glass thin film is inserted into the solution during this polymerization, this layer motivates the formation of Cr2O3−Cr(OH)3/P2CA nanocomposite photoelectrode.

1.4 Characterization and analyses

Examining the crystalline solids' structure of the materials is performed using PANalytical Pro, New Zealand, and then through the XPS analyses. Moreover, the process of determining a sample's chemical makeup using the molecular vibrations of that sample through the FTIR 340 Jasco spectrophotometer. For the morphological study, at high magnifications, SEM can provide crucial information regarding the morphology and topography of the prepared materials, ZEISS, Germany. For confirming the morphology of the sample, TEM with the JEOL JEM-2100 model is used, in which the process is performed at very high magnification. The absorbance and then bandgap calculation is performed using the UV/Vis spectrophotometer, this device has a model of Birkin Elmer, USA.

1.5 The electrochemical test

The behavior of the electrochemical systems is tested using the power stations (CHI608E). This process is performed by applying a potential (−0.85 to 1.1 V) vs. RHE. Through this potential, the working electrode (Cr2O3−Cr(OH)3)/P2CA nanocomposite photoelectrode) responds and produces the current density (Jph). In this cell, the graphite electrode functions as the counter electrode, while the calomel electrode serves as the third electrode. through which the potential inside the cell is determined. A high-intensity discharge metal halide lamp (400 W) is applied as a light source for the photocatalytic reaction. Sewage water (third treated water, pH 7.2) is used as the source of hydrogen gas, this water is applied as an electrolyte inside the cell.

2 Results and discussion

2.1 Characterization procedures

The surface topography and morphology of P2CA and Cr2O3−Cr(OH)3/P2CA are depicted in Fig. 1a and b, respectively, using SEM analysis, while the 2D morphologies are illustrated through TEM (Fig. 1c and d)  respectively. The SEM images reveal that the P2CA material exhibits a fibrous structure, with interconnected fibers forming a network. The fibers have an average length of 2–3 µm and a width of approximately 100 nm. This unique fibrous morphology provides a large surface area and interstitial spaces, which are advantageous for incorporating and interacting with other materials during the composite formation process.

The composite material, Cr2O3-Cr(OH)3/P2CA, exhibits significant improvements in its topography and morphology compared to the individual components. The addition of Cr2O3-Cr(OH)3 to P2CA results in the formation of a highly porous structure with distinctive flower-shaped features. The material displays a slot-like behavior with circular empty holes distributed throughout its surface. These nanoparticles within the composite exhibit a pore structure ranging from 5 to 100 nm, further enhancing the material's porous nature. These unique characteristics contribute to the increased surface area and improved properties of the Cr2O3−Cr(OH)3/P2CA composite material. The cross section of this Cr2O3−Cr(OH)3/P2CA nanocomposite is mentioned in Fig. S2,, which is obtained through the simulated modeling from SEM.

To be more specific, the TEM image shows the extensive incorporation of Cr2O3−Cr(OH)3 into the P2CA polymer materials; the metal has a dark color and an average particle size of 18 nm, while the polymer coats these particles with its gray color. Using the inserted magnified image, the interatomic distance is about 2.0 nm, illustrating the growth of the particles that order beside each other, these properties demonstrate promising optical properties

On the other hand, porous, homogeneous, semispherical particles (450 nm) make up the Ppy seeding thin film layer (Fig. S2(a)). These particles have an average size of 15 nm and are composed of numerous smaller particles that aggregate to form bigger semispherical shapes. With their wrinkled microscopic particles, the Ppy particles' shape makes them ideal for usage as a seed layer for the development of further nanomaterials. The homogeneous shape of the particles assures constant and predictable growth behavior, while the porous structure reflects the high surface area of the Ppy particles allow the nucleation and formation of new materials.

Fig. 1
figure 1

SEM of a P2CA, b Cr2O3-Cr(OH)3/P2CA nanocomposite. c and d TEM of this nanocomposite at different magnifications

The elemental and chemical structure of the synthesized Cr2O3-Cr(OH)3/P2CA nanocomposite is performed using the XRD analysis as illustrated in Fig. 2a. The P2CA polymer has an amorphous structure that appears through the broad peaks, this behavior is matched with most of the polymers that have a nanocrystalline structure (Gamal et al. 2022; Rabia et al. 2022). In contrast, the Cr2O3-Cr(OH)3/P2CA nanocomposite exhibited a crystalline structure, as evidenced by the sharp peaks observed at certain angles: 23.38°, 40.59°, 50.23°, 58.67°, 66.36°, and 73.58°. These peaks matched with the growth directions (012), (113), (024), (122), (300), and (019), correspondingly that confirmed the presence of Cr2O3 inside the composite(Tsegay et al. 2021). The XRD analysis does not confirm the Cr(OH)3; this is normal for this material and consistent with previous literature(Balayeva et al. 2019; Zhang et al. 2014).

For the calculation of the crystalline size (D) of this composite, Cr2O3-Cr(OH)3/P2CA, using the width of a crystal's diffraction (W), Scherrer’s formula, Eq. 1(Almohammedi et al. 2021; Fadel et al. 2018a) is applied, using the X-ray diffraction wavelength (λ). Under these calculations, the average D size is 75 nm for the crystalline peaks located at 40.59° and 66.36°.

$${\text{D = 0}}{\text{.9}}\lambda {\text{ / W cos}}\theta$$
(1)

The seeding Ppy layer is characterized using SEM and XRD, in which the Ppy film has porous spherical particles (Fig. S3(a)) with a semicrystalline behavior through the XRD pattern (Fig. S3(b)). The Ppy film is advantageous for supporting the growth of additional materials within the polymer network, enabling their growth and development. The FTIR analysis for this seeding layer is mentioned in Fig. S3(c). All the bands for the Ppy polymer appear, such as 1545 cm−1 (ring), while the bands at 1312 and 1177 cm−1 are for C–H, in the same way, the band at 1045 cm−1 is for the C–N group.

FTIR analyses reveal the functional groups of the P2CA and Cr2O3–Cr(OH)3/P2CA nanocomposite (Fig. 2b). N–H and C–N group appears at 3235 cm−1 and 1567 cm−1, respectively. Also, the C-H group locates at 1492 cm−1. C = C and C-Cl groups appear well at 1282 cm−1 and 699 cm−1, correspondingly. These functional groups appear in the Cr2O3–Cr(OH)3/P2CA composite, but with minor blue shifts (in most of the function groups) due to the effect of Cr2O3–Cr(OH)3 inorganic materials. This behavior matches with most polymer composite(Hadia et al. 2022).

Fig. 2
figure 2

a XRD, b FTIR, c optical, and d bandgap for the P2CA and Cr2O3–Cr(OH)3/P2CA nanocomposite

The nanocomposite made up of P2CA and Cr2O3–Cr(OH)3 exhibits strong optical absorption in both the ultraviolet and visible regions, as shown in Fig. 2a and b, with absorption peaks extending up to 700 nm and 800 nm, respectively. The incorporation of Cr2O3–Cr(OH)3 into the nanocomposite enhances its sensitivity to photons in the visible region, indicating its potential for use in optical applications. This enhancement is likely due to electron transitions within the nanocomposite, which motivate the observed changes in optical properties.

The optical properties of the P2CA and Cr2O3–Cr(OH)3/P2CA nanocomposite can be quantitatively described using Tauc's equations, which depend on the material's absorbance (A) and absorption coefficient (α). By applying Eqs. 2 and 3 of Tauc's equations (Fadel et al. 2018b), it is possible to calculate the bandgap of the material using these parameters. The bandgap is a characteristic property of a material that describes the electron transition process.

In Tauc's equations, h and ν are the Planck's const. and frequency. By measuring the absorbance and absorption coefficient of the nanocomposite in the UV-Vis spectra, it is possible to determine the bandgap of the material and gain further insight into its electronic properties. The observed enhancement in photon sensitivity in the Vis region may be related to reduce in the bandgap under the insertion of Cr2O3–Cr(OH)3 into the nanocomposite.

$${{\upalpha }\text{h}{\upnu } = \text{A}(\text{h}{\upnu }-{\text{E}}_{\text{g}})}^{1/2}$$
(2)
$${\upalpha }=\left(\frac{\text{2,303}}{\text{d}}\right)\text{A}$$
(3)

The bandgap confirms this enhancement as demonstrated in Fig. 2b. By calculating the bandgap using the equation Eg = 1240/λ, where λ is the wavelength corresponding to the absorption edge (668 nm in this case), the bandgap of the composite is determined to be approximately 1.87 eV. This indicates that the composite has a relatively low bandgap, allowing it to absorb a wide range of wavelengths in the visible and near-infrared regions. The wide optical bandgap of the Cr2O3-Cr(OH)3/P2CA nanocomposite, makes it suitable for various photocatalytic applications, such as green hydrogen generation and photovoltaic devices. This broad range of absorption allows for efficient utilization of solar energy, enabling the material to harness a wider spectrum of light for catalytic reactions or energy conversion processes. Its optical properties make it a promising candidate for sustainable energy applications.

In contrast to the P2CA and Cr2O3-Cr(OH)3/P2CA nanocomposite, the optical properties of a Ppy film are limited, as shown in Fig. S3(d). The Ppy film exhibits strong absorbance in the UV region only, indicating limited sensitivity to photons in the visible range. However, this property makes Ppy film a good candidate for use as a seeding layer in the growth of the Cr2O3–Cr(OH)3/P2CA nanocomposite. The seeding layer does not significantly affect the light absorbance of the resulting nanocomposite while promoting its growth.

Figure 3a shows an XPS survey of the Cr2O3-Cr(OH)3/P2CA nanocomposite. Figure 3b displays the Cr spectra, which reveal the Cr 2p3/2 and 2p1/2 peaks derived from Cr2O3 and Cr(OH)3 at 577.93 and 287 eV, respectively. Additionally, Fig. 3c shows the appearance of the O1s peak at 532.31 eV, confirming the presence of oxygen in both the Cr2O3–Cr(OH)3 materials. The ratio of O to Cr is about 4.6, indicating the formation of oxide and hydroxide at the same time in the Cr atom(Bumajdad et al. 2017). Furthermore, different other components have been distinguished in Fig. 3d, e, and f, including C1s, Cl2p, and N1s at 285.82, 201.05, and 400.25 eV, respectively.

Fig. 3
figure 3

XPS a survey, b Cr, c O, d C, e N, and f C elements of the Cr2O3-Cr(OH)3 /P2CA nanocomposite

2.2 The electrochemical study

The prepared Cr2O3-Cr(OH)3/P2CA nanocomposite supported on the Ppy seeding layer as a working electrode in a hydrogen generation cell that uses wastewater as an electrolyte (third treatment). Inside this cell, the graphite rod serves as a counter electrode using the CHI60E as a power station for this testing.

The great enhancement in the produced Jph value under light is illustrated well in Fig. 4a, red curve. The Jph value in off/on light clarifies the great enhancements under light, these values are 0.002 and 0.018 mA.cm−2, correspondingly. The negative value of the Jph indicates the reduction process and the hydrogen generation reaction, while the small dark current indicates the semiconductor nature of the synthesized Cr2O3-Cr(OH)3/P2CA nanocomposite. The wide absorbing behavior of this composite, as indicated before in the optical measurements, motivates the electron transition and then the collections on the conducting band, in which these electrons transfer to the neighboring solution (wastewater) for additional reduction and the hydrogen gas production. The hydrogen gas rate is represented by the Jph value(Sayyah et al. 2016a; Sayyah et al. 2016b), so the rate increases well after the light illumination. The electrochemical behavior of Ppy thin film is illustrated in Fig. S4, in which the maximum Jph is 0.01 mA.cm−2 under light illumination.

Figure 4b shows that the Cr2O3-Cr(OH)3/P2CA nanocomposite exhibits similar behavior as the one described above, in terms of its response to on/off chopped light. This behavior indicates that the nanocomposite is highly sensitive to the incidence of photons. Furthermore, this sensitivity suggests that the nanocomposite can be reliably used for the hydrogen reduction reaction from wastewater solutions. Overall, the results from Fig. 4b provide a strong indication of the reproducibility and reliability of the Cr2O3-Cr(OH)3/P2CA nanocomposite for use in wastewater treatment applications (Table 1).

Fig. 4
figure 4

a The current density under the applied potential in on/off light conditions, and b the current density reproducibility under on/off chopped light for the working electrode Cr2O3-Cr(OH)3/P2CA nanocomposite

Table 1 The concentration of the different elements and materials in the sewage water used for hydrogen generation.

Figure 5 a and b demonstrate the sensitivity of the Cr2O3-Cr(OH)3/P2CA nanocomposite photoelectrode to different monochromatic light wavelengths, specifically 340, 540, and 730 nm. The results show that the optimum Jph value is achieved at 340 nm, indicating that the nanocomposite is highly sensitive to increasing light frequency. Furthermore, the results confirm that the photoelectrode exhibits responsivity in the infrared (IR) region, as evidenced by the increase in Jph from − 0.005 to − 0.006 mA.cm−2 at 340 and 730 nm, correspondingly.

These findings demonstrate that the Cr2O3-Cr(OH)3/P2CA nanocomposite photoelectrode is sensitive to a wide range of optical frequencies, including the IR region, and suggest that the nanocomposite can significantly enhance the hydrogen reaction. Overall, the results from Fig. 5 a and b highlight the potential of the Cr2O3-Cr(OH)3/P2CA nanocomposite as an efficient and versatile material for use in a range of photoelectrochemical applications.

Fig. 5
figure 5

a The response of the fabricated Cr2O3-Cr(OH)3/P2CA nanocomposite photoelectrode to the light illumination under various optical wavelengths (340 to 730 nm) and b the produced Jph values under these optical filters

When a very small, applied potential of -0.1 V is used, the hydrogen reduction reaction occurs and H2 gas is evolved at the cathode. This can be confirmed through the Faraday law, which is described by Eq. 4 [5]. The rate of H2 gas production is about 20 µmole.h−1.10cm−2 of the Cr2O3-Cr(OH)3/P2CA nanocomposite photoelectrode. The Faraday law is based on the Faraday constant (F), which has a value of 96500 C mol−1.

The high rate of hydrogen gas production observed in this study indicates the potential for industrial applications and the use of sewage water as a hydrogen source, without the need for any man-made electrolyte. Overall, these findings suggest that the Cr2O3-Cr(OH)3/P2CA nanocomposite photoelectrode is a promising material for use in wastewater treatment and hydrogen gas evolution applications.

$${\text{H}}_{{\text{2}}} {\text{(moles) = }}\int\limits_{t}^{t} {\frac{{J_{{ph}} dt}}{F}}$$
(4)

3 Conclusions

A flower-like Cr2O3-Cr(OH)3/P2CA nanocomposite is synthesized by oxidation of 2CA with K2Cr2O7. The preparation process is performed on Ppy seeing film. SEM illustrates that the P2CA material has a tissue structure through the great fibers' behavior. The Cr2O3-Cr(OH)3/P2CA composite has a large porous structure with flower-shaped properties, slot behavior, and large circular empty holes, with nanoparticles with pore structures ranging from 5 to 100 nm. The calculated bandgap for P2CA and Cr2O3-Cr(OH)3/P2CA are 2.02 and 1.87 eV, respectively.

A Cr2O3-Cr(OH)3-P2CA composite photoelectrode is used to generate hydrogen from sewage water, and the produced Jph value reflects the rate of hydrogen generation. The light illumination and the optical wavelength filter condition are applied for testing the behavior of this composite. The Jph value in off/on light clarifies the great enhancements under light, these values are 0.002 and 0.018 mA.cm-2, correspondingly. Moreover, the increase in Jph from − 0.005 to -0.006 mA.cm-2 at 340 and 730 nm, correspondingly. These results suggest that the Cr2O3-Cr(OH)3/P2CA composite photoelectrode exhibits high sensitivity and can efficiently generate hydrogen from wastewater, making it a promising material for industrial applications.