Colorimetric sensor for bad odor detection using automated color correction

Colorimetric sensors based on color-changing dyes offer a convenient approach for the quantitative measurement of gases. An integrated, mobile colorimetric sensor can be particularly helpful for occasional gas measurements, such as informal air quality checks for bad odors. In these situations, the main requirement is high availability, easy usage, and high specificity towards one single chemical compound, combined with cost-efficient production. In this contribution, we show how a well stablished colorimetric method can be adapted for easy operation and readout, making it suitable for the untrained end user. As an example, we present the use of pH indicators for the selective and reversible detection of NH3 in air (one relevant gas contributing to bad odors) using gas-sensitive layers dip coated on glass substrates. Our results show that the method can be adapted to detect NH3 concentrations lower than 1 ppm, with measure-to-result times in the range of a few minutes. We demonstrate that the color measurements can be carried out with the optical signals of RGB sensors, without losing quantitative performance.


INTRODUCTION
A control of gases in the environment is required in many industries, such as the chemical industry, automotive, food and pharmaceutical production, or fire detection. In the last years also a rising need for NH3 sensors could be observed. NH3 detection is especially important in environmental monitoring, process monitoring and the control of perishable goods [1][2][3] . For example, NH3 monitoring is highly important in pig sties and their vicinity, breath analysis, leakage detection in industrial plants, or during the selective catalytic reduction of NOx in exhaust gases. Regarding control of perishable goods, an application is the monitoring NH3 in food packaging. Most of the fresh food (meat, fish, vegetables, ...) is packed into modified atmosphere to preserve its freshness and quality, and it is marked with an estimated expiry date. This rigid criterion makes industry throw away 1/3 of the food produced every year, being precisely meat and fish 35% of this waste. Depending on the application, required concentrations for NH3 detection are between 50 ppb and 1000 ppm. Due to this variety of applications, NH3 was chosen as target gas. Several methods and sensors for detecting NH3 are available on the market. However, many applications need compact stationary or even mobile sensor systems. Thus, the sensors themselves are required to be as small as possible, energy-efficient, and low-cost, and many times compatible with wireless readout. A promising choice for such sensor networks are colorimetric sensors due to their high selectivity and virtually zero power consumption in the gas-to-color transduction stage.
Colorimetry is widely used to determine the presence of specific chemical compounds in complex chemical environments. Colorimetric tests are based on a highly specific reaction (identification step) that can only proceed in presence of the substance of interest and leads to a product (e.g. changes in pH) that triggers the color change of a dye (transduction step). Depending on the robustness of the chemical route chosen in both steps, high specificity towards individual compounds can be achieved. Compared to other technologies, e.g. electronic sensors, the identification, and transduction steps are relatively decoupled offering better chances for reconfiguring the specificity towards different compounds in an easier way. Consequently, colorimetric tests remain as excellent candidates to build up complex multiplex sensing arrays, combining multiple gas-specific sensing spots made of different gas-specific indicators 4 . In terms of integration, most of the color changing indicators are cheap and can be printed and dried on inexpensive, disposable substrates 5 to build small, cost effective devices with high analytical power.
The detection of ammonia using colorimetry is widely described in literature [6][7][8][9][10][11][12][13][14][15] . Already in 1976 David et al. reported about an idea regarding colorimetric detection of ammonia gas. The detection limit reached was very low, but the colorimetric reaction was irreversible 6 . A reversible reaction can be achieved by using pH indicators like bromophenol blue, bromocresol green, bromocresol blue, bromocresol purple or chlorophenol red [9][10][11][12][13] . These pH indicators are usually embedded into polymers, whereby detection limits of in ppb range are reported. Due to the availability and gentle handling of pH indicators they are also used in commercially available gas sensing systems 16 .
However, the main limitation of colorimetric methods is their readout. While direct observation with the naked eyes could be of use for semi-quantitative purposes, automated readout is necessary in applications needing fully quantitative determinations. To that end, spectroscopic techniques are normally used to measure accurately the spectral changes of the dyes. This approach however requires complex and costly equipment and is unsuitable for many in-field applications. That is the reason why many efforts have been invested over the years to develop integrated systems capable of carrying out simplified spectroscopic measurements 17 . In parallel, many authors explored the possibility of carrying out these color measurements using the conventional red, blue, and green spectral bands available in conventional digital imaging devices (e.g. desktop scanners) with promising results 18 . However, these solutions relay on environments with well controlled light conditions to guarantee the accuracy of the color determination 19 . Thus, the true potential of colorimetric measurements to make complex analytics simple and inexpensive could only be exploited if the measurement methods were based on ubiquitously available imaging devices (e.g. smartphone cameras) with color determination methods immune to ambient light interferences 20 .
In this context, we report here on a systematic methodology to translate the color information available in the color spectra of the indicator dyes into the simplified set of red-green-blue (RGB) bands available in the sensors of conventional cameras. We propose a pre-calibration stage, based on spectroscopic information that can be used later to interpret correctly the RGB information provided by a much cheaper measurement instrument, e.g. a camera.
As an application example, we developed and implemented a reversible colorimetric method towards NH3 in air. Gassensing elements were prepared dip-coating a glass-substrate in a solution containing the colorimetric pH indicator bromophenol blue. So in this study we were able to combine proven colorimetric technology with new color acquisition methods opening the way to a small, energy-efficient and low-cost gas sensor enabling everyone to wireless readout the current NH3 concentration.

Fabrication of the gas-sensitive layer
For preparing the sensitive layers, a solution containing the pH indicator as well as the organic polymer was prepared. Therefore, 1 g ethyl cellulose (EC) (Sigma-Aldrich, Germany) and 1 mL (3.7 mmol) tributyl phosphate (TBP) (Fluka, Germany) were dissolved in 20 mL pure ethanol (99.9%; Roth, Germany) and 30 mg (0.04 mmol) bromophenol blue (BPB) (AppliChem, Germany) added just prior to use. The solution was stirred until the turbid solution turned clear.
The sensing elements were fabricated by dip-coating of a glass slide (18 mm x 18 mm) into the solution. The colorimetric layers were dried in air for at least 12 h at room temperature. By varying the dipping velocity and repeating this process, different thicknesses could be obtained. Here, layers between 2 µm and 15 µm thick were used.

Gas sensing experiments
To investigate the spectral response of the deposited colorimetric layers, 100 µl of the solution was pipetted onto a glass window of a gas-tight cell for measurements in an UV-VIS spectrometer (Lambda900, Perkin Elmer). The solution was dried for 2 h and exposed to 200 ppm NH3 for 10 min at a gas flow of 1 l/min. Upon NH3 exposure, the indicator dye changes its color from yellow to blue. The spectral response from 250 nm to 850 nm is depicted in Figure 1.
Gas sensing experiments were conducted in a customized chamber of 15 ml in volume. The gas flow was maintained at 200 ml/min during all the experiments. In these conditions, the gas chamber can be fully flushed five times in less than 20 seconds. Reference gaseous atmospheres were provided by several independent mass flow controllers blending dry synthetic air (SA, 79 % of N2 and 21 % of O2), and NH3 (100 ppm in SA). Constant relative humidity (from now on RH) levels were obtained by bubbling dry SA into deionized water (relative humidity obtained at a constant temperature of 25 °C at a pressure of 1 atm). In the cross-interference experiments, additional cylinders containing certified dilutions of different gases in SA were used. To measure the color changes of the sensing elements in real time, during the exposure to changing reference atmospheres, a digital camera (Raspberry Pi Camera v2, sensor Sony IMX 219) was coupled to the gas test chamber though a transparent quartz window. Constant illumination conditions were maintained with a halogen white lamp (color temperature 3200 K).

The indicator approach
The chosen pH indicator bromophenol blue changes its color at a pH value of 3.0-4.6 from yellow to blue. This is caused by the following reversible ring opening reaction depicted in Figure 2.

Spectral response
First, we characterized the spectral composition of the colors reflected by the indicator dyes in presence of different gas concentrations. Figure 3 shows the reflectance spectra c() acquired immediately after exposing a sensing element to steady reference atmospheres containing 0, 10, 20, 50, and 100 ppm of NH3 diluted in SA with 50% RH for 10 minutes.
Clearly, the indicator dye used exhibited two broad adsorption bands in the visible range, centered around 410 nm (purple-blue) and 580 nm (yellow). In clean dry air, the purple-blue adsorption band dominates the spectra, while most of the yellow light is reflected. In presence of increasing amounts of NH3, the yellow light is increasingly absorbed by the dye and the reflection correspond mostly to purple-blue wavelengths. This is fully consistent with the qualitative turn from yellow to purple-blue observed with the naked eyes. Figure 3 Spectral response of the colorimetric gas-sensitive layer, after exposure for 10 min to five different reference atmospheres containing NH3 diluted in humid air (RH 50%).

Transformation to the RGB space
In order to be able to extract in real time quantitative gas measurements from the images acquired with the camera we used the spectral information to stablish a functional relationship between the RGB data and the gas concentration.
As the spectral response of most of the cameras is designed to mimic the response of the human vision, we choose to estimate the color corresponding to the available spectra c() with the standard tri-stimulus XYZ eye-cones curves (shown in Figure 4.a). This is, we calculated the normalized color coordinates of each spectra in the XYZ representation using the standard definitions: (2) For an easier comparison with the color information provided by the camera, these coordinates where renormalized to integers between [0,256), which is the standard numeric span of one single color channel at 1 byte resolution. Figure 4.b shows the result of this process, representing the 3D RGB coordinates of the spectra c(). Also, Figure 4.c shows a render of these RGB colors, confirming that the RGB coordinates correspond to the yellow to purple-blue turn observed in the real samples. Once in the RGB space, the most convenient 1D projection  was searched. After many different trials, we concluded that the best results could already be obtained using the simplest projections; for example, using one single coordinate (e.g.  = Red,  = Green, or  = Blue), or also calculating the grey light intensity of the same (i.e.  = gray is the mean RGB value). Figure 5 shows the calibration colors in all these four 1D projections. Among them, clearly the  = Red or  = Green projections lead to the maximum separation of the calibration samples, and are thus the most simple and convenient choices.
Interestingly, independently on the projection used, data follow a log-type trend that can be analytically expressed as: where [NH3] is the gas concentration;  the 1D projection of the RGB space used; and a, b, c are the fitting parameters. Figure 5 also shows the good agreement between the fitting of eq.(3) and the available data. Consequently, a general color calibration procedure can be implemented as follows: 1) Acquiring the reflectance spectra c() of real samples exposed to gases.
2) Calculating the RGB representation of the colors encoded in c(), using a model of the spectral response of the sensor (in our case the XYZ space). 3) Searching for a convenient 1D projection  of the color space, based on criteria like good color separation and low computational cost. 4) Fitting an analytic expression to the calibration colors in  coordinates that could be used to relate gas concentration with the colors observed in the camera images. 5) Applying this analytic expression to recover the gas concentration from ; and scaling the color span to the reference color observed in "clean air" conditions (i.e. initial color).
Once defined this protocol, we then used it to monitor in real time the NH3 concentration in extended gas sensing experiments. Figure 6.a shows a record of the color changes observed on the sensor element upon exposure to a sequence of NH3 gas pulses. Color changes were expressed in terms of the  = Red projected signal. Six different concentrations from 5 ppm to 100 ppm where used in two consecutive sequences of increasing and decreasing concentrations. We observed that  scaled with the gas concentration and recovered its initial value when returning to clean atmospheres of dry SA with no significant drift. Concerning the sensor response time, measurable color changes large enough to quantify the presence of gases developed in less than 5 minutes. The recovery times were comparable, achieving full signal recovery. The detection limit was estimated to be less of 1 ppm, using exposure times in the range of minutes and considering a noiseto-signal ratio of approximately 3 bits in 256 levels (1 byte color channel resolution). The influence of the most common interfering compounds in open air was also investigated. Figure 6.a shows the response to a similar sequence of NH3 pulses, but now diluted in a background of humid air (RH 50%). Clearly, humidity interferes on the measurements, possibly due to its influence on the indicator's pH. Also, Figure 6.b shows the response to NH3 in presence of CO; in this case, the color sensing response is not interfered.

Real-time RGB measurements
Finally, to validate the calibration proposed in the previous sections, we plotted in Figure 7.a the response  at different NH3 concentrations in dry and humid conditions. Clearly, both datasets follow the trend of eq.(3) demonstrating that the calibration model estimated on the basis of the color spectra is also valid for the RGB spectra. To conclude, we calculated the color signal  with the original fitting function applied to the spectra and compared that with the equivalent number estimated from the RGB data. The results plotted in Figure 7.b demonstre excellent 1:1 correlation. Therefore, the color calibration and correction method, based on spectral reference data can be transferred to RGB data acquired in real time.

CONCLUSION
We successfully prepared colorimetric layers on glass-substrates. The pH indicator dye bromophenol blue was embedded in ethyl cellulose as polymer matrix and then deposited with dip coating. Measurements in an UV-VIS spectrometer after exposing NH3 showed the expected spectral response for bromophenol blue and its deprotonated analogue.
Then, we used this spectral information to predict the color signal evolution in the RGB space, which is more convenient when using a digital camera. An analytic model that links this color signal with the gas concentration was found, and a method to apply it to real-time RGB data was proposed.
Finally, the sensing performance of the layers was measured in real-time in the range from a few to 100 ppm, showing low detection limits below 1 ppm and response times in the range of a few minutes. The signals were fully reversible and specific to NH3. However, a significant influence of ambient humidity was observed.
Further work will include, among others, investigating in detail the influence of water on the response to NH3 and how to circumvent this effect, testing the endurance of the sensors in long term experiments, including the exposure to lower and higher concentrations of other interfering agents, verifying the repeatability of the sensors comparing the responses obtained with large sets of equivalent devices, and studying the influence of the illumination conditions on the sensor performances observed.
In summary, we demonstrated an easy to use methodology to carry out highly specific chemical sensing with colorimetry in everyday life, with simple and inexpensive tools, opening a whole new strategy for ubiquitously available test kits for bad odor detection.