Influence of Mg Doping Levels on the Sensing Properties of SnO2 Films.

This work presents the effect of magnesium (Mg) doping on the sensing properties of tin dioxide (SnO2) thin films. Mg-doped SnO2 films were prepared via a spray pyrolysis method using three doping concentrations (0.8 at.%, 1.2 at.%, and 1.6 at.%) and the sensing responses were obtained at a comparatively low operating temperature (160 °C) compared to other gas sensitive materials in the literature. The morphological, structural and chemical composition analysis of the doped films show local lattice disorders and a proportional decrease in the average crystallite size as the Mg-doping level increases. These results also indicate an excess of Mg (in the samples prepared with 1.6 at.% of magnesium) which causes the formation of a secondary magnesium oxide phase. The films are tested towards three volatile organic compounds (VOCs), including ethanol, acetone, and toluene. The gas sensing tests show an enhancement of the sensing properties to these vapors as the Mg-doping level rises. This improvement is particularly observed for ethanol and, thus, the gas sensing analysis is focused on this analyte. Results to 80 ppm of ethanol, for instance, show that the response of the 1.6 at.% Mg-doped SnO2 film is four times higher and 90 s faster than that of the 0.8 at.% Mg-doped SnO2 film. This enhancement is attributed to the Mg-incorporation into the SnO2 cell and to the formation of MgO within the film. These two factors maximize the electrical resistance change in the gas adsorption stage, and thus, raise ethanol sensitivity.


Introduction
The monitoring of volatile organic compounds (VOCs), including ethanol (C 2 H 6 O), acetone (C 3 H 6 O), and toluene (C 7 H 8 ), is routinely needed for evaluating environmental quality and industrial safety [1]. Recently, the monitoring of VOCs has also gained importance in clinical applications as a promising tool to identify pathological conditions at early stages (via breath analysis of anomalous concentrations of certain VOCs) [2]. In this context, metal oxides (MOXs)-based gas sensors (chemoresistive sensors) are attractive devices that can be miniaturized and integrated as array systems into compact VOC monitoring equipment at reduced fabrication costs as compared to other technologies (e.g., spectrometers) [1,2]. Previously, MOXs such as ZnO, SnO 2 , WO 3 , and TiO 2 at the nanoscale have proved promising properties to sense VOCs due to their high surface-to-volume ratio, which provides better sensitivity and stability compared to bulk MOXs [3][4][5][6][7]. Currently, however, these materials require yet the enhancement of sensitivity to low concentrations of VOCs and, generally, the improvement of selectivity and the minimization of drift effect over time. Thus, various efforts have been focused on this line, pointing out the importance of enhancing both chemical and electronic sensitization by incorporating intentional impurities (e.g., doping) or modifying the surface of traditional gas-sensitive MOXs [6,8].
Tin dioxide (SnO 2 ) is considered as one of the leading n-type MOXs used in commercial chemoresistive gas sensors, however, the enhancement of its sensing performance remains active to date [9,10]. As mentioned above for other MOXs, a large series of reports has also emphasized the remarkable improvement of SnO 2 sensing characteristics, whether by adding catalysts, introducing functional activators, or doping with impurities [5,10,11]. The latter has proved to be an efficient way to create more oxygen vacancies and to amplify the electrochemical reaction of analytes on the layer's surface [7,12].
In the literature, there are several examples of noble metals (Pd, Pt), rare earth metals (Ce, Pr), and metals (Zn, Al) improving the sensitivity and selectivity of various MOXs including SnO 2 [10,[12][13][14][15][16]. Among these materials, magnesium (Mg) is attractive, as it has proved to improve sensitivity to ethanol, H 2 , CO, and ammonia when incorporated into ZnO to form Mg-doped ZnO [17][18][19][20][21]. Similarly, Mg-doped TiO 2 and Mg-doped In 2 O 3 have shown to improve sensitivity to CO and ethanol, respectively [3,22]. Mg is also considered a promising candidate to enhance SnO 2 sensing properties, particularly as it presents a close ionic radius (0.67 nm) to that of Sn (0.71 nm), which facilitates Mg 2+ diffusion into the SnO 2 cell to substitute Sn 4+ [23]. Despite this, the use of Mg-doped SnO 2 in gas sensing, particularly VOC sensing, is not that common in the state-of-the-art.
In the midst of various techniques used to synthesize doped MOX films, spray pyrolysis proved to be simple, cost effective and allowed a wide variety of substrate coatings [24]. Despite the fact that controlling the size and rate of sprayed droplets remains a challenging factor for films' quality, spray pyrolysis is considered a useful method for the design and development of chemoresistive gas sensors [24,25].
Previously, we proved the spray pyrolysis deposition of SnO 2 films and their potential to detect vapors such as ethanol, methanol and acetone [26]. Herein, we go further into this line and investigate the influence of Mg doping levels on the VOC sensing properties of SnO 2 thin films synthesized via the spray pyrolysis process. This work explores the structural, morphological, and chemical composition properties of the films and their gas sensing properties towards ethanol, acetone and toluene.

Thin Film Synthesis and Processing
Magnesium-doped tin dioxide thin films with three doping concentrations (0.8, 1.2, and 1.6 at.%) were synthesized by spray pyrolysis method on cleaned amorphous glass substrate (70 × 30 × 1 mm) at 400 • C. To obtain a 0.8 at.% Mg-doped SnO 2 film, a mixture of 1088 mg of tin (II) chloride dihydrate (SnCl 2 ·2H 2 O, Sigma-Aldrich, 98%), 40 mg of magnesium chloride hexahydrate (MgCl 2 -6H 2 O, Sigma-Aldrich, 99%), and 100 mL of ethanol (Sigma-Aldrich, 96%) was stirred under heat for 30 min. Afterwards, this solution was sprayed by a nozzle to the heated substrate using airflow (0.5 mL/min) for 30 min. The same process was used to prepare all films, varying the weight ratio of the precursors according to the doping concentrations. The as-prepared Mg-doped SnO 2 thin films were subsequently annealed at 450 • C in dry air for 60 min in order to ensure the stability of the materials during the gas sensing test. The influence of the annealing temperatures on the SnO 2 thin films' properties was reported in our previous work [27]. Finally, the coated samples were cut into parts (10 × 15 × 1 mm) to be used for characterization and gas tests.

Characterization Methods
Structural characterization was performed using an X-ray Diffractometer (XRD-Bruker-AXS, LinxEye XE-T detector, KFL Cu 2K (λ (CuKα) = 1.541840 Å) operated at 40 KV and 40 mA) in the 2θ angle from 20 • to 80 • . XPowder software was employed to refine (peak position, lattice parameters, and crystallites size) the data. The surface morphology was examined by Scanning Electron Microscopy (SEM-Carl Zeiss, Auriga Series) equipped with an EDX spectrometer (Energy Dispersive X-ray Spectroscopy) for elemental composition analysis. The surface properties of the films were analyzed using X-ray Photoelectron Spectroscopy (XPS-Kratos Axis Supra with monochromatic Al Kα X-ray radiation, emission current of 15 mA and hybrid lens mode, Manchester, UK) varying the binding energy (BE) range between 0−1350 eV and using CasaXPS for peaks fitting.

Gas Sensing Measurements
To evaluate the gas sensing properties of Mg-doped SnO 2 thin films towards various gaseous analytes (ethanol, acetone, and toluene), we used the system represented in Figure 1 and reported previously [28]. Briefly, the system consists of a continuous gas supply (dry synthetic air and different calibrated gas analytes) controlled by mass flow controllers (MFC), a test chamber equipped with two probes as the electrical signal collectors, a heating plate with a temperature controller, and a data acquisition system (electronic measurement system, electrometer, and PC). The films were exposed to each analyte for 10 min, and after that, the chamber was purged with synthetic air for 30 min to recover the initial base line resistance. Gas test measurements were recorded fixing the operating temperature (T op ) to 160 • C and varying the analyte concentration from 10 to 80 ppm. The gas response is defined as R a /R g (reducing gases), where R a and R g are the resistances of the film in dry air and after exposure to analyte, respectively, while sensitivity (S), is the report between response and gas concentration (∆R/∆C) [7]. The response and recovery times are defined as the time required for the sensor to reach 90% of the response upon exposure to the target gas, and the time required for a sensor to return to 90% of the original baseline signal upon removal of the target gas, respectively. All samples were alternatively tested towards the target analytes in dry air accumulating a total operating period of 120 h distributed over 30 days. Among these hours, on average, each sample operated for about 20 h. Hereafter, the tested films are labeled as MTO1 (0.8 at.% magnesium-doped tin dioxide), MTO2 (1.2 at.% magnesium-doped tin dioxide), and MTO3 (1.6 at.% magnesium-doped tin dioxide). Microscopy (SEM-Carl Zeiss, Auriga Series) equipped with an EDX spectrometer (Energy Dispersive X-Ray Spectroscopy) for elemental composition analysis. The surface properties of the films were analyzed using X-Ray Photoelectron Spectroscopy (XPS-Kratos Axis Supra with monochromatic Al Kα X-ray radiation, emission current of 15 mA and hybrid lens mode, Manchester, UK) varying the binding energy (BE) range between 0−1350 eV and using CasaXPS for peaks fitting.

Gas Sensing Measurements
To evaluate the gas sensing properties of Mg-doped SnO2 thin films towards various gaseous analytes (ethanol, acetone, and toluene), we used the system represented in Figure 1 and reported previously [28]. Briefly, the system consists of a continuous gas supply (dry synthetic air and different calibrated gas analytes) controlled by mass flow controllers (MFC), a test chamber equipped with two probes as the electrical signal collectors, a heating plate with a temperature controller, and a data acquisition system (electronic measurement system, electrometer, and PC). The films were exposed to each analyte for 10 min, and after that, the chamber was purged with synthetic air for 30 min to recover the initial base line resistance. Gas test measurements were recorded fixing the operating temperature (Top) to 160°C and varying the analyte concentration from 10 to 80 ppm. The gas response is defined as Ra/Rg (reducing gases), where Ra and Rg are the resistances of the film in dry air and after exposure to analyte, respectively, while sensitivity (S), is the report between response and gas concentration (∆R/∆C) [7]. The response and recovery times are defined as the time required for the sensor to reach 90% of the response upon exposure to the target gas, and the time required for a sensor to return to 90% of the original baseline signal upon removal of the target gas, respectively. All samples were alternatively tested towards the target analytes in dry air accumulating a total operating period of 120 hours distributed over 30 days. Among these hours, on average, each sample operated for about 20 hours. Hereafter, the tested films are labeled as MTO1 (0.8 at.% magnesiumdoped tin dioxide), MTO2 (1.2 at.% magnesium-doped tin dioxide), and MTO3 (1.6 at.% magnesiumdoped tin dioxide).

Films Analysis and Characterization
X-Ray diffraction patterns were evaluated to gain insight into the crystal structure of the Mgdoped SnO2 thin films. As exhibited in Figure 2, all films are polycrystalline in nature and crystallize in rutile tetragonal tin dioxide (SnO2) structure (P42/mnm space group, ICDD card 72−1147) with a dominant (110) diffraction at 26.53° 2θ approximately. In general, the results show a steady decrease of all SnO2 diffraction peaks accompanied by a diffraction pattern shift to lower angle values (>0.06°

Films Analysis and Characterization
X-ray diffraction patterns were evaluated to gain insight into the crystal structure of the Mg-doped SnO 2 thin films. As exhibited in Figure 2, all films are polycrystalline in nature and crystallize in rutile tetragonal tin dioxide (SnO 2 ) structure (P4 2 /mnm space group, ICDD card 72−1147) with a dominant (110) diffraction at 26.53 • 2θ approximately. In general, the results show a steady decrease of all SnO 2 diffraction peaks accompanied by a diffraction pattern shift to lower angle values (>0.06 • 2θ) as the Mg amount increases in the films. This could be caused in part by the diffusion of Mg 2+ ions into the SnO 2 lattice and the smaller ionic radii of the guest atom (Mg 2+ : 0.67 Å) compared to the host atom (Sn 4+ : 0.71 Å), and also by the lower electronic density of Mg atoms (1.738 g/cm 3 ) compared to Sn atoms (β−Sn = 7.265 g/cm 3 ). The results also indicate a change in the lattice parameters of the Mg-doped SnO 2 thin films (Table 1), which reveal a slight increase in "a" and decrease in "c", compared to the non-doped SnO 2 film reported in our previous work [27]. In addition, a proportional decrease of the average crystallite size (D) with the increase of the Mg-doping levels can also be observed in Table 1. Overall, these properties suggest the presence of local lattice disorders in the films and, in turn, an increment of surface defects in the Mg-doped samples with respect to the non-doped samples, as noticed earlier in the literature [29].
Sensors 2020, 20, x FOR PEER REVIEW 4 of 17 host atom (Sn 4+ : 0.71 Å ), and also by the lower electronic density of Mg atoms (1.738 g/cm 3 ) compared to Sn atoms (β−Sn = 7.265 g/cm 3 ). The results also indicate a change in the lattice parameters of the Mg-doped SnO2 thin films (Table 1), which reveal a slight increase in "a" and decrease in "c", compared to the non-doped SnO2 film reported in our previous work [27]. In addition, a proportional decrease of the average crystallite size (D) with the increase of the Mg-doping levels can also be observed in Table 1. Overall, these properties suggest the presence of local lattice disorders in the films and, in turn, an increment of surface defects in the Mg-doped samples with respect to the nondoped samples, as noticed earlier in the literature [29]. The 'extra' diffraction peak at 43.8° 2θ in the MTO3 pattern is associated with the (200) reflection of MgO in halite structure (ICDD 75−1525). The presence of this diffraction suggests an excess of Mg (over-doping) in MTO3 and the formation of a secondary phase. This is consistent with the unit cell parameters found for MTO3 (Table 1), which show no further change with respect to MTO2, and endorse the fact that the substitution process goes to its saturation. These observations are in agreement with previous reports on Mg-doped SnO2 by the sol-gel process [30]. Moreover, the Mgdoped SnO2 patterns also revealed additional diffraction peaks referring to the formation of NaCl crystals (ICDD 05−0628) on the matrix of the films. This could be attributed to the combination of sodium ions (diffused from the glass substrate) and chloride ions (from the metal chloride precursor) to form NaCl crystals [31].

Sample
Unit cell parameters Unit cell volume Average crystallite size  The 'extra' diffraction peak at 43.8 • 2θ in the MTO3 pattern is associated with the (200) reflection of MgO in halite structure (ICDD 75−1525). The presence of this diffraction suggests an excess of Mg (over-doping) in MTO3 and the formation of a secondary phase. This is consistent with the unit cell parameters found for MTO3 (Table 1), which show no further change with respect to MTO2, and endorse the fact that the substitution process goes to its saturation. These observations are in agreement with previous reports on Mg-doped SnO 2 by the sol-gel process [30]. Moreover, the Mg-doped SnO 2 Sensors 2020, 20, 2158 5 of 18 patterns also revealed additional diffraction peaks referring to the formation of NaCl crystals (ICDD 05−0628) on the matrix of the films. This could be attributed to the combination of sodium ions (diffused from the glass substrate) and chloride ions (from the metal chloride precursor) to form NaCl crystals [31]. Table 1. Lattice parameters and average crystalline size of the Mg-doped SnO 2 thin films.

Sample
Unit Cell Parameters Unit Cell Volume Average Crystallite Size     The presence of other elements, such as Si and Na (associated with the use of glass substrate), and Cl (related to the chloride-based precursors), are also registered and in line with the XRD results. Further properties of the elements at the surface of the films were investigated by XPS. Figure 4 displays the survey XPS spectrum for each film (i.e., MTO1, MTO2 and MTO3). These spectra show a sharp and intense XPS core level Sn 3d and O 1s peaks around 486.5 eV and 530.3 eV, respectively. The spectra also show minor peaks for Sn 4d 3/2 , Sn 4p, Sn 4s, C 1s, Mg KLL, Sn 3p 3/2 , Sn 3p 1/2 , Sn 3s, O KLL, Sn MNN, and Mg 1s. Na KLL and Cl 2p peaks are also identified in the spectra in concordance with the XRD and EDS results.   Figure 5 shows the deconvolution of O 1s and Sn 3d XPS core level spectra recorded on the films. The O 1s core level peak exhibits slight asymmetry with a distinct shoulder in all the investigated samples suggesting the presence of three components ( Figure 5). The main component centered at ~530.3 eV is assigned to lattice oxygen (OL) (oxygen directly bounded to a metal atom) [32]. The two other components, found at higher binding energy ~531.6 and ~532.4 eV, are connected with the oxygen vacancies (OV) mandatory for charge compensation after doping and the chemosorbed oxygen (OChem), respectively, as in the previous literature [33].
The Sn 3d region of the three samples ( Figure 5) presents doublets at 486.5 and 494.9 eV for Sn 3d5/2 and Sn 3d3/2, respectively. According to the literature [32], the three oxidation states of Sn atoms are defined by three binding energy values as the following Sn 0 (485.0 eV), Sn 2+ (485.9 eV), and Sn 4+ (486.6 eV). Our results indicate the absence of Sn 0 and Sn 2+ within the films and therefore confirm the Sn 4+ oxidation state and the formation of SnO2 by spray pyrolysis.
XPS results also show the Mg 1s core level peak and the Mg KLL Auger emission peak. Estimation of the content of Mg at the samples indicate lower contents for MOT1 and MTO2 (~0.7 at.%) respect to MTO3 (~1 at.%). The results in Figure 6a show the Mg 1s spectrum for the MTO1 and MTO2 films at a lower energy (~1303.6 eV) than that recorded for the MTO3 films, which display a shift to a higher energy (~1303.8 eV) most likely due to the oxidation of Mg [30,34]. The Mg KLL  Figure 5 shows the deconvolution of O 1s and Sn 3d XPS core level spectra recorded on the films. The O 1s core level peak exhibits slight asymmetry with a distinct shoulder in all the investigated samples suggesting the presence of three components ( Figure 5). The main component centered at 530.3 eV is assigned to lattice oxygen (O L ) (oxygen directly bounded to a metal atom) [32]. The two other components, found at higher binding energy~531.6 and~532.4 eV, are connected with the oxygen vacancies (O V ) mandatory for charge compensation after doping and the chemosorbed oxygen (O Chem ), respectively, as in the previous literature [33].
The Sn 3d region of the three samples ( Figure 5) presents doublets at 486.5 and 494.9 eV for Sn 3d 5/2 and Sn 3d 3/2 , respectively. According to the literature [32], the three oxidation states of Sn atoms are defined by three binding energy values as the following Sn 0 (485.0 eV), Sn 2+ (485.9 eV), and Sn 4+ (486.6 eV). Our results indicate the absence of Sn 0 and Sn 2+ within the films and therefore confirm the Sn 4+ oxidation state and the formation of SnO 2 by spray pyrolysis.   XPS results also show the Mg 1s core level peak and the Mg KLL Auger emission peak. Estimation of the content of Mg at the samples indicate lower contents for MOT1 and MTO2 (~0.7 at.%) respect to MTO3 (~1 at.%). The results in Figure 6a show the Mg 1s spectrum for the MTO1 and MTO2 films at a lower energy (~1303.6 eV) than that recorded for the MTO3 films, which display a shift to a higher energy (~1303.8 eV) most likely due to the oxidation of Mg [30,34]. The Mg KLL Auger spectrum (Figure 6b-d) supports this fact by showing a component associated to Mg metal in the three samples and a second component (only present in the MTO3 films and shifted 5.2 eV to higher energy) assigned to Mg oxide [35,36]. These results are in line with the MgO diffractions identified by XRD ( Figure 2).
Overall, the analysis of the material demonstrates the formation of Mg-doped SnO 2 . These results indicate that the morphological differences in the films (i.e., MTO1, MTO2, and MTO3) are attributed to the variation of Mg doping level in the SnO 2 films. The incorporation of the Mg precursor in the spray solution affects the nucleation process and growth conditions of the films. This also slightly deviates the crystalline structure of the doped films (with respect to pristine SnO 2 ) and, therefore, the film morphology. As the doping reaches a saturation point, the alloy system tends to dissociate and a second phase material emerges (i.e., MgO) causing further change in the growth mechanism and the film morphology. Previously, other authors also observed morphological changes in SnO 2 and ZnO films due to Eu (europium) [37] and Mg doping [38], respectively, and the formation of a MgO second phase material.

Gas Sensing Properties
Non-doped and Mg-doped SnO 2 films were exposed consecutively to various reductive gases (ethanol, acetone, and toluene) in a concentration of 80 ppm at an operating temperature (T op ) of 160 • C. A summary of the response to each analyte and each sample is presented in Figure 7a. These results reveal low responses for the non-doped SnO 2 film compared to the Mg-doped SnO 2 , which show higher responses to the target analytes as the Mg percentage increases in the films (e.g., MTO3 film response to ethanol is almost fourteen times higher than SnO 2 film). In contrast, the response time ( Figure 7b) shows a decreasing trend as the Mg percentage increases in the films. Generally, the electrical measurements also revealed an increase of the film electrical resistance by more than five orders of magnitude as the Mg percentage increases from 0 at.% to 1.6 at.%. In addition, the dynamic response to ethanol (Figure 8a) displayed a more reproducible and stable signal for the Mg-doped films compared to the non-doped film, particularly for those doped with a higher Mg concentration (MTO3). Similarly, the dynamic response to acetone and toluene showed reproducible and stable signals as shown in (Figure 8b) for the MTO3 samples. The results in Figures 7 and 8b also show better responses towards ethanol than to acetone and toluene, in proportion to the increase of Mg doping. For instance, the MTO3 film responses were 13.5, 3.1, and 2.3 for a concentration of 80 ppm of ethanol, acetone, and toluene, respectively.
Further testing of the Mg-doped SnO 2 films to various concentrations of ethanol (highest response) and toluene (lowest response) from 10 ppm to 80 ppm displayed a proportional increase of the response with the gas concentration (Figures 9 and 10). We also observe that by increasing the Mg percentage from 0.8 at.% (MTO1) to 1.6 at.% (MTO3), the response to ethanol increases by two times (from 1.6 to 3) for 10 ppm and by four times (from 3.2 to 13.5) for 80 ppm. Coincidently, we note that the response to ethanol obtained from the MTO1 film to 80 ppm is almost equal to the response obtained from the MTO3 film to 10 ppm. The same behavior, although with lower enhancement than that observed for ethanol, was observed for toluene. Hence, these results demonstrate a major enhancement of the response with the increase of Mg doping in SnO 2 film, especially towards ethanol. films compared to the non-doped film, particularly for those doped with a higher Mg concentration (MTO3). Similarly, the dynamic response to acetone and toluene showed reproducible and stable signals as shown in (Figure 8b) for the MTO3 samples. The results in Figures 7 and 8b also show better responses towards ethanol than to acetone and toluene, in proportion to the increase of Mg doping. For instance, the MTO3 film responses were 13.5, 3.1, and 2.3 for a concentration of 80 ppm of ethanol, acetone, and toluene, respectively. Further testing of the Mg-doped SnO2 films to various concentrations of ethanol (highest response) and toluene (lowest response) from 10 ppm to 80 ppm displayed a proportional increase of the response with the gas concentration (Figures 9 and 10). We also observe that by increasing the Mg percentage from 0.8 at.% (MTO1) to 1.6 at.% (MTO3), the response to ethanol increases by two times (from 1.6 to 3) for 10 ppm and by four times (from 3.2 to 13.5) for 80 ppm. Coincidently, we note that the response to ethanol obtained from the MTO1 film to 80 ppm is almost equal to the response obtained from the MTO3 film to 10 ppm. The same behavior, although with lower enhancement than that observed for ethanol, was observed for toluene. Hence, these results demonstrate a major enhancement of the response with the increase of Mg doping in SnO2 film, especially towards ethanol.  Similarly, the film doping level also influences the sensitivity of the films (Figure 11), which could be favorable for tuning of the cross-sensitivity (∆S). Thus, we observed lower cross-sensitivity and in turn, better selectivity between ethanol and toluene for the samples with higher doping levels (∆S = 8.8 for MTO2 and ∆S = 13.9 for MTO3) as compared to the sample with low doping concentration (∆S = 1.6 for MTO1). Thus, the results suggest partial selectivity to ethanol, particularly for the MTO3 films.
Further analysis of the dynamic response of the films (Figure 9) shows that the response time ( Figure 12) for ethanol and toluene is inversely related to the gas concentration in both cases. For instance, for ethanol at 80 ppm, the response time decreases from 233 s (MTO1) to 143 s (MTO3), which is 90 s faster, by doubling the Mg percentage in the SnO 2 film (from 0.8 at.% to 1.6 at.%). Similar behavior is observed for toluene with a response time decrease of 59 s for MTO3 with respect to MTO1. The results also show a complete recovery of the base line in the three systems, which is accelerated by increasing the Mg percentage in the films (Figure 9).
Overall, the films displayed a low drift of the baseline resistance during each test, most likely connected with the low operating temperature. Despite this, the response magnitudes did not show significant changes. Generally, the MTO3 films showed better medium-term stability displaying 8% and 6% less deviation in the base line resistance during the whole testing period (see experimental section) compared to the MTO1 and MTO2 films, respectively. Further analysis after the testing period and after having exposed the films to all target analytes showed no significant changes in the main core levels XPS spectrum of tin, magnesium, and oxygen, supporting the stability of the film.   Similarly, the film doping level also influences the sensitivity of the films (Figure 11), which could be favorable for tuning of the cross-sensitivity (ΔS). Thus, we observed lower cross-sensitivity and in turn, better selectivity between ethanol and toluene for the samples with higher doping levels (ΔS = 8.8 for MTO2 and ΔS = 13.9 for MTO3) as compared to the sample with low doping concentration (ΔS = 1.6 for MTO1). Thus, the results suggest partial selectivity to ethanol, particularly for the MTO3 films.  Table 2 presents a comparison of our results and those for other materials in the literature. The table summarizes the material synthesis method, testing conditions (concentration, operating temperature), and response reported to ethanol and toluene. In this summary, one can notice the use of various materials for sensing both gases, including intrinsic oxides (e.g., SnO 2 , WO 3 , Fe 2 O 3 ) and modified (e.g., SnO 2 /ZnO, SnO 2 /MgAl 2 O 4 ) or doped (Mg-doped ZnO, Pr-doped SnO 2 ) oxides. Despite the comparison of the data being complex, as gas sensing results depend on not only the sensing material but also the test conditions, we consider these data still meaningful to offer a general idea of the properties of our samples. Overall, we observe that our results are in agreement with the literature and that the responses recorded to ethanol and toluene with our samples are higher or in the same order at a comparatively lower operating temperature (160 • C) and lower concentration (80 ppm) than other works (which show operating temperatures above 200 • C and typically concentrations of 100 ppm). The response time recorded for the works in the literature is in general in the same order of magnitude (hundreds of seconds) as for our films. Table 2 also includes an example of a similar system (i.e., Mg-doped SnO 2 via spray pyrolysis) although tested towards a different analyte (LPG-liquid petroleum gas). The response (1.4) of this system to 1000 ppm of LPG was registered at 285 • C. Similarly, the film doping level also influences the sensitivity of the films (Figure 11), which could be favorable for tuning of the cross-sensitivity (ΔS). Thus, we observed lower cross-sensitivity and in turn, better selectivity between ethanol and toluene for the samples with higher doping levels (ΔS = 8.8 for MTO2 and ΔS = 13.9 for MTO3) as compared to the sample with low doping concentration (ΔS = 1.6 for MTO1). Thus, the results suggest partial selectivity to ethanol, particularly for the MTO3 films. Further analysis of the dynamic response of the films (Figure 9) shows that the response time ( Figure 12) for ethanol and toluene is inversely related to the gas concentration in both cases. For instance, for ethanol at 80 ppm, the response time decreases from 233 s (MTO1) to 143 s (MTO3), which is 90 s faster, by doubling the Mg percentage in the SnO2 film (from 0.8 at.% to 1.6 at.%). Similar behavior is observed for toluene with a response time decrease of 59 s for MTO3 with respect to MTO1. The results also show a complete recovery of the base line in the three systems, which is accelerated by increasing the Mg percentage in the films (Figure 9). Overall, the films displayed a low drift of the baseline resistance during each test, most likely connected with the low operating temperature. Despite this, the response magnitudes did not show significant changes. Generally, the MTO3 films showed better medium-term stability displaying 8% and 6% less deviation in the base line resistance during the whole testing period (see experimental

Gas Sensing Mechanism
Generally, the gas sensing results showed that all films behave as typical n-type semiconductors when exposed to gases, i.e., decreasing the overall electrical resistance in the presence of reducing gases such as ethanol, acetone, and toluene. This is consistence with the most accepted sensing mechanism model proposed in the literature for pristine metal oxides including SnO 2 [46]. According to this model (Figure 13a), when SnO 2 film is exposed to air, oxygen molecules are adsorbed at the surface and form oxygen ions [47,48] (in our case O 2 − is formed because the operating temperature is 160 • C [11]), thus extracting electrons from the conduction band. As a result of this electron transfer, a depletion layer is formed and the film electrical resistance is increased. As soon as SnO 2 film is exposed to a desired concentration of a reducing gas, such as ethanol, acetone or toluene, the reductive gas molecules will interact with oxygen negative ions and transfer the electrons back to the SnO 2 conductive band. Therefore, the depletion layer narrows and the film electrical resistance decreases [46].
Sensors 2020, 20, x FOR PEER REVIEW 13 of 17 surface and form oxygen ions [47][48] (in our case O2 ‾ is formed because the operating temperature is 160°C [11]), thus extracting electrons from the conduction band. As a result of this electron transfer, a depletion layer is formed and the film electrical resistance is increased. As soon as SnO2 film is exposed to a desired concentration of a reducing gas, such as ethanol, acetone or toluene, the reductive gas molecules will interact with oxygen negative ions and transfer the electrons back to the SnO2 conductive band. Therefore, the depletion layer narrows and the film electrical resistance decreases [46]. This mechanism is similar for the Mg-doped films (Figure 13b). However, in this system the incorporation of Mg into the SnO2 structure enhances the sensing mechanism due to the lattice disorder introduced by the substitution of Sn 4+ ions by Mg 2+ ions and the subsequent diminution of the crystallite size by nearly three times with respect to the pristine SnO2 films (Table 1). Then, more reactive oxygen molecules are adsorbed in the pre-adsorption cycle and available to interact with the reductive gases [16,49].
The mechanism for the over-doped films (Figure 13c), however, includes a new component, introduced by the second phase particles (i.e., MgO) rather than by the change in crystalline size (notice the crystallite size of MTO1, MTO2, and MTO3 is similar). The presence of second phase particles with low loadings enhances further the sensing mechanism via a 'spillover effect' [50], which can be connected with the faster response and recovery time of MTO3 with respect to MTO2 and MTO1. The second phase particles also introduce an extra potential barrier formed between the MgO and Mg-doped SnO2 (heterojunction). This extra potential barrier may accumulate or deplete extra- Figure 13. Schematic representation of the gas sensing mechanisms of (a) non-doped and (b and c) Mg-doped SnO 2 films in air (left) and reductive gas (right). E CB is the bottom of conduction band; E F is the bulk Fermi level; E VB is the top of valence band; ∆Φ is the built-in potential barrier; Xn, and Xn 2 are depth of the depletion layer from the surface; Xn 1 is the depth of the accumulation layer from the surface (not to scale). This mechanism is similar for the Mg-doped films (Figure 13b). However, in this system the incorporation of Mg into the SnO 2 structure enhances the sensing mechanism due to the lattice disorder introduced by the substitution of Sn 4+ ions by Mg 2+ ions and the subsequent diminution of the crystallite size by nearly three times with respect to the pristine SnO 2 films (Table 1). Then, more reactive oxygen molecules are adsorbed in the pre-adsorption cycle and available to interact with the reductive gases [16,49].
The mechanism for the over-doped films (Figure 13c), however, includes a new component, introduced by the second phase particles (i.e., MgO) rather than by the change in crystalline size (notice the crystallite size of MTO1, MTO2, and MTO3 is similar). The presence of second phase particles with low loadings enhances further the sensing mechanism via a 'spillover effect' [50], which can be connected with the faster response and recovery time of MTO3 with respect to MTO2 and MTO1. The second phase particles also introduce an extra potential barrier formed between the MgO and Mg-doped SnO 2 (heterojunction). This extra potential barrier may accumulate or deplete extra-pre-adsorbed oxygen in the boundary grain to grain, thus maximizing the electrical resistance change in the gas (analyte) adsorption stage, as noticed earlier for other gas sensitive materials with nanoscaled heterojunctions [6,51].
On the other hand, the visibly different morphologies in the films, as result of the Mg doping, could also play a role in the sensing performance by providing a different electrical percolation and possible fluctuations (noise) in the grain boundaries. Although the current dc measurements do not give evidence of the level of these fluctuations, we cannot rule out the presence of a parallel mechanism dependent on the grain boundaries, as noticed previously for ethanol and hydrogen by low-frequency noise measurements [52].

Conclusions
Mg-doped SnO 2 thin films synthesized via a spray pyrolysis method were investigated for ethanol, acetone, and toluene sensing. Overall, the Mg-doped SnO 2 films proved a more reproducible sensing behavior with complete recovery of the base line resistance compared to the non-doped SnO 2 films. This paper proposes that increasing the Mg-doping level (from 0.8 at.% to 1.6 at.%) is responsible for the improvement of the sensing properties due to the decrease in the crystallites' size and to the increase in defects in the SnO 2 films. The results indicate that this remarkable improvement is also connected with the formation of MgO, which favors the spillover effects at the film and incorporates extra potential barriers formed between the MgO and the Mg-doped SnO 2 grains. Both components (i.e., size reduction and the incorporation of MgO) play an important role in enhancing the ethanol sensing behavior of SnO 2 , and thus, the response of the 1.6 at.% Mg-doped SnO 2 films is four times higher and 90 s faster than the response of the 0.8 at.% Mg-doped SnO 2 films.