## 2 Materials and Methods
### Design of the Sensing System Prototype
#### 2.4.2 Electronic Subsystem  
The electronic subsystem consisted of the measurement circuit, power supply circuit, and the touchscreen display. The measurement circuit consisted of an instrumental amplifier (IA), a microcontroller device (\(\upmu\)C), a low-pass filter (LPF), and a digital-to-analog converter (DAC). Figure 4 shows the block diagram of the measuring circuit. The PMT operates with a high gain; therefore, any small change in the measurement setup due to environmental light, cuvette movement, aging of the LED, etc., can be a source of error. To minimize these issues, a calibration must be done for each measurement. The basic idea of the calibration  
Figure 4: Simplified electronic schematic of the fluorimeter circuit (IA—instrumental amplifier, PMT—photomultiplier, DAC—digital to analog converter, LPF—low-pass filter, \(\upmu\)C—microcontroller, LCD—liquid crystal display, P—potentiometer). Figure 3: Spectral response of the chemical sensor, LED, optical filter, and photomultiplier tube (PMT). procedure is to measure without the presence of the analyte (it is called \"blank\") and saving the value. Then, measuring the presence of the analyte and subtracting the blank value. This calibration procedure was implemented into the hardware with two sequential steps:  
1. Measure without the sol-gel sensing material (i.e., without the photoluminescence emitter in the light path). In this step, the IA is the difference between the output voltage of the PMT (V\({}_{\mathrm{PMT}}\)) and the output voltage of the DAC. This last voltage corresponds also to V\({}_{\mathrm{PMT}}\) and has been converted to digital in the analog-to-digital converter (ADC) of the microcontroller (input AN1). In these conditions, the output of the IA should be approximately zero volts. 2. Measure with the sol-gel sensing material (i.e., with photoluminescence emitter in the light path). In this step, the IA is also the difference between V\({}_{\mathrm{PMT}}\) and the DAC output, which is the PMT output voltage without the analyte. In this way, the voltage at the output of the IA is due only to the phosphorescence of the sensor. This signal is passed through an RC low-pass filter to avoid the aliasing phenomena when the signal is sampled by the microcontroller (input AN0). The instrument is powered from the mains through an AC/DC converter of +9 V. Alternatively, a pack of +9 V/2000 mAh Li-ion batteries can be used for in-field applications. To recharge the batteries, an inexpensive current source was implemented around the LM317 adjustable regulator. Two DC/DC converters were used to obtain +3.3 V (JCA0305S03) to power the microcontroller and \(\pm\)12 V (JCA0205D02) to power the IA and the PMT module. The main consumptions are the PMT module (max. 50 mA), the LCD module (max. 45 mA), and the UV LED (max. 80 mA). This consumption permits working with the instrument for at least two hours. The display was a 3.5\" LCD module (MTF-TQ35 SP811-AV) from Microtips Technology Inc. (Orlando, FL, USA). Figure 5 shows the flowchart of the microcontroller firmware and the user interface screens. The microcontroller was programmed in the C language. First, the microcontroller and the touch screen are initialized. Second, the values of the DAC and the digital potentiometer are loaded from the microcontroller. Then, the calibration screen is shown, to measure the \"blank.\" The ADC reads the blank 10 times, obtains the average value, and stores this value as the zero value. Next, the instrument is ready to measure the analyte and the measurement screen is shown. The ADC also reads the analyte 10 times and the average value is obtained and subtracted from the value of the \"blank\". This value is converted into a concentration using the calibration curve and shown on the final screen. It is necessary to calibrate the instrument with each measurement by following the above procedure. The settings screen is accessed by pressing the battery symbol placed at the lower-right corner of the display.