Introduction

Silicon has undergone extensive research, and its technological applications have reached advanced levels, establishing it as a widely utilized material in diverse scientific fields beyond electronics. Porous silicon is a material that can be obtained through the chemical or electrochemical dissolution of crystalline silicon, first fabricated by Uhlir1. It has been extensively studied for its mechanical, electrical, and optical properties, as well as its potential applications in sensing and optoelectronics2,3,4,5. Various methods of fabrication have been reported6,7, with electrochemical etching being one of the most common8. Porous silicon offers advantages such as low-temperature performance, low cost, easy manufacturing, and compatibility with silicon technology in electronics, as well as a high surface-to-volume ratio, making it useful in different industries9.

The investigation of the surface characteristics of a porous silicon system is a crucial aspect guiding its technological applications. Our study delves into the behavior of spatial patterns, shedding light on how they can impact the material's physical and optical properties. In the realm of surface morphology studies, researchers traditionally rely on techniques like scanning electron microscopy (SEM) or atomic force microscopy (AFM). However, AFM stands out as a precision tool for comprehensive assessment of a surface's topographical properties10,11. Due to its sensitivity and accuracy, AFM generates 3D topographic maps, yielding diverse morphological parameters and Minkowski functionals (MFs)12,13. These insights prove invaluable for characterizing surfaces across various scales. Statistical analysis of AFM images involves extracting quantitative height-based parameters like roughness root mean square surface roughness (Sq), average roughness (Sa), maximum peak height (Sp), maximum pit depth (Sv), and maximum height (Sz), and more. These metrics quantitatively define surface texture, enabling the identification of variations, irregularities, and patterns14,15. Additionally, AFM allows for the study of 3D spatial patterns through fractal mathematics, shedding light on specific aspects of sample microtexture16,17,18. Herein, we have incorporated new parameters, such as fractal succolarity (FS) and topographic entropy (E), to elucidate surface porosity and the uniformity of 3D topographic profiles in our samples. These aspects are crucial as nanoscale exploration of the porous silicon surface plays a pivotal role in unraveling intricate surface features, understanding optical behaviors, and optimizing potential applications.

The reflectance spectra of porous silicon have been analyzed using a simulation method that adjusts dielectric function models. Silicon thin films are utilized in devices for optics, optoelectronics, and microelectronics due to its band gap of 1.12 eV, which enables efficient detection of visible‒light and conversion of sunlight into electricity19. The potential technological importance of silicon-based light emitting devices has sparked interest in the visible photoluminescence of porous silicon at room temperature, which was first reported by Canham in 199020 and subsequently confirmed by other researchers21. However, the existing literature on porous silicon system reveals ongoing controversies regarding its optical and morphological properties under varying preparation conditions, particularly in electrodeposition systems, so far.

Remarkably, in recent years, gas sensing has become increasingly important in environmental monitoring, with a focus on developing small size, low‒power consumption, and reliable gas sensors. Different sensor configurations are required for various applications 22,23. The rapid development of global industry has led to environmental problems such as weather pollution, emission of toxic gases, and volatile organic compounds, which can pose a threat to human health and the environment24. Semiconductor gas sensor technology plays a vital role in detecting these pollutants due to its small size, low cost, and easy manufacturing characteristics. The use of porous silicon in gas sensor technology has improved the accuracy of gas detection by increasing surface reactions on the material. The morphology of the pores can be easily controlled during fabrication, allowing for the design of specific sensor properties25,26.

This paper is dedicated to the obtention of electrodeposited porous silicon thin films by varying HF/ethanol ratios. Our main goal is to offer valuable insights into the 3D nanoscale topography, optical characteristics, and gas sensor properties of these films. As far as current knowledge goes, these aspects have not been thoroughly explored in existing literature. The outcomes of our research yield noteworthy results, holding substantial relevance in the realm of affordable device manufacturing nanotechnology for addressing climate pollution.

Materials and methods

Thin films deposition

An electrochemical etching setup was utilized to prepare porous silicon samples. P-type silicon wafers with a thickness of 525 µm, resistivity of 1–10 Ωcm and a (100) orientation were cleaned with 5% hydrofluoric acid, acetone, and DI (Deionized) water. A layer of aluminum was deposited on the backside of the wafers using the electron beam gun method. The cleaned glossy side was used as the anode electrode in the etching configuration, with a platinum wire counter electrode. The space between electrodes was filled with an electrolyte solution of HF/ethanol in different concentration ratio according to Table 1. The electrochemical etching process was carried out for 60 min at a current density of \(1.99\,{{mA} \mathord{\left/ {\vphantom {{mA} {cm^{2} }}} \right. \kern-0pt} {cm^{2} }}\).

Table 1 Electrolyte characteristics used for different samples.

Characterization of the products

Morphological and fractal analysis

We used the MIRA 3 field emission scanning electron microscopy (FESEM) at Razi metallurgical research center to examine the shape and structure of the porous silicon layers we obtained.

The surface morphology of the samples was scrutinized through 3D Atomic Force Microscopy (AFM) topographical maps, employing an atomic force microscope (AFM) in contact mode, specifically the Auto Probe CP instrument from Park Scientific. The AFM images were processed and studied using Gwyddion version 2.59 software (available in http://gwyddion.net/). The height-based parameters like root mean square roughness (Sq), maximum peak height (Sp), maximum pit depth (Sv), and maximum height (Sz) were extracted and analyzed according to ISO 25,178-2: 2012—surface texture: areal27.

The surface morphology of the samples was further investigated using Minkowski Functionals (MFs). MFs are a set of mathematical descriptors used to analyze and quantify the geometrical properties and morphology of objects or structures, typically in a spatial or image analysis context15,16. Herein, we have computed three known MFs, including Volume (V), Surface Area (S), and Euler-Poincaré Characteristic (χ). V measures the volume or spatial extent of a given structure. In image analysis, it quantifies the amount of space enclosed by the object and is obtained according to Eq. (1), where N represents the total number of pixels, Nwhite represents the number of “white” pixels above the threshold. S represents the boundary or surface that encloses the object. It characterizes the interface between the object and its surroundings and is obtained using the Eq. (2), where Nbound represents the number of white‒black pixel boundaries. Finally, χ is a topological descriptor that reflects the connectivity and topology of an object. It is related to the number of enclosed cavities or voids within the object and is computed using the Eq. (3), where Cwhite and Cblack represent the number of continuous sets of white and black pixels28, respectively.

$$ V = \frac{{N_{white} }}{N} $$
(1)
$$ S = \frac{{N_{bound} }}{N} $$
(2)
$$ \chi = \frac{{C_{white} - C_{black} }}{N} $$
(3)

The spatial complexity and other specific nanotexture surface aspects of the samples were investigated using fractal parameters. These parameters include fractal dimension (FD), fractal sucoolarity (FS), and topographical entropy (E). FD is a mathematical measure used to quantify the level of complexity or irregularity in a fractal object or pattern29 and can easily computed from Gwyddion software. In the context of surface analysis, it characterizes the roughness or intricacy of a surface at various scales. FS is a parameter that provides insights into the shape and complexity of a fractal. It quantifies the degree to which a fractal object fills space30 and is computed using the Eq. (4), where P0 represents the count of filled boxes along each line, Pr corresponds to the abscissa of the pressure centroid associated with each occupiable box within the image, and n is associated with the total count of boxes along each line. A higher succolarity value suggests that the fractal occupies space more efficiently or densely, while a lower value indicates a sparser or less efficient filling of space.

$${F}_{S}= \frac{\sum_{i=1}^{n}{P}_{r}{(k)P}_{0}(k)}{{P}_{0}(n){\sum }_{k=1}^{n}{P}_{r}(k)}$$
(4)

Additionally, the topographical entropy, computed using Shannon entropy31, measures the degree of disorder or randomness in the distribution of certain characteristics on a surface. In the context of topography or morphology analysis, it can assess the organization of the topographical profile. A lower surface entropy value typically indicates greater variability or disorder in the surface's characteristics, while a higher value suggests more uniformity or regularity. TE value is computed using the Eq. (5), where \({p}_{ij}\) represents the probability of pixels exhibiting discrepancies or not within the height range of the analyzed dataset. The value of this parameter varies of 0 (perfect non-uniform pattern) to 1 (perfect uniform pattern)32. FS and TE parameters were computed using R scripts developed in R language using the RStudio software33 (available in https://www.rstudio.com/).

$$TE= -\sum_{i=1}^{N}\sum_{j=1}^{N}{P}_{ij}log{P}_{ij}$$
(5)

Optical analysis

The diffuse reflectance spectroscopy (DRS) was used to investigate the optical properties of the samples. The electrolyte concentration which is a basic factor in uniformity of porous Si samples was optimized. The prepared wafer was then applied in an experimental setup for sensor testing, which included a chamber with the porous Si sample, target vapor, connecting pipes with gas cut-off valves, a DC mini air pump, and a Fluke 289 multimeter for electrical data of sensor response which has been reported previously34. All estimations were done at room temperature.

By measuring the reflectance spectrum of the samples in the range of 200 to 1200 nm and using the Kubelka–Munk theory and converting the reflectance of the samples to the Kubelka–Munk function (F (R)) by Eq. (6), we have35:

$$ F(R) = \frac{{(1 - R)^{2} }}{2R} $$
(6)

where R is the reflectance of sample and depends on wavelength. Equation (7) shows the relationship between F(R) and the absorption coefficient (α) as36:

$$ \alpha = \frac{F(R)}{t} $$
(7)

where ‘t’ is the thickness of porous silicon.

To assess the optical bandgap energy (Eg) dependence on the directly allowed transitions, a plot of (αhν)2 versus hν was obtained, which further allowed the calculation of Eg via the linear hν intercept. Moreover, we used Eq. (8) to calculate the Urbach energy (Eu) values.

$$ \alpha = \alpha_{0} \exp \left( {\frac{h\nu }{{E_{u} }}} \right) $$
(8)

where Eu is the latitude of the local state. If we plot lnα as photon energy, the amount of that energy can be determined from the slope of the curve.

Finally, the steepness parameter σ, characterizes the broadening of the optical absorption edge due to the electron‒phonon interactions and is calculated by the Eq. (9):

$$ \sigma = \frac{{k_{B} T}}{{E_{u} }} $$
(9)

where kB is the Boltzmann constant and T is the absolute temperature in K. Therefore, the values of the strength of the electron–phonon interaction (Ee−p) can be estimated by the Eq. (10) [36]:

$$ E_{e - p} = \frac{2}{3\sigma } $$
(10)

Statistical analysis

The statistical analysis of the data in this study was conducted using the Origin software. To assess the significance of differences among average value of the height-based parameters of porous silicon surfaces, the Analysis of Variance (ANOVA) and Tukey tests were employed. The threshold for statistical significance was set at a p-value of 0.05.

Results and discussion

Morphological and spatial analysis

The SEM technique offers a formidable magnification capability of up to 1,000,000 times, allowing examination at the nanometer scale37. Its significant depth of field is advantageous, enabling simultaneous focus on the specimen’s surface regardless of its roughness38. Moreover, SEM surpasses surface topography analysis39, offering insights into chemical composition40, crystal structure41, and electrical properties42 of the sample. Enhanced confidence in analysis is achievable by seamlessly switching between various imaging techniques, facilitating cross-correlation of gathered information. Additionally, this method presents a key benefit by generating high-resolution images characterized by substantial pixel density, owing to its impressive resolution.

As mentioned in the methodology of this work, the conditions of the etching process were maintained, only varying the HF/ethanol ratio to produce the samples. In our study, to demonstrate how alterations in this ratio impact the micromorphology of the samples, SEM micrographs displaying surface topographies of the films are depicted in Fig. 1. Within this figure, at magnifications of 15,000 × and 35,000x, discernible modifications on the surface are evident, showcasing considerable variations in pore sizes distributed across all surfaces within each sample.

Figure 1
figure 1

SEM micrographs of the (ab) Si#1:4, (de) Si#1:5, (gh) Si#1:6, (jk) Si#1:7, and (mn) Si#1:8 porous silicon surfaces using magnifications of 15,000 × and 35,000x. On the right, correspondent cross section images (15,000x).

Representative images of the surface of the samples and also cross section analysis results illustrate that wear produces porous structures and a significant increase in the average diameter of the pores can be observed, which varied between 1.02 ± 0.09 μm and 2.35 ± 0.11 μm, for Si#1:4 and Si#1:8, respectively. Samples Si#1:5, Si#1:6 and Si#1:7 reached values of the order of 1.19 ± 0.14, 1.39 ± 0.13 and, 1.52 ± 0.06 μm, respectively. On the other hand, the cross-sectional images showed a compensation, in which it is possible to observe a decrease in pore depth, varying between 4.11 ± 0.24 and 6.87 ± 0.57 for Si#1:8 and Si#1:5, with the smallest and largest values, respectively. For the other films, the average depths were Si#1:4 = 4.26 ± 0.11, Si#1:6 = 5.63 ± 0.44, and Si#1:7 = 5.84 ± 0.24. These results demonstrate that in the acid etching process, both the diameter and depth of the pores vary depending on the HF/ethanol concentration.

The morphological characteristics of the samples were also analyzed via AFM, and their 3D surface representations are depicted in Fig. 2. Figure 2a illustrates the surface morphology of the pure Si sample (Si#0), revealing a smooth surface with minor irregularities observable over a 10.2 nm Z‒scale. Conversely, the samples prepared using varying HF/ethanol ratios (Fig. 2a‒f) exhibit a similar surface morphology, albeit notably rougher when compared to the Si#0 sample. These surfaces are predominantly characterized by rugged, mountainous regions displaying substantial irregularities. Such pronounced surface irregularity signifies that the surface porosity of these specimens consistently exceeds that of the pristine Si#0 sample.

Figure 2
figure 2

Representative 3-D AFM micrographs of (a) Si#0, (b) Si#1:4, (c) Si#1:5, (d) Si#1:6, (e) Si#1:7, and (f) Si#1:8 porous silicon surfaces.

Table 2 presents the topographical parameters associated with each sample. As evident, the Si#0 sample boasts a root mean square surface roughness (Sq) of a mere 0.3 nm, which corroborates our qualitative assessment based on Fig. 2a. In stark contrast, the samples produced under a HF/ethanol solution exhibit average roughness values spanning the range of 113 nm (Si#1:4) to 218 nm (Si#1:8), markedly higher than the Si#0 sample. The other height-based parameters, such as maximum peak height (Sp), maximum pit depth (Sv), and maximum height (Sz), follow a similar trend. This underscores the absolute influence of the HF/ethanol ratio on the vertical growth of the samples across various scales. In this regard, it is noteworthy that the roughness values ascend from sample Si#1:4 to Si#1:8, underscoring the pivotal role played by the HF/ethanol ratio in shaping the 3D spatial patterns on the porous silicon surfaces.

Table 2 Height parameters of electrodeposited porous Si surfaces.

Figure 3 illustrates the topographic profiles of the samples. As evident, the Si#0 sample's distribution of rough peaks is notably concentrated within the 1‒2 nm range (Fig. 3a). Moreover, this sample displays an exceptionally narrow distribution, indicative of a leptokurtic surface profile43. On the other hand, the samples subjected to HF/ethanol treatment present broader distributions of rough peaks, spanning a range from 150 to 1200 nm. This unequivocally confirms that HF/ethanol different ratios have altered the surface characteristics, fostering vertical profile growth through acid‒induced modification. Notably, starting from a HF/ethanol ratio of 1:6 (Si#1:6), the distributions exhibit increased flatness, signifying more platykurtic surface profiles31. Furthermore, when examining the Abbott-Firestone curves (AFC)44,45, it becomes evident that the Si#0 sample's curve (Fig. 3c) rapidly approaches its maximum compared to the samples obtained with the HF/ethanol solution (Fig. 3d). This observation underscores that the height distribution of the Si#0 sample does not align with the centering observed in samples Si#1:4 to Si#1:8. As a consequence of the analogous distribution shape seen in samples Si#1:4 to Si#1:8, it's worth noting that their AFCs exhibit the typical S-shaped profile10.

Figure 3
figure 3

(a)‒(b) Topographical profile and (c)‒(d) Abbott-Firestone curves of electrodeposited porous Si surfaces.

We delved further into the morphological characteristics of the samples using Minkowski Functionals (MFs)12,13, and the results are depicted in Fig. 4. In Fig. 4a, we can observe that the Minkowski volume (V) of the Si#0 sample diminishes as relative height (%) increases. However, V consistently diminishes with relative height (%) across all silicon surfaces Si#1:4 to Si#1:8 (Fig. 3d), indicating a substantial portion of material existing above a specific relative height (%) for these samples compared to the Si#0 sample. This robustly supports the notion of increased surface porosity along the surfaces of the samples treated with the HF/ethanol solution. Figure 4) illustrates the Minkowski boundary (S) curve for the Si#0 sample, displaying a narrow non-monotonic trend10 with relative height, centered below 20%. In contrast, samples Si#1:4 to Si#1:8 exhibit maximum S values with relative height centered above 20%. Furthermore, the peak values of S do not demonstrate a linear increase relative to the HF/ethanol ratio. Notably, samples Si#1:4 and Si#1:7 display the highest and lowest maximum S values, respectively. This underscores that the relative distribution of voids exhibits non‒linear behavior in response to variations in the HF/ethanol ratio. Moving to Fig. 4c, it presents the Euler-Poincaré characteristic (χ) of the Si#0 sample, which adheres to the conventional pattern with distinct negative minima and positive maxima values46. These values, when compared to samples obtained with different HF/ethanol ratios, are notably shifted to the left along the relative heights. Moreover, the maximum and minimum χ values for samples Si#1:4 to Si#1:8 are slightly higher than those of the Si#0 sample. It worth noting that no linear behavior was observed in these maximum and minimum values concerning the different HF/ethanol ratios. This suggests that spatial connectivity exhibits non-linear characteristics in response to changes in HF/ethanol solution ratios. Therefore, the results encompassing V, S, and χ collectively emphasize the unique spatial distribution of matter in samples Si#1:4 to Si#1:8 in contrast to the Si#0 sample according to Fig. 4d, e and f respectively. This substantiates that acid etching facilitated the formation of similar highly rough morphologies.

Figure 4
figure 4

Minkowski volume, Minkowski boundary, and Minkowski connectivity of electrodeposited porous Si surfaces.

Fractal analysis of the 3D spatial patterns

It is known that the microtexture of nanoscale surfaces can be completely mapped by fractal parameters30,47. Herein, we use the fractal dimension (FD), the fractal succolarity (FS), and the topographic entropy (TE) to evaluate the complexity, surface porosity, and uniformity of the topographic profile of the samples, respectively, as shown in Table 3. The highest FD value was observed for Si#0 sample. There is a discernible decline in the average FD values for samples Si#1:4 to Si#1:8, signifying a reduction in the spatial complexity of the samples as function as HF/ethanol solution ratio employed. Consequently, we can infer that the acid etching process led to the creation of less intricate surfaces with shorter-range correlations, despite their increased roughness. This indicates that as the HF/ethanol solution ratio was changed from 1/4 to 1/8, the surfaces progressed towards an almost perfectly flat state (FD = 2)18.

Table 3 Fractal parameters of porous silicon surfaces.

The assessment of surface porosity using the fractal sucoolarity30 parameter reveals that the Si#0 surface is the less porous surface, characterized by the lowest FS value (~ 0.44). Furthermore, porosity consistently increases (with statistical significance at p < 0.05) from samples Si#1:4 to Si#1:8, ranging from ~ 0.45 to ~ 0.54. This signifies that surface porosity escalates as the HF/ethanol solution ratio decreases. Hence, the sample produced under a 1/8 ratio proved to be the most porous among all, in alignment with our qualitative analysis of the AFM images. It’s noteworthy that the elevation in surface roughness resulted in flatter surfaces with a more extensive distribution of regions permitting fluid access from lower to upper bands. This finding aligns with the behavior of the Urbach energy, which exhibits an increase from samples Si#1:4 to Si#1:8, reflecting the rise in surface porosity across the samples. Additionally, we assessed the uniformity of the topographic profiles using topographic entropy (TE)32. Notably, the Si#0 surface, along with the sample produced with an HF/ethanol ratio of 1/6, displayed the lowest average TE values. However, our statistical analysis revealed that the average values, in general, do not exhibit statistically significant differences (p > 0.05). In simpler terms, the tails of the distributions (for N = 3) overlap, demonstrating that any mean value is a valid representation. Consequently, we can conclude that all topographical patterns, including those of the Si#0 sample, demonstrate similar levels of topographical uniformity. This implies that they possess comparable proportions of uniform and non-uniform patterns. It's worth emphasizing that the E values approximating 1 for all samples indicate a high degree of uniformity in their topographical patterns, affirming the excellent quality and robustness of our samples.

Optical properties

In Fig. 5, the absorption diagram is drawn in terms of incident photon energy. The absorption of the samples has increased with the increase of porosity up to sample Si#1:7 and the porosity is 54%, but in the Si#1:8 sample it has decreased drastically, and it is even less than non‒porous silicon surface (Si#0). Accordingly, we chose to check the behavior of the sensor. The Eg values (Fig. 6) decrease smoothly from 1.18 eV to 1.12 eV as the amount of porosity increases, as shown in Table 4. By increasing the amount of porosity, the Eg has decreased, that is, the number of localized states and defects has increased, which is exactly confirmed by calculating the Urbach energy (Eu), because with the increase in porosity, the amount of Eu has increased (Table 4).

Figure 5
figure 5

Adsorption coefficient of Si surfaces with different porosity.

Figure 6
figure 6

Diagram of (αhν)2 versus hν and determination Eg from (a) Si#1:4 to Si#1:6, (b) Si#1:7, and (c) Si#1:8.

Table 4 The values of optical parameters of porous Si surfaces.

As can be seen, the porosity of the surfaces has created holes and defects in the structure also increased the density of replaced levels, as verified by the Eg and Eu values shown in Table 4. Notably, we can note that Eu value increases with increasing porosity. Furthermore, there is a good linear relation between Eg and Eu, as shown in Fig. 7. The empirical formula for this linear fit is given by Eq. (11). The average value of the constant in Eq. (11) is also obtained from the linear fit calculated down to 1.2 eV ignoring tailing. Curiously, a linear relationship between the Eg and the width of the Eu has also been observed in other semiconductors48.

$$ E_{g} = 1.2 - 0.2E_{u} $$
(11)
Figure 7
figure 7

The relation between Eg and width of Eu of Si porous surfaces.

The estimated values of steepness parameters and the strength of the electron‒phonon interaction are listed in Table 4. The porosity of the Si structure affects the Eu emission, and the higher the porosity, the stronger the Eu emission. Porosity in the Si structure increases the number of localized states, vacancies, and dislocation defects. We estimated the values ​​of the steepness parameter and the strength of the electron‒phonon interaction according to Table 2. The Eu and Ee-p values ​​increase with increasing Si porosity. On the other hand, the steepness parameter decreases. Hence, increased porosity diminishes steepness values due to heightened dislocations and structural disturbances. Porosity reduces the transconductance parameter while augmenting electron‒phonon interaction strength.

Evaluating the sensing properties

Figure 8 shows the experimental values of the resistance-based gas sensors regarding to CO2 and O2 at 20 °C with different gas concentrations (30, 50, 70 and 90 sccm). Figure 8a shows the changes in electrical resistance of the gas sensor in terms of time and in different concentrations (30, 50, 70, and 90 sccm) of CO2 gas. As can be seen, the electrical resistance increases with the absorption of CO2 gas by the sensor. The electrical resistance with a fixed concentration of 30 sccm of CO2 gas increases from 162 to 169.6 KΩ for 30 s, and for a concentration of 90 sccm, the electrical resistance increases from 147 to 154.9 KΩ. The results of Fig. 8a show that the electrical resistance has decreased with the increase in the concentration of CO2 gas. With the increase of CO2 gas concentration from 30 to 90 sccm, the electrical resistance has decreased from 162 to 147 KΩ respectively. Comparison between the fabricated gas sensor and other works shows good agreement. Abdali et al49. show that for the CO2 gas sensor with different concentrations, the electrical resistance has decreased with increasing gas concentration. In Fig. 8b, the diagram of changes in the electric resistance of the sensor in terms of time and in different concentrations (30, 50, 70 and 90 sccm) of O2 gas has been examined. As can be seen from Fig. 8b, the electrical resistance increases with the absorption of O2 gas by the sensor and the electrical resistance with fixed concentrations of 30 sccm and 90 sccm increases from 6.14 to 6.24 MΩ and from 6.47 to 6.67MΩ, respectively, with the passage of time of 30 s. The results from Fig. 8b show that unlike the behavior of sensor in the presence of CO2 gas, with the increase in concentration of O2 gas from 30 and 90 sccm, the electrical resistance has increased from 6.14 to 6.47 MΩ. A comparison between the graphs in Fig. 8a and b shows that the electrical resistance of gas sensor in the presence of CO2 and O2 gases at a concentration of 30 sccm are 162 KΩ and 6.14 MΩ, respectively, which indicate the optimal response of the gas sensor.

Figure 8
figure 8

Experimental value of the resistance-based gas sensors to (a) CO2 (b) O2 at 20 °C and different gas concentrations (30, 50, 70 and 90 sccm).

Resistance-based gas sensor response is obtained from the following Equation50:

$$ {\text{Re}} sponse(\% ) = \frac{{R_{g} - R_{0} }}{{R_{g} }} \times 100 = \frac{\Delta R}{R}(\% ) $$
(12)

In this regard, Rg is the electrical resistance of the sensor in the presence of CO2 and O2 gas. As can be seen from Fig. 8, the response of the resistance-based sensor in different concentrations is higher for CO2 gas. Also, the results from Fig. 9 show that with the increase in the concentration of CO2 and O2 gases from 30 to 90 sccm, the response of the sensors has increased from 4 to 8% and from 1 to 6%, respectively. The response time of the sensor (t 90%) is defined as the time it takes to reach 90% of the final value, and the reversibility time (t 10%) is the time from 90 to 10% of the initial value51. As can be seen from Fig. 9, the response time of the CO2 gas sensor is equal to 27 s and the reversibility time is 81 s. The response and reversibility times for the O2 gas sensor are 29 s and 83 s, respectively.

Figure 9
figure 9

Response (%) of CO2 and O2 gas sensors in different gas concentration (a) 30 sccm (b) 40 sccm (c) 70 sccm (d) 90 sccm.

The comparison between CO2 and O2 gas sensor performance is shown in Table 5. In Ref.52, a resistance-based sensor for detecting CO2, H2, and C2H2 gases using nanoporous graphene has been investigated. That article showed that at concentration of 60 sccm, the response of the sensor to CO2, H2 and C2H2 gases is 37.04%, 16.16% and 2.87%, respectively. The CO2 gas resistance-based sensor based on MgFe2O4 shows response time of 3 s at temperature of 300 °C53. The comparison between CO2 and O2 resistance-based gas sensors based on CNTs, ZnO and SnO2 shows the response time and reversibility in a few minutes54,55,56. Smith et. al.57 investigated a resistance-based CO2 gas sensor based on graphene. They showed that at room temperature and at a concentration of 400 ppm, the response time of the sensor is 3 s. The comparison between the response time and reversibility of the fabricated sensor with other CO2 and O2 gas resistance-based sensors shows that the fabricated sensor in the present work has a high response speed at room temperature 57,58,59.

Table 5 Comparison of CO2 and O2 gas sensors.

Conclusions

In summary, P-type silicon with a (100) orientation served as the substrate for porous silicon fabrication through the electrochemical etching method, utilizing HF/ethanol electrolyte at varying ratios. Characterizations via AFM, SEM, and DRS yielded essential insights into 3D topography, morphological, and optical properties of the thins films. Morphological analysis underscored the formation of unique surfaces with distinct morphologies compared to untreated samples, fostering substantially rougher surfaces with maintained flat characteristics, as confirmed by Minkowski Functionals analysis. Fractal mathematics exploration of 3D spatial patterns emphasized that HF/ethanol-treated surfaces, despite increased roughness, exhibited flatter attributes compared to untreated Si samples. Fractal analysis highlighted roughness as a fundamental factor in creating more porous surfaces, evident in the fractal juice parameter. Topographic entropy assessments demonstrated similar high-quality attributes in the uniformity of 3D topographic patterns across all samples. Optical calculations revealed that increased porosity correlated with a rise in localized states and defects, alongside an augmentation in the Eu value. Consequently, porosity contributed to a reduction in steepness values due to heightened dislocations and structural disturbances. The transconductance parameter decreased, while the strength of electron–phonon interaction increased with porosity. Subsequently, the porous sample was employed as a gas sensor for CO2 and O2 vapors at room temperature, monitoring changes in electrical resistance over time and varying concentrations. Increasing CO2 gas concentration from 30 to 90 sccm resulted in a decrease in electrical resistance from 162 KΩ to 147 KΩ, with a response time of 27 s and a reversibility time of 81 s. For the O2 gas sensor, response and reversibility times were 29 s and 83 s, respectively. These findings underscore the pivotal role of surface porosity in shaping the optical and sensing properties of silicon porous surfaces under different HF/ethanol ratios.