Electronic Nose with Digital Gas Sensors Connected via Bluetooth to a Smartphone for Air Quality Measurements

This paper introduces a miniaturized personal electronic nose (39 mm × 33 mm), which is managed through an app developed on a smartphone. The electronic nose (e-nose) incorporates four new generation digital gas sensors. These MOx-type sensors incorporate a microcontroller in the same package, being also smaller than the previous generation. This makes it easier to integrate them into the electronics and improves their performance. In this research, the application of the device is focused on the detection of atmospheric pollutants in order to complement the information provided by the reference stations. To validate the system, it has been tested with different concentrations of NOx including some tests specifically developed to study the behavior of the device in different humidity conditions. Finally, a mobile application has been developed to provide classification services. In this regard, a neural network has been developed, trained, and integrated into a smartphone to process the information retrieved from e-nose devices.


Introduction
Most research studies and media emphasize that air pollution is one of the greatest environmental health risks worldwide. Nevertheless, it is often imperceptible to people, which makes it go unnoticed. According to the latest data from the World Health Organization (WHO), air pollution causes up to 7 million deaths a year [1]. In addition, there are numerous research studies demonstrating the adverse effects of pollution on almost every system of the human body [2][3][4]. However, although the poor quality of air is widespread, it is invisible to the naked eye, and therefore people are not really aware of the levels of air quality to which they are exposed at every time and place. Normally, reference air quality measurement systems are found in a few locations. It is generally due to the high cost of air quality monitoring stations, which makes it difficult to get real-time relevant data with sufficient spatial resolution.
Consequently, several organizations and countries worldwide have established air quality monitoring systems. Therefore, this approach requires a high budget, which in general implies an insufficient number of measurement points. However, these systems have a high cost and size, resulting in an insufficient number of measurement points. Furthermore, the location of air quality stations is not always sufficiently representative. Therefore, there is a need for small, low-power devices for personal air quality monitoring. As a result, different small, portable, and low-power devices have emerged [5][6][7][8][9][10]. While these devices are less accurate and show a higher uncertainty compared with reference systems, they increase the spatial density of measurements and could provide useful electronic nose. It allows fast data processing and a decrease in the flow of data to be sent and received from the smartphone.
The complete system is described in detail throughout the paper. First, the design of the electronic nose is described, focusing on the included sensors. The following part deals with the development of the mobile application in charge of processing the data retrieved from the e-nose device. In order to study the detection and discrimination capacity of the device, some laboratory tests have been performed. These experiments have been carried out with different concentrations of NOx, which is one of the main contributors to air pollution. The measurement procedure and the obtained results are presented and discussed in Section 3. Finally, the conclusions are presented.

Electronic Nose Description
The block diagram of the developed electronic nose prototype is depicted in Figure 1. The power source is composed of a battery charger, a +3.7 VDC Li-ion battery, a +3.3 V dc-dc converter, and a +1.8 V low drop-out linear regulator. The core of the system is a 32-bit microcontroller, model PIC32MM0256GPM048 from Microchip, which performs the main operations: sensor control through two I2C serial interfaces; communications with smart devices by using a Bluetooth low-energy RN4871 tiny module from Microchip; and wired UART communications with other devices. This microcontroller has been chosen because of its low current consumption thanks to its low operating frequency (24 MHz). Despite of that, it has a great processing power due to its 32-bit architecture, which is complemented with a 256 KB program memory and a 32 KB data memory.
Four digital gas sensor chips have been installed. However, due to their different supply voltages (+1.8 V and +3.3 V), it has been decided to use two separate I 2 C interfaces to achieve more simplicity.
Regarding the power consumption of the electronic nose, a theoretical maximum current (according to manufacturers) of 412 mA has been calculated, although the operating current measured experimentally was up to 185 mA.
In Figure 2, a picture of the developed electronic nose is shown. The dimensions of the device are 39 mm × 33 mm.

Gas Sensors
The four chips, which integrate metal oxide (MOX) sensors, are the following: BME680 from Bosch [26], SGP30 from Sensirion [27], and CCS811 [28] and iAQ-Core [29] both from AMS. All of them are miniaturized intelligent gas sensors. These devices are characterized by the integration of analog and digital electronics combined with a hot microplate and the detecting elements on a single chip. In general, the signals coming from the resistive sensing elements are received by the processor through conditioning analog circuits. Then, these signals are processed with different algorithms (averaging, baseline compensation, humidity correction, etc.). Furthermore, some of them allow users to write calibration parameters. Finally, the output signals (calibrated and/or raw) are transmitted using digital communication protocols. This integrated digital interface greatly simplifies the integration of these sensors into the electronic nose. Figure 3 shows a block diagram of the main components and functionalities of digital gas sensors. The main characteristics of the gas sensors are indicated in Table 1. All sensors, except BME680, include intelligent algorithms to process the raw signals to output TVOC (Total Volatile Organic Compounds) and equivalent CO 2 (eCO 2 ) prediction values. Additionally, SGP30 provides raw signals for H 2 and ethanol. The BME680 also includes temperature, relative humidity, and atmospheric pressure sensors, whose ranges are −40 to +85 • C, 0% to 100%, and 300 to 1100 hPa, respectively.

Communication Protocol
A simple ASCII-based protocol has been established for the Bluetooth communication between the microcontroller and an external smart device. There are some commands for retrieving data from individual sensors and some for changing sensor parameters, setting heaters values, etc. Every sample time, the microcontroller reads sensor values and sends them via Bluetooth in a formatted frame. Each data frame is composed of columns separated by horizontal tabs and finished with carry return and line feed characters. The meaning of each column can be found in Table 2. The 16th column shows a 0 when the electronic nose is smelling clean air (desorption), and it shows a 1 when is smelling a sample (absorption). The 17th column is used to notify the user (who has an app in the smart device) when to manually switch from a desorption phase to absorption phase or vice versa.

App and Neural Network
A software tool (app) has been developed for processing the data provided by the electronic nose. The following requirements have been considered:

1.
Portability: As the small size and light weight are some of the main advantages of the e-nose device, it is most suitable for outdoor environments. To get more benefits from these advantages, this work has considered mobile devices as the target hardware where a software application should be install to monitor and control e-nose data.

2.
Connectivity: The tool must support connection with the e-nose device and it is also required to implement the correct communication protocol to interchange data between both systems. 3.
Data processing: Sensor data need to be processed before they can be used. In this regard, the tool should apply data processing algorithms. 4.
Data classification: A data classification algorithm must be applied to categorize sensor data and provide useful information for the users.

5.
Performance: The tool must receive sensor data in short intervals of time while processing and classifying the information without affecting the overall system operation. 6.
Response time: User requests must be processed and served immediately.
To deal with all this specifications, first, Android has been selected as the mobile operating system, because its great advantage is that it is widely spread over millions of devices around the world. A Bluetooth low-energy communication module has been selected to interconnect both systems (e-nose device and the smartphone) because of the long autonomy that this alternative provides. Next, data normalization and feature extraction algorithms have been applied. Finally, machine learning algorithms have been selected as the best approach to classify data retrieved from the e-nose. In this case, neural networks have been applied, since performance and short response times are achieved once the neural network has been previously trained.
According to system requirements, different technologies can be applied for software development. Cloud-based approaches offer a technology that provides magnificent elastic computation and data management abilities for the Internet of Things (IoT). This approach is aimed at formulating a complex information system with the combination of sensor data acquisition [30]. A previous work [31] presented a cloud-based proposal to integrate services for e-nose devices. However, this approach was more appropriate when short response times were not required and connectivity was always guaranteed. In scenarios where response time is a priority and/or connectivity cannot be achieved, this approach is not applicable and different alternatives must be addressed, which is the scenario on which this work focuses. To deal with this problem, this section proposes the integration of the processing and classifying algorithms into smartphones. Figure 4 shows the methodology followed for developing the proposed tool, which is divided into the following steps.

1.
Neural network building: The aim of this level is building and training a neural network using e-nose data extracted from a set of experiments. As smartphones do not provide enough performance to process all the information, a high capacity computer has been chosen for neural network training. In this level, Neuroph software has been used to build and train a multilayer neural network composed by three layers with 10 inputs (one for each sensor signal) and nine outputs (one for each compound classified). This is an open source tool for machine learning development and has been selected among others because it provides specific libraries to connect mobile applications with neural networks.

2.
Mobile application development: A mobile app has been implemented to monitor and process all the information retrieved from the e-nose device. The Android Studio tool has been used for developing this software and Neuroph libraries have been integrated in order to manage the neural network. The functionality of this tool is diverse: from connecting with the external device through Bluetooth low energy to applying classification algorithms to categorizing sensor data, passing by the processing and the storing of the data for later analysis.

Results
In order to study the performance of the electronic nose for detecting and discriminating contaminants, some measurements have been made in the laboratory. Specifically, NO and NO 2 have been measured at different concentrations.

Measurements Set-Up
A homemade gas line has been developed and used to perform pulses of NO 2 and NO at different concentrations. This system ( Figure 5) allows to mix up to four gases from gas cylinders at the desired concentration. It is composed by mass flow controllers, electrovalves, and a gas expansion module, and it is controlled by a PLC (programmable logic controller) with a touch screen. The gas line allows programming customized and timed cycles to generate gas mixtures. In this specific case, 10 measurement cycles have been programmed for each concentration, in which dry air is delivered to the sensors for 4 min and a mix of the pollutant to be measured at the desired concentration with dry air is generated for 2.5 min. At the output, it is mixed with an adjustable humidity flow, which is also taken into account when calculating the desired concentration. During the whole experiment, the relative humidity was 0%. The flow rate to the electronic nose was always fixed to 200 mL/min. On the other hand, humidity tests have been carried out with the purpose of studying how this could affect the detection capability of the device and to be able to take future precautions. Variations in humidity have been measured in the same way as described above. Throughout, 40 µg/m 3 of NO 2 has been generated in cycles of 4 and 2.5 min. Five different relative humidities have been produced: 0%, 10%, 40%, 70%, and 90%. As in the previous test, 10 measurement cycles have been carried out for each relative humidity generated.
To carry out these tests with gas cylinders, a watertight methacrylate housing has been designed with two pneumatic couplings that allow the gases to flow through the electronic nose. The volume corresponding to the cell through which the gas flows is 33 cm 3 (with dimensions of 4 × 5.5 × 1.5 cm). The housing also includes an insulated bottom compartment to accommodate the battery. It is worth pointing out that this chamber and the calibration process will only be used for the laboratory tests carried out in this study in order to obtain an initial evaluation of the performance of the system. In future work, additional calibrations will be applied for the field tests in real conditions that are scheduled to be performed near reference stations for correlation tasks.

Pollutant Discrimination Results
Once the electronic nose takes measurements, the sensor signals are received in the smartphone. These signals are those specified between the fifth and 15th column listed in Table 2. However, the signal from SGP30 relating to eCO 2 has been discarded because this signal has a minimum of 400 ppm that is never exceeded throughout the experiments. Therefore, the signals that are considered in these experiments will be named from now on as follows: BME680, SGP30_1 (H 2 in Table 2), SGP30_2 (ethanol in Table 2), SGP30_TVOC, CCS811, CCS811_TVOC, CCS811_CO2, iAQCore, iAQCore_TVOC, and iAQCore_CO2.
Before data processing, it is necessary to pre-process the signals in order to obtain a characteristic value for each measurement cycle. Therefore, to perform this feature extraction, a baseline manipulation algorithm has been used. In the selected algorithm in this study, the obtained characteristic value is proportional to the difference between the baseline value (corresponding to the dry air flow) and the value reached during the pollutant measurement phase: where Vref is the value obtained from the sensor during the air measurement phase and Vp is the value in the pollutant measurement phase. As a result, after having made all the measurements, a matrix of 10 (sensor signals) by 90 (10 cycles multiplied by nine NOx concentrations) will be obtained. Nevertheless, the first value of each concentration of each measured compound is discarded. Therefore, the final matrix will be 9 × 81.
Subsequently, a reduction in dimensionality has been carried out using the Principal Component Analysis (PCA) [33]. This technique can describe a dataset in terms of new non-correlated variables ("components"). Components are sorted by the amount of original variance they represent, so the technique is useful for reducing the dimensionality and the redundancy of the dataset. In this way, just the first two main components (which will contain most of the information) can be represented in a plot to observe the distribution of the data. The resulting plot is shown in Figure 6. In this case, the first main component contains 67% of the information and the second one contains the remaining 18%.
In general, it can be noticed that the different clusters can be differentiated, although there is overlap between zones such as NO 2 120 µg/m 3 , NO 165 µg/m 3 , NO 2 205 µg/m 3 , and NO 15.5 µg/m 3 . In some areas, such as NO 2 at a concentration of 80 µg/m 3 , drift problems appear. Such problems are probably related to an insufficient sensor stabilization time before performing these measurements. On the other hand, correlation tests have been performed in order to evaluate the predictive capacity of the device in quantification tasks. For this purpose, a Partial Least Squares (PLS) regression has been performed and the predictions made by the model from the sensor responses have been represented (Figure 7). The actual value is represented on the X-axis, and the value estimated by the model is represented on the Y-axis. The coefficient of determination (R 2 ) obtained is 0.947 for NO 2 measurements and 0.951 for NO measurements. Finally, for classification purposes, a neural network has been programmed into the smartphone app (externally trained). A multiperceptron architecture [34] has 10 neurons in the input layer, a hidden layer containing four neurons, and one neuron in the output layer. Afterwards, the LOOCV (leave-one-out cross-validation) validation technique was used to study the classification capability. Results are shown in the Confusion Matrix (Table 3). In this matrix, each column represents the predicted pollutant concentration and each row represents the real pollutant concentration. Consequently, the main diagonal contains correct predictions, while outside values correspond to erroneous predictions. Finally, a success rate of 92.59% is achieved in the classification, with six mistakes being committed out of 81. Table 3. Confusion matrix obtained in leave-one-out cross-validation (LOOCV).

Limit of Detection (LOD) Estimation
In addition, an estimation of the limit of detection of the electronic nose for NO and NO 2 has been obtained. It has been calculated for each of the four sensors integrated in the device. For this purpose, the raw signal obtained from each sensor (Ω) is used, since all other signals are algorithms offered by the manufacturer that may be non-linear and in some cases have lower and upper limits implemented.
The estimated LOD (µg/m 3 ) has been determined according to the simplified LOD formula [35,36]: where Â is the slope of the resistive response of the sensor against the pollutant concentration and s 0 is the standard deviation of blank measurements, i.e., measurements performed in clean air.
As an example, Figure 9 shows a chart with the data obtained by the CCS811 gas sensor for the different NO concentrations. The red line represents the trend line whose slope is used for the calculation of the LOD (Equation (2)), which is also represented in the figure (black line).  Table 4 summarizes the estimated NO 2 and NO limits of detection for each sensor expressed in µg/m 3 .

Humidity Tests
NO 2 measurements at a concentration of 40 µg/m 3 have been performed under five different relative humidity conditions, with the aim of studying the response of the sensors under these different environmental conditions. The results have revealed that as the relative humidity increases, the response of the sensors decreases, or is even non-existent in this scenario. For each humidity value, 10 measurement cycles have been carried out. Figure 10 shows a radial graph of the averaged values of the 10 measurement cycles for each gas sensor. It can be verified that sensor responses are low for high values of relative humidity, except in some cases, such as the CCS811 TVOC response. This might be related to the internal algorithm implemented by the manufacturer. Sensor time responses can also be studied, as shown in Figure 11, where a comparative graph of the SGP30_2 response signals is depicted. It can be appreciated that below 40% of relative humidity, the responses are almost imperceptible. However, the operating range in this test is not the same for all installed sensors. Figure 12 depicts the resistive responses of the CCS811 sensor, which are, indeed, inversely proportional to relative humidity. Nevertheless, even at 90% relative humidity, a significant variation of the response to NO 2 can be detected. Therefore, a filtering unit or a humidity correction algorithm should be added in high humidity environments for the detection of low concentrations of pollutants. This must be taken into account for future improvements and developments.

Conclusions
In this paper, a low-cost, low-consumption, and very small size electronic nose for air quality monitoring has been illustrated. Typical gas sensors based on metal oxide technology that have been used in electronic noses for decades are not appropriate for miniaturized instruments due to their high power consumption and size. MEMS technology has allowed the integration of gas sensors within CMOS technology modules, which embed signal processing, A/D converter, and communication circuits. These digital sensors that have appeared in the market in the last years normally incorporate several gas sensors or even others such as atmospheric pressure, humidity, or ambient temperature sensors.
On the other hand, the use of miniaturized measurement devices of small size, low power consumption, and cost in combination with smartphones allows the creation of sensor networks in which each citizen acts as a node of a huge network with a very high number of nodes. This configuration, together with the great computation capacity of the processors of the latest telephones, makes it possible to execute complex signal processing techniques in the device itself without having to increase the amount of data sent or received.
The detection and discrimination capability of the device with different concentrations of NOx compounds (some of the main atmospheric pollutants) have been checked. For this purpose, a multiperceptron neuronal network has been programmed in the app developed for smartphones. It has been performed several tests with different conditions of relative humidity to study whether it affects the detection performance of the gas sensors. It was concluded that high humidity conditions could significantly affect the operation of the device for this application, especially in the detection of low pollution concentrations.
The results obtained indicate that significant future work will be required to improve the reliability of MOx sensors in the presence of humidity in order to obtain a good prediction in the concentration of pollutants in air. However, these digital sensors may be integrated in the near future in smart devices, such as phones, watches, or tablets, following the trend of increasing the number of sensors in these devices. This integration, and its massive use, will allow the appearance of numerous applications that will make use of the sensor data as it happened some years ago with the cameras integrated in the smartphones and the apps of artificial vision. Such prototypes and advanced algorithms for signal processing are already under development, as discussed, and will likely be required for the widespread and successful deployment of e-noses as personal devices for air quality monitoring. Funding: Authors want to thank the European Union for supporting NanoSen-AQM (SOE/P1/E0569), and Junta de Extremadura and FEDER (Fondo Europeo de Desarrollo Regional "Una manera de hacer Europa") for supporting the IB16048 project and GR18135.

Conflicts of Interest:
The authors declare no conflict of interest.