## 3 Results
### Firmware Development and Experimental Tests on Realized Smart Garment  
This section describes the development of the proposed smart garment's firmware, detailing the communication modalities between the installed sensors and the acquisition and processing section; furthermore, the management of the data coming from the sensors is also analyzed to calculate the relevant parameters measurable by the smart system. Moreover, the results of the communication test performed between the smart garment and the IBM Watson cloud platform are reported. Figure 12: Circuit scheme of the conditioning section of the ME3-H2S sensor. The flowchart of the firmware deployed by the wearable device is illustrated in Figure 14. First, all of the variables useful for programming purposes are declared, and the used communication interfaces (I\({}^{2}\)C and UART interfaces) are initialized. Then, the program flow enters a loop that iterates until the device is switched on. Subsequently, the measurement cycle starts by verifying the contact of the PPG sensor with the user's skin. This task is performed by checking the reflected IR component acquired from the MAX30102 sensor; if the reflected component is lower than a given threshold, it means that there is no contact with the sensor. The acquisition cycle is thus stopped until the user puts on the smart garment. Once the wearable device is worn, the acquisition cycle starts by gathering raw data from the PPG sensor. First, the 32-bit samples of IR and red components acquired by the two detectors integrated into the MAX30102 sensor are stored by the microcontroller for 4 s; since the sampling period is set to 25 samples per second (sps), 100 elements are collected and stored into two arrays. The acquired samples are stored inside the data memory (static random-access memory (SRAM)) of the SAMD21G18A microcontroller. Then, the measurement is refined by recording new samples every second for 35 s; specifically, the first 25 sets of samples are deleted, and the remaining ones are shifted to the top of the corresponding array. Therefore, by setting the variable i = 75 (the array index), 25 new samples can be recorded every second (Figure 14a). After 35 iterations, the HR and SpO\({}_{2}\) are calculated; specifically, the HR firmware detects the time interval between two peaks of the optical signal reflected from the skin surface [50]. In addition, the implemented SpO\({}_{2}\) firmware relies on the  
Figure 13: Schematic (**a**), layout (**b**), and PCB top (**c**) and bottom (**d**) views of the ME3-H2S sensor’s conditioning section. Diagrams were realized with the Eagle CAD software. Lambert-Beer law, which allows measuring SpO\({}_{2}\) using the molar extinction coefficients of oxygenated hemoglobin (HbO\({}_{2}\)) and deoxygenated (RHb) hemoglobin [51]. Arterial blood, periodically pumped into blood vessels, absorbs and modulates incident light as it passes through the tissue and forms a photoplethysmographic signal (PPG). The AC component of PPG signals represents the light absorbed by pulsatile arterial blood and is usually found at a frequency of 1 Hz, depending on the heart rate. This AC component is superimposed on a DC signal that captures the effects of light absorbed by other blood and tissue components (venous and capillary blood, bone, water, etc.). The relationship between the AC signal and the DC level is commonly referred to as the perfusion index (PI). Two LEDs with different wavelengths are needed to measure SpO\({}_{2}\), selected so that the molar absorption coefficients of HbO\({}_{2}\) and RHb are well separated. Figure 14: Flowchart of the firmware deployed by the wearable device (**a**); interrupt service routine (ISR) used to detect falls (**b**). A 660 nm red LED and an 880 nm infrared LED are commonly used in pulse oximetry because oximetry relies on the change in the absorption of the electromagnetic energy of the hemoglobin molecule when its chemical bonds are altered (i.e., when it comes into contact with the light beam generated by the LED) [52].