Viability And Effectiveness of Mindfulness State Measurement Methodology Using Internet of Things: Proof of Concept

Purpose: This proof-of-concept study aimed to develop and evaluate the feasibility and preliminary efficiency of a methodology to measure the mindfulness state using a wearable device (“Cap”) capable of monitoring students’ levels of full attention by means of real-time measured heart rate variability (HRV). Methods: The device was developed to export the data to the user’s cell phone via Bluetooth, which in turn stores the securely accessible data in the cloud. The autonomous wearable device consists of electronic boards of the Arduino platform that, in addition to the HRV, detect the heartbeat, the external temperature of the skull surface, and head/neck movements. Results: Preliminary statistical data using rMSSD (root mean squared successive differences), the Poincare map, the Toronto Mindfulness Scale, the Mindful Attention Awareness Scale (MAAS) and the Philadelphia Mindfulness Scale (PMS) show that increased HRV values converge to high values for the mindfulness state when the time difference between R and R N +1 sample is greater than 88 ms. Conclusion: The device proved to be viable and potentially effective for measuring the state of mindfulness. Thus, further studies should be conducted to test it on a large scale as well as in real classroom situations.


INTRODUCTION
The main negative element of smartphones is dependence on electronic games and social networks among children, adolescents and adults [1]. Nomophobia (an illness characterized by the fear of being without access to a cell phone, video game, or other electronic device to communicate via the Internet) generates the need to maintain social networks as a persistent, parallel world that is always active and online for as long as possible [2]. The excessive use of smartphones causes psychological and behavioral damage in individuals comparable to that of drug addicts [3] as well as causing both stress and insomnia [4] and reduced school performance in children and adolescents [5].
In schools, the use of cell phones can have a distracting effect, leading to a loss of focus or a decrease in the degree of attention during classes depending on the age of the student [6]. Therefore, the research target of this work is a concept test in the form of a wearable prototype with Internet of Things (IoT) technology, e.g., a Cap capable of preliminarily indicating the degree of attention of students during their school activities by combining the behavior of their heart rate variability (HRV) [7,8], the effects of mindfulness intervention [9], and scales that quantify the degree of attention: the Mindful Attention Awareness Scale (MAAS) [10], Philadelphia Mindfulness Scale (PMS) [11] and Toronto Mindfulness Scale [12].
Based on the central idea of the IoT to monitor individuals' HRV, the physiological basis of the human body is the simultaneous actions of the sympathetic nervous system (SNS) and the parasympathetic nervous system (PNS) [13], given that both constitute the human nervous system [14,15].
It is known that the SNS transmits messages in a bidirectional flow inside the spinal cord that can accelerate the heartbeat, dilate the bronchi of the lungs, decrease motility of the large intestine, constrict blood vessels, cause pupil dilation, initiate sweating, and increase blood pressure. The PNS, in contrast, transmits messages via the vagus nerve [16,17], a shorter and therefore faster-acting pathway than the spinal cord [7] that seeks to balance the excesses of the SNS, i.e., by slowing the heart rate and decreasing blood pressure, adrenaline and sugar in the blood. With the actions of the SNS, especially the PNS, we can obtain HRV in milliseconds [8]. The period in milliseconds is calculated between two subsequent referential R peaks of the QRS complex wave [18]. The proposed affordable wearable device measures this time using blood oxygenation attached to the earlobe of the individual [19] and detects oxygen peaks by means of infrared reflection on the bloodstream with every pulse of the heart [20].
For a healthy individual, it is natural that the RR beat interval changes during daily life, either during physical activity or at rest. The lower the heart rate (HR), the higher the HRV [21] and the greater the action of the PNS. For individuals with emotional or social disorders, such as attention deficit hyperactivity disorder (ADHD) and chronic stress, the HR is higher, and consequently, the HRV is lower [22,23,24].
However, if an individual practices meditation of any type, the HR is lower and the HRV is higher [25,26]. In this study, we highlight the Western meditation practice known as mindfulness, adapted from the Vipassana practice outside of a religious context by the Zen Buddhist Jon Kabat-Zinn in 1970 [9]. Mindfulness is self-reflection with self-awareness that seeks to reduce levels of stress and anxiety by heightening conscious experience in a given moment, i.e., by intentional and effortless full attention [27, p. 1481] with the mind centered in the moment and, above all, with nonjudgmental acceptance (compassion) [28,29].
To associate the mental health of a person with their HRV, there are previous statistical studies in the time and frequency domain [24]. With regard to time, the NN50 counts the quantity of RR intervals greater than 50 ms, the pNN50 calculates the percentage of NN50 on the total of RR intervals analyzed, the standard deviation NN50 (SDNN) is the standard deviation of the NN50, and the root mean squared successive differences (rMSSD) is related to the mental workload or the degree of activity of the parasympathetic autonomic system [21,30]. In the frequency domain, the power spectral density of the QRS signal uses the fast Fourier transform in two groups: low frequency (LF) from 0.04 to 0.15 Hz and high frequency (HF) from 0.15 to 0.4 Hz [31]. HF corresponds to parasympathetic and vagal activity, while LF is sensitive to the two activities of the autonomic nervous system, SNS and PNS. Regardless of the domain of analysis, HRV should be observed between 0.5 and 30 minutes [32,33].
Other studies [25,26] present results that demonstrate increases in HRV in participants undergoing medium-and long-term training in ancient and religious Vipassana meditation (the birthplace of mindfulness) in addition to reducing stress and increasing alertness through mindfulness meditation [34, 35,36,25].
However, in addition to the measurement of HRV performed by the Cap, this study evaluates a methodology to measure the degree of attention of senior high students by collecting the surface temperature of the skull and head/neck movements using sensors of the Arduino family. This is followed by the presentation of the methodology.

METHODOLOGY
The object of study of this research was a wearable device with Internet of Things technology capable of measuring the degree of students' concentration while they were engaged in their school activities, specifically, during a 100-minute class. The prototype testing consisted of the following steps.
First, 155 invitations were sent to students' parents with the informed consent terms attached (the invitations were sent by e-mail due to COVID-19 pandemic isolation rules germs) and kept inside the box for 60 days. In addition to this procedure, a sachet with alcohol gel was added to the external lid of the box so that the student could sanitize his/her hands before first contact with the Cap as a way to prevent the harmful effects of COVID-19.
On the day after the delivery of the kit, another general and virtual meeting was held for training on the use of the wearable device and proper positioning of the heart rate sensor on the earlobe. The app was installed on the participant's own cell phone, and the Bluetooth connection between the cell phone and the Cap was tested to ensure its proper functioning and data storage in the researcher's Google Drive. As a complement, an online manual was available for student consultation with images and videos that reinforced the virtual training conducted directly with the researcher.
With the Cap and app developed exclusively for this research working properly at each student's residence, a common school class was randomly defined in which the Cap would be tested. This class was from 7:30 am to 9:10 am, totaling 100 minutes of continuous monitoring during school activities.
During this period, the researcher followed the procedure online, validating the RR interval, the external temperature of the skull surface, and head/neck movement data stored in Google Drive. According to the pedagogical scheme adopted in the school because of the COVID-19 pandemic, all 5 students entered the respective subject of their course via Google Meet (Google's video calling platform), where the students were normally organized in virtual classrooms with their respective 1 st or 2 nd grade classes.
The 5 selected kept their cameras and microphones on during the class, and the subject teacher of each class taught the class to all students normally.
After the 100-min lesson using the Cap, the 5 students completed 3 questionnaires quantifying the degree of full attention referring to the last 100 minutes of activity. These questionnaires were completed via Google Forms. The researcher followed the completion by video call (following the same scheme of simultaneity of the 100-min class), where each student assigned a score for the questions that classified his or her own degree of attention. The MAAS [37] and PMS [38] questionnaires and their scales were validated in the Portuguese-Brazilian language. The Toronto questionnaire [12] was translated by the researchers involved in this work due to its relevance in quantifying the degree of the students' full attention in the last moments of the class.
After data collection, the researcher made correlations and statistical analyses between the RR intervals extracted during the 100-min class and the answers to the mindfulness scale questionnaires completed immediately after the 100-min class. It was expected that a relationship would be found between maximum HRV and the questionnaire scores.
At the end of the trials, the kits were collected by the researcher, and the participating students received their individual report with conclusions about their degree of attention. The grades are presented in the Results section.

Prototype Cap
The technology employed in the prototype was the IoT, which allows mobility, connectivity, scalability, low power consumption, intelligence, miniaturization of electronic boards, and multifunctional sensors [39, 40,41,42,43,44]. Other studies have shown the feasibility and accuracy of remotely monitoring vital signs [45,46,47]. With the versatility of the Internet of Things, a Cap-shaped prototype was created, with circuits fixed (sewn) on its external side. The heart rate sensor is a low-cost reflected infrared oximetry sensor composed mainly of an instrumentation amplifier with no need for a symmetrical power supply. There are also some resistors and capacitors calibrated to detect, filter and compare the inputs and outputs of the amplifiers in addition to the emitting LED and a phototransistor receiver for the detection process by reflecting the infrared on the blood current with each pulse of the heart [20]. Pulse detection by oximetry is reliable for the real beats of the human heart [50].
The temperature sensor (ranging from -40 to +85ºC) positioned inside the Cap is integrated with the MPU6050 gyroscope motion sensor, which is capable of determining simultaneous movements in the X, Y, and Z axes of the head and neck. Its communication with the Arduino main board is via the I2C bus.

App
After the beats are detected by blood oximetry, the data are transmitted via Bluetooth technology to the participating student's cell phone, which is loaded with an app developed by the researcher and receives the data from the Cap. App usability can be observed in Figure 2. This is designed so that the student pairs the Cap with his/her cell phone via Bluetooth by entering the standard code 1234 when prompted. Next, the participant opens the application, types his/her name in the "Enter your name" field, then expands a menu by clicking the "(1) Cap #" button and chooses the Cap he/she is wearing (ranging from 01 to 05). Finally, by means of a short click on the "(2) On-off" button, the app connects with the Cap. If this communication is successful, the same "(2) On-off" button turns green. The following are the screen details of the Android app. Item " (3) Calibration" on the screen, serves to calibrate the oximetry sensor and item "(4) Send data" serves to send the data to the cloud storage, which will be further processed via MATLAB. The "Exit" button kills the application.
 Cap: the Cap identification number (between 01 and 05) is loaded in front of this word when it successfully connects to the application;  Man Icon: this icon varies between "sitting man" and "standing man", indicating whether the These variables were recorded continuously and serially in the application in the form of a text file and separated by the preamble "P" (character 50h of the ASCII table). Once the data were collected by the cell phone and Cap, they were uploaded to Google Drive (via local Wi-Fi and TCP/IP protocol).

Questionnaires
The participants completed three questionnaires after the 100-min period of HRV monitoring during school activities at home.
MAAS objectively stratifies the state of full attention in that phase of the measurement [37].
The MAAS result is obtained by adding the score attributed to each of the 15 questions, which can be between 1 and 6, and then dividing this sum by 15 to obtain the final average. The closer this average is to the value of 6, the higher the degree of full attention of the participant.
The second questionnaire is the SMP, which also assesses the quantification of the subject's full attention state [38]. The result of the SMP is also obtained by simple average of the score of the 20 questions, which can be between 1 and 5. However, the SMP has two facets of mindfulness: acceptance and awareness (equivalent to "self-awareness" or "acting with awareness" [38]. Consequently, the SMP generates two results. The closer to the value is to 5 in each of the subgroups of 10 questions, the higher the degree for each facet. The third and last questionnaire, Toronto [12], has 13 questions divided into two subgroups: the curiosity score with 6 questions (3, 5, 6, 10, 12 and 13) and the decentering score with 7 questions (1, 2, 4, 7, 8, 9 and 11). Both have five answer choices: "(0) not at all", "(1) a little", " (2) moderately", "(3) quite a bit" and "(4) very much". Each subgroup is added, and its average is obtained.
A value closer to 4 indicates more curiosity or more decentering, respectively, the individual will be.

Variables Analysis
In the area of neuroscience, four signals are observed here: BPM, RR interval, temperature, and head/neck movements. In the area of psychology, we use the averages of the three questionnaires: MAAS, PMS, and Toronto. Considering this, the p-value hypothesis test was used between rMSSD and these questionnaire averages in addition to the geometric analysis through the Poincaré map [51,52], the histogram of the RR intervals and the rMSSD value [51]. An association was defined between the rMSSD (in milliseconds) of each participant and the participant's questionnaire results to support the hypothesis of measuring the degree of full attention using the Internet of Things.
Numerically, the rMSSD is equivalent to the standard deviation in the geometric analysis of the Poincaré map.
The HRV analysis for the 100-min class was segmented into intervals of 15 and 30-min, based on [32], and additionally for 50 minutes on an experimental basis. Thus, the data were organized as follows: Moreover, some signal enhancement techniques were adopted. The results will be discussed in the following section.
1. Noisy samples whose RRN interval became larger than 1500 ms were truncated to this value. The same occurred for RRN samples smaller than 250 ms. These limits were adopted because they This was necessary to avoid discarding PN packets because the observation windows depend directly on the number of packets processed to obtain 15-, 30-and 50-min times.
3. The entire RR time signal resulting from the two previous techniques (truncation and replacement) was subjected to a moving average of MA = 2. This value was adopted minimally to reduce the spuriousness that borders the limits of the Poincaré maps without changing their shape (in particular, their width). It is essential to maintain "perpendicular width" of the Poincaré because it represents the individual's HRV [51]. The geometric maintenance of the Poincaré map is important to prove the hypothesis of the degree of full attention measured through the Internet of Things.
The temperature, given in ºC, was extracted from the external skull surface, on the scalp. There was no intervention to bring the sensor into direct contact with the skin, such as shaving the hair.
However, the sensor remained inside the Cap, and the temperature was recorded with each heartbeat.
Within the two observation windows of 15-, 30-and 50-min, the mean and standard deviation were calculated.
Regarding the head/neck movement, the physical behavior of the student was rated on a binary basis of whether the student was moving at each heartbeat. Within the intervals of 15-, 30-and 50-min, the percentage of each state was defined as still or moving.
Regarding the head/neck movement, the physical behavior of the student was binary rated as to whether or not he was moving at each heartbeat. Within the intervals of 15-, 30-and 50-min, the percentage of each state was defined: still or moving.

Treatment of Corrupted Samples
In compliance with the social isolation of the COVID-19 pandemic, the school routine of the 5 subjects took place in their own homes. Consequently, the data collection process via the Cap occurred from the students' home environment. In this research, the degree of attention during a 100-min lesson was measured.
Initially, the two correction techniques for sample data did not show significant differences between the original and the postprocessed statistical parameters. That is, neither the replacement of a given totally corrupted sample by the average of the 4 immediately preceding uncorrupted samples (Eq.

Benefits of the Moving Average (MA = 2)
To better consolidate the comparison of the effect of the MA = 2 of subject 01 and to demonstrate the maintenance of the Poincaré standard shape, Fig. 3(a) shows the overlay between the Poincaré map without the filter effect (blue) and with the filter effect (yellow) as well as their respective histograms in Fig. 3 Table 1 organizes the variables, their respective meanings, and the row position in which they will be presented in the other tables.    [21,30]. In the 8 th row, there is the predominance percentage of NN50 intervals over the sample's universe of the first 50 minutes, which in the case of subject 01 was 98.52%.

Participants' Data
The 9 th and 10 th lines show SD1 and SD2, respectively. These indices represent a qualitative analysis of the Poincaré map in geometric ellipse form [51]. Fig. 4 shows that SD1 is equivalent to the width of the scatter of points perpendicular to the identity line and behaves as an instantaneous recording index of the beat-to-beat variability [53], while SD2 appears to represent the scatter of points along the identity line and the HRV in long duration recordings. Finally, in the 11 th row, we have the ratio of both (SD1/SD2) which shows the ratio between the two variations, short and long, of the RR intervals [54,55].  Tables 3 and   4 below.

DISCUSSION
The present study is considered a concept test and naturally requires further investigation. For example, the sample of subjects was reduced to five due to pandemic restrictions, and the data collection environment was not controlled due to the imposition of social distance. Factors such as these generated partial results that were not sufficient to accept a p-value of 5% significance.
However, the studies mathematically proved the minimum average value of the rMSSD intervals to obtain the acceptance of the hypothesis using a Z-Test. That is, for H0 (the device -Capis able to measure the degree of attention) to classify a student as "concentrating on school activities" in an observation window of up to 50-min, the minimum average interval should be 88 ms.
To prove this statement, we adopted the Z-Test (Eq. 3) at 5% significance, for which the acceptable critical value should be less than 1.9599 for the variances of the rMSSD and the Toronto questionnaire presented in Table 2.
For example, consider, hypothetically, that subject 01 had obtained an average rMSSD = 133 ms in the first 50-min of the class and in the second part of the class, his/her rMSSD fell to 45  It is worth noting that in this pretest no mathematical association was found between rMSSD and PMS or rMSSD and MAAS. A possible justification for PMS not having achieved this association is that the author himself note its effectiveness if considered for the last week [11] and not the last hour.
With regard to MAAS [56], which also did not show an association with rMSSD, the author does not specify which reference window should be considered when choosing the answers to questionnaire.
This issue needs to be better investigated with a larger number of participants and more care in phenomenology.
Another finding in this research, originally predicted in [51] and confirmed in [53], is the mathematical relationship between rMSSD and the Poincaré map. According to this author, rMSSD is numerically equivalent to the geometric width of the graph ellipse, oriented by a perpendicular line on the identity line (review Fig. 4). Initially, this width was called SD1, but it was later interpreted as short-term HRV. The width SD1 is defined mathematically as follows: In fact, this was proven by sampling 15-, 30-and 50-min. For example, taking any rMSSD value from the 6 th row of any Table 4, 3 or 2 and dividing by √2 is practically the respective value SD1 of the 9 th row of the same table. Therefore, this suggest that the data presented in these tables are correct. Additionally, no mathematical evidence was found to support this technique. Figure 3 presents this geometric comparison (blue and yellow) of the Poincaré. The histograms had the least aggressive peaks due to the frequency damping of each sample but kept the width of their bases. This is equivalent to preserving the elliptical shape of the respective Poincaré map while minimizing the spurious shape. (4)

CONCLUSIONS AND FURTHER WORKS
Measuring heart rate variability by analyzing the RR time interval of the heartbeat QRS wave complex was a challenging and functional goal. The results in Tables 2, 3  Among the analyzed periods of 15-, 30-and 50-min, the latter proved to be more robust in associating rMSSD with any adopted questionnaire.
All data packages collected by the five Caps were mathematically analyzed initially in Octave and subsequently in MATLAB. The hypothesis tests were performed in Excel, but IBM SPSS was also used for comparison purposes.
For the average temperature of the skull surface, no direct relationship with the degree of attention was found. It was noted that the sensor did not reach the average human body temperature of 36°C because the scalp behaves as a poor conductor of heat. However, the tests show that the behavior of the surface temperature of the scalp during the test lesson did not vary significantly among the participants.
The monitoring of head/shoulder movements, also presented as time in the same table, did not provide evidence that relates rMSSD to the quantification of full attention by the questionnaires.
However, it did produce suspicions of excessive leg movement presence while the subject was sitting focused on his/her school activity, as was the case for subject 02, who self-reported in the experimental feedback. On the other hand, subject 04 got up from her chair in the 1 st and 2 nd P of the class, changing her BPM at certain times (as seen in the analysis of the tachogram of Cap 04. However, this BPM change did not translate into higher or lower levels of full attention within the 50 minutes observed, proving the thesis already presented that accelerated BPM is related to the activity of the sympathetic nervous system and during this period, HRV is reduced and without focus of attention. Poincaré maps presented the expected geometric shape (an ellipse) even with the application of the moving average (MA = 2). Its rMSSD width was mathematically preserved with SD1, respecting the ratio of √2 [51].
Finally, partial results seem to indicate that the minimum RR interval (or rMSSD) of 88 ms for the same subject allows the Cap to classify him/her as being or not being in full attention level. Further investigations in this direction will be conducted. Figure 1 Wearable Internet of Things device in the form of a data collector Cap. The heartbeat sensor attached to the orange, red and brown wire and magnet is highlighted Source: designed by the author.