1 Introduction

With each breath exhaled thousands of molecules are expelled, providing a window into the physiological state of the body [1]. The utilization of breath as a medical test is based on the fact that there is a significant correlation between some diseases and specific concentrations of some gases or vapors called biomarkers [1,2,3]. The breath analysis is a powerful tool for clinical diagnostics because it is noninvasive, painless, cost-effective, and easily repeated [4,5,6,7,8]. Metal oxide semiconductors (MOSs) are an attractive option as a breath analysis device because they are cheap, compact, robust, sensitive, and allow for real-time measurements [3]. In using the MOS sensors as a breath analysis device, there are two main challenges: first, selectivity of the sensor while the human breath is a mixture of more than thousand gases and volatile vapors with different concentrations (ranging from several ppb to several ppm) [4, 9] and second, good performance of the sensor at high humidity when relative humidity (RH) of the human breath is more than 80% [10]. Ammonia is one of the biomarkers present in the human breath and its increase might be related to bacterial production in the oral cavity, kidney disease, hepatic encephalopathy or infection with Helicobacter pylori [4]. Many researchers have been using different metal oxide semiconductors to detect the ammonia gas. Some well-known of these materials are SnO2, ZnO, V2O5, ITO, WO3, MoO3 and TiO2 [11, 12]. But according to the literature [12,13,14,15,16,17], it seems that the pure and doped ZnO in different forms can be a good candidate to sense the ammonia gas due to their high and fast response and low operating temperature. In recent years, various researchers have been using different metal additives and have changed the growth parameters to engineer the band gap, electrical properties, and subsequently to improve the ammonia gas sensing performance of the ZnO thin films. Mani et al. [13] deposited the undoped and copper-doped zinc oxide thin films using spray pyrolysis technique and investigated structural, morphological, optical, and ammonia gas sensing properties of the samples. Trawal et al. [14] used different concentrations of cadmium (1–5 at%) as the dopant. They employed spray pyrolysis technique to deposit the pure and Cd-doped ZnO thin films and studied the structural, morphological, and ammonia gas sensing properties. Mani et al. [15] also reported the deposition of nano-structured pure and Ni-doped ZnO thin films by spray pyrolysis technique. They showed that the Ni-doping greatly affected the crystallographic orientation, surface morphology, roughness, and ammonia sensing response of the samples. Kulandaisamy et al. [16] studied the effect of Mg doping on the ammonia sensing properties of ZnO thin films. They grew the samples with different Mg molars by spray pyrolysis method. Mariappan et al. [17] also studied the role of substrate temperature on the structural, morphological, and ammonia gas sensing properties of Na-doped ZnO thin films. They employed the spray pyrolysis technique. The results of the above-mentioned published works are summarized in Table 1. With an overview on the above-mentioned (and not mentioned) published works, it can be deduced that the Mg-doped ZnO thin film presents a good ammonia sensing performance at room temperature and may be a suitable candidate as a breath analysis sensor. Furthermore, it seems that the effect of the high-relative humidity on sensing performance of the pure and doped ZnO thin films has seldom been studied while the sensitivity, selectivity and reliability at high RH play a vital role at the breath analysis sensors. In our earlier work [18], we studied the ammonia gas sensing properties of Mg-doped ZnO thin films at room temperature and 80% RH as a function of Mg concentration in the range of 0.003–0.009 M. The results of this work revealed that the best sensitivity was attributed to the sample doped with 0.005 M Mg while an increase in Mg concentration resulted in a reduction in sensitivity of the samples. In the current research, based on the results obtained from the previous work, we selected the optimum concentration of Mg (i.e., 0.005 M) and preparation conditions and tried to improve the sensing performance of the Mg-doped ZnO thin films as breath analysis sensor by modifying the substrate temperature.

Table 1 A summary of nanostructure and ammonia gas sensing performance of undoped and doped ZnO thin films (previously published works)

2 Experimental details

A domestic-made spray coating unit was used to deposit the Mg-doped ZnO thin films on glass substrates at different temperatures (125, 250, 375, 500 °C). Prior to deposition, the substrates were ultrasonically cleaned in acetone then ethanol and dried with the flow of argon. Zinc acetate dihydrate [(Zn (CH3COO)2∙2H2O) of 0.1 M, Sigma-Aldrich, purity 99%, USA] and (0.005 M) magnesium nitrate hexahydrate [(Mg (NO3)2∙6H2O), Merck, 99% purity, USA] were used as precursor salts according to literature [16, 18]. The spray solution was also prepared according to the mentioned literature [16, 18] by dissolving required amount of zinc acetate dihydrate and magnesium nitrate hexahydrate salts in 50 mL of deionized water and stirred continuously for 1 h. The distance between the nozzle and the substrate was 15 cm and the flow rate of the solution was 5 ml/min. The nozzle size was also 0.5 mm. Four different deposition processes were performed at various substrate temperatures (125, 250, 375, 500 °C) while the other deposition parameters were constant. To prepare each sample five steps deposition process with the interval time of 60 s were done. The substrate temperature was controlled using a thermostat which was equipped with a thermocouple with an accuracy of ± 3 °C.

To study the crystallographic structure of the samples, X-ray diffraction (XRD) data of the Mg-doped ZnO thin films prepared in this work were collected using a Philips XRD X’pert MPD Diffractometer (Cu Kα radiation) with a step size of 0.02° and step time of 1 s.

The physical surface morphology of the samples was observed with an atomic force microscope (AFM) (Auto probe PC, Park Scientific Instrument, USA) while the thickness was measured using an Alpha-step profilometer. The morphological features, thickness, and chemical composition of the samples were also checked using field emission scanning electron microscope (FESEM) (CamScan MV 2300, Czech and England).

The investigation of the gas sensing properties of the samples was performed at a temperature and moisture controlled test chamber (AES-4TH Testing System, Beijing Elite Tech Co., Ltd). The electrical resistance of the samples was measured in the air and presence of ammonia gas at room temperature (RT) and relative humidity (RH) of 80%. The deviation of the relative humidity (RH) during measurement was 2%. The mentioned value of RH (i.e., 80%) was selected because exhaled breath RH is near to this value [19].

The response is defined as the ratio of the electrical resistance in the air (Ra) to that in the mixture of detected gas and air (Rg) as follows [16]:

$$S={\text{ }}{R_{\text{a}}}/{R_{\text{g}}}$$
(1)

Response and recovery time was also estimated as the time taken for the sensor output to reach 90% of its saturation after applying or switching off the target gas in a step function. The calculating method of concentration and injection volume for gas can be also found elsewhere [20].

3 Results and discussion

3.1 Thickness measurement

In the first step of the structural analyses, the dependence of the film thickness on the substrate temperature was investigated. The variation of the film thickness as a function of substrate temperature is shown in Fig. 1. As can be seen, an increase in the substrate temperature causes a decrease in the film thickness. This reduction can be attributed to (1) incomplete thermal decomposition of the spray droplets, and (2) re-evaporation of the initial constituent at higher substrate temperature.

Fig. 1
figure 1

Thickness values of the Mg-doped ZnO thin films deposited by spray pyrolysis technique as a function of substrate temperature

3.2 Crystallographic structure

The XRD spectra of the Mg-doped ZnO thin films deposited on glass substrates at different temperatures are depicted in Fig. 2 while the numerical data of this analysis are listed in Table 2. It can be observed that all samples show five diffraction lines corresponding to (100), (002), (101), (110), and (103) crystallographic orientations with reference to JCPDS Card no.: 36-1451. These patterns confirm that all samples are polycrystalline with hexagonal wurtzite structure. No phase detection corresponding to Mg and MgO can be also due to the low concentration of Mg doping and confirm that doping is within the solubility limit. With attention to the patterns, it can be seen that the intensity and the full width at half maximum (FWHM) of the peaks change with an increase in the substrate temperature. For a closer look at these observations, the texture coefficient (TC) and the crystallite size (D) are calculated for main diffraction lines [(100), (002), and (101)] of the samples. TC can be evaluated according to the following equation [14]:

Fig. 2
figure 2

X-ray diffraction patterns of the Mg-doped ZnO thin films deposited by spray pyrolysis technique at different substrate temperatures, a 125 °C, b 250 °C, c 375 °C, d 500°C

Table 2 Details of samples preparation and results of XRD and AFM analyses
$${\text{T}}{{\text{C}}_{(hkl)}}=\frac{{\frac{{{I_{(hkl)}}}}{{{I_{0(hkl)}}}}}}{{\left( {\frac{1}{N}} \right)\mathop \sum \nolimits^{} \frac{{{I_{(hkl)}}}}{{{I_{0(hkl)}}}}}},$$
(2)

where I is the measured intensity, I0 is the standard intensity, and N is the number of the peak. The crystallite size can be also calculated using from Scherer formula [21]:

$$D=\frac{{k\lambda }}{{B\cos \theta }},$$
(3)

where λ is the wavelength of X-ray, θ is the Bragg angle, and k is a dimensionless constant which is related to the shape and distribution of crystallites (usually taken as unity). For obtaining the value for B, we used the usual procedure of full width at half maximum (FWHM) measurement technique [22], therefore:

$$B={\left( {W_{0}^{2} - W{}_{i}^{2}} \right)^{{\raise0.7ex\hbox{$1$} \!\mathord{\left/ {\vphantom {1 2}}\right.\kern-0pt}\!\lower0.7ex\hbox{$2$}}}},$$
(4)

where W0 is the full width at half maximum (FWHM) of the peak of the sample and Wi is the FWHM of stress-free sample (standard SiO2 single crystal sample). The values of the coefficient texture and the crystallite size are given in columns 7 and 8 of Table 2, respectively. As can be seen, the (002) plane is preferred crystal growth orientation of the samples. Furthermore, an increase in the substrate temperature causes an increase in the crystallite size and the values of TC parameter for (002) crystallographic orientation. Higher substrate temperature provides the opportunity to increase the mobility and coalescence due to the diffusion effect which in turn reduce the defects and increase the crystallinity and the crystallite size. The slight decline of the TC parameter of the (002) orientation at the highest substrate temperature (500 °C) may also result from the decrease of the film thickness, and the removal or loss of oxygen at this (high) temperature from the ZnO film structure. The investigation of the peak positions of the samples (column 4 of Table 2) shows that the diffraction lines positions are shifted to higher angles relative to the undoped ZnO sample. This observation provides the necessary information for calculating the nano-strain (ε) in the body of the film [23, 24], using:

$$\varepsilon ={\text{ }}\left( {d - {d_0}} \right)/{d_0},$$
(5)

where d is the plane spacing of the sample (column 9 of Table 2) and d0 is the plane spacing of the standard powder ZnO sample (with reference to JCPDS Card no.: 36-1451). The values of nano-strain (ε) obtained from the diffraction lines positions for the samples are shown in column 10 of Table 2. The results show the compressive strain for all samples, indicating shrinkage of the unit cell. This behavior can result from the smaller ionic radius of Mg2+ (57 pm) compared to Zn2+ (60 pm) [25]. The improvement of the nano-strain at the highest substrate temperature (500 °C) may be also attributed to the enhanced mobility at this temperature as explained earlier.

3.3 Surface morphology

2D and 3D AFM images of the Mg-doped ZnO thin films deposited on glass substrates at different temperatures are shown in Figs. 3 and 4, respectively. Grain size (obtained by JMicrovision code from 2D images) and surface roughness of the samples are also listed in columns 11 and 12 of Table 2, respectively. Consistent with the results of the XRD analysis, an increase in the substrate temperature causes the increasing of the grain size and the surface roughness. However, the surface becomes smoother at the highest substrate temperature (500 °C).

Fig. 3
figure 3

2D AFM images of the Mg-doped ZnO thin films deposited by spray pyrolysis technique at different substrate temperatures, a 125 °C, b 250 °C, c 375 °C, d 500 °C

Fig. 4
figure 4

3D AFM images of the Mg-doped ZnO thin films deposited by spray pyrolysis technique at different substrate temperatures, a 125 °C, b 250 °C, c 375 °C, d 500 °C

The surface morphology and the thickness of the samples were also checked by FESEM analysis. A typical FESEM micrograph of the surface and cross-section of the selected sample namely sample III (deposited at 375 °C) are depicted in Fig. 5. These images are in good agreement with AFM images and thickness measurement by the profilometer.

Fig. 5
figure 5

FESEM micrograph of a the surface and b the cross-section of the selected sample deposited at 375 °C (sample III)

It is also worth mentioning that the observed granular structure by AFM and FESEM images is consistent with the previous reports [12,13,14,15,16] that used the spray pyrolysis technique to deposit the samples and different dopants (Table 1).

3.4 Chemical composition

To confirm the presence of Mg in the samples, the chemical composition of the samples produced in this work was studied using energy dispersive X-ray (EDX) analysis. A typical spectrum of the selected sample (deposited at 375 °C, sample III) is shown in Fig. 6 while there is no significant change in the EDX spectrum of various samples deposited at different substrate temperatures. As can be seen, the peak at 1.253 keV indicates the presence of magnesium and two peaks at 1.012 keV and 0.525 keV validate the presence of zinc and oxygen, respectively.

Fig. 6
figure 6

EDX spectrum of the selected sample deposited at 375 °C (sample III)

3.5 Sensitivity

To investigate the gas sensing performance of the samples, the Mg-doped ZnO thin films deposited at different substrate temperatures were exposed to various concentration of ammonia gas (10, 50, and 100 ppm) at room temperature and 80% RH. Once the sensing elements were exposed to the air atmosphere, electrons in the conduction band of the films were trapped by the ambient oxygen. The depletion layer is formed after extracting electrons and the surface resistance of the sample increases accordingly (baseline resistance for sensing measurements). While exposing the film to ammonia gas of desired concentration levels, a sharp decrease in the surface resistance from the baseline was observed because of the interaction between the surface adsorbed oxygen and the reducing nature of NH3 gas [13, 26]. In fact, the mentioned interaction causes to release electrons back, making the depletion layer thinner. Figure 7 schematically shows the mentioned sensing mechanism. From the variation of film resistance in the air (Ra) and ammonia gas (Rg), the response was calculated using the Eq. (1). The resistance versus time curves of the Mg-doped ZnO thin films deposited at different substrate temperatures are shown in Fig. 8. The obtained data from the curves plotted in Fig. 8, namely response, response time and recovery time, are presented in Fig. 9. It is obvious that an increase in the substrate temperature up to 375 °C results in an increase in the sensitivity of the samples while the response is decreased at the highest temperature (500 °C). It is well-known that the sensitivity of metal oxide semiconductor gas sensors is greatly dependent on micro-structural factors including crystallinity, grain size or grain boundary, surface roughness, film thickness, density, porosity, and effective surface area [27, 28]. So that, the increase of the crystallinity, surface roughness, porosity, and effective surface area has positive effects on the sensitivity, whereas the reduction of the grains size and thickness can improve the sensing performance of the MOSs. In the case of the samples studied in this work, according to Table 2, it seems that the crystallinity, the surface roughness, and the film thickness play the key roles.

Fig. 7
figure 7

The schematic image of sensing mechanism

Fig. 8
figure 8

Resistance versus time curves for the Mg-doped ZnO thin films deposited at different substrate temperatures under different concentrations of ammonia gas (operating temperature: RT and RH: 80%), a 125 °C, b 250 °C, c 375 °C, d 500 °C

Fig. 9
figure 9

a Response, b response time, and c recovery time of the Mg-doped ZnO thin films deposited at different substrate temperatures (operating temperature: RT and RH: 80%)

In addition to this, it is evident that when the ZnO film is exposed to air at high temperature, the oxygen molecules get chemisorb to generate oxygen species (O2, O2−, and O) by extracting an electron from the conduction band of ZnO. It should be noted that chemisorbed oxygen species depend strongly on temperature. At low temperatures, (< 100 °C) O2 is commonly chemisorbed. At high temperatures, however, O (100–300 °C) and O2− (> 300 °C) are commonly chemisorbed, while O2 disappear rapidly [14, 29, 30]. Therefore, the behavior of the ammonia gas response of the samples with substrate temperature can be also affected by the kind and amount of the adsorbed oxygen on the film surface deposited at higher temperatures.

3.6 Selectivity

As mentioned in the Sect. 1”, the selectivity of the sensor is a vital factor when the human breath is a mixture of more than thousand gases and volatile vapors with different concentrations. To this end, the Mg-doped ZnO thin film deposited at the substrate temperature of 375 °C as a selected sample that showed the best sensitivity was exposed to 100 ppm of different gases and vapors such as acetone, acetaldehyde, ethanol, formaldehyde, and Toluene that may be found in the human breath. The selectivity of a sensor is defined as the ratio of its response to a certain object to that of other objects as K = SA/SB [31]. SA and SB are the responses of a sensor to a target gas (gas A) and an interfering gas (gas B), respectively. These results are presented in Fig. 10. As can be observed, the selected sample shows the selectivity between 8 and 24 times relative to other gases and vapors that is worthy of a breath analysis device.

Fig. 10
figure 10

Selectivity of the Mg-doped ZnO thin film deposited at 375 °C (selected sample) (target gas: ammonia (100 ppm), operating temperature: RT, RH: 80%)

3.7 Reliability

Reliability of the breath analysis device is strongly dependent on the reproducibility and stability of the device at high humidity. To consider the reliability of the samples prepared in this work, the reproducibility as well as short and long time stability of the deposited sample at 375 °C, as the selected sample, was checked. The reproducibility of a sensor is evaluated by the change of sensing behavior after numerous times of switching between ‘ON’ and ‘OFF’ states [31]. To investigate the reproducibility of the Mg-doped ZnO thin film deposited at 375 °C, the response of the sample was tested to 100 ppm ammonia gas at room temperature and relative humidity of 80% for five times. The results are depicted in Fig. 11 that show a good reproducibility of the sample. To study the short and long times stability of the selected sample, the response of the sample was measured to 100 ppm ammonia as a function of day in steps of 3 days for 24 days (Fig. 12a) and as a function of month for 6 months (Fig. 12b) at room temperature and relative humidity of 80%. As can be seen, the response does not fluctuate obviously with time lapse.

Fig. 11
figure 11

Resistance versus time curves for the Mg-doped ZnO thin films deposited at 375 °C under 100 ppm of ammonia gas (operating temperature: RT and RH: 80%), a test for reproducibility

Fig. 12
figure 12

a The response value of the Mg-doped ZnO thin film deposited at 375 °C as a function of day (a test for short time stability), b the response value of the Mg-doped ZnO thin film deposited at 375 °C as a function of month (a test for long time stability)

3.8 Comparison with other ammonia gas sensor

To use the different nano-structured materials as the ammonia gas sensor can be found in many reports. Results of some of these researches are presented in Table 3. As it is expected, various materials with different dopant and surface morphologies show different operating temperature and sensitivity. With an overview on Table 1, it can be deduced that the Mg-doped ZnO thin film deposited at the substrate temperature of 375 °C may be a good selection to sense the ammonia gas as the breath analysis device while it shows appropriate reliability.

Table 3 A summary of nanostructure and ammonia gas sensing performance of different nano-structured materials

4 Conclusion

Mg-doped ZnO thin films were deposited using spray pyrolysis technique on glass substrates at different temperatures (125, 250, 375, 500 °C). Crystallographic structure, surface morphology, and ammonia gas sensing performance of the samples were studied as a breath analysis device. The results showed that the Mg-doped ZnO thin film deposited at 375 °C can be a good candidate to sense the ammonia as the breath analysis device due to its good sensitivity, selectivity, and reliability at high-relative humidity.