# A Novel mHealth Approach for the Monitoring and Assisted Therapeutics of Obstructive Sleep Apnea
## 4 Prototype Assembly and Testing
### Circuit Tests  
To test this circuit, the EMG sensor necessarily needed to have three electrodes connected to a muscle. The values acquired by the surface electrodes vary over time. Whenever the muscle is at rest, the read values will always remain within a range, never being equal. This range of values is exceeded whenever there is a stimulus to the muscle in question. The control of the number of readings as a function of time is accomplished by programming the microcontroller. The more readings are performed in a shorter period of time (increase in the acquisition frequency), the greater the accuracy of the acquired signal. However, increasing the number of readings also increases the probability of acquiring unwanted noise signals, so there needs to be a balance to obtain the best possible results. In order to obtain the best results, presented in Figures 16 and 17, a signal was acquired and analyzed every 20 ms. Thus, 50 signals per second were acquired through the surface electrodes. As presented previously, the muscle that the electrodes were to be attached to was the genioglossus muscle. However, due to the fact that it is extremely difficult to find electrodes that can be used inside the mouth; that, for this application, the electrodes would have had to have been custom made, with smaller dimensions, in order to be placed inside the oral cavity; and because a structure that contained and positioned them in the appropriate location would have been needed, the forearm muscle was used for testing instead. Thus, Figure 16 compares the electromyographic tests of the genioglossus muscle, with those of a forearm muscle. The first part of the figure, represented by the letter A, concerns the forearm muscle. Here the muscle is relaxed during the period described by number 1, and there are three voluntary contractions, as shown by the number 2. The second part of Figure 16, represented by the letter B, shows the results of the EMG when placed on the genioglossus muscle. Again, the state of relaxation of the tongue is visible in 1 and in 2, through two voluntary excitations of the tongue through a conscious movement. By analyzing the electromyographic data in this muscle, it is also easy to observe a cyclical upward movement, represented by the green arrows, which relate to the heartbeat. Through the analysis of these two images and considering the level of difficulty in acquiring an adequate reading of the genioglossus muscle, we decided to perform the tests on the forearm muscle. This allowed easier operation and enabled us to obtain more reliable data. During the tests, it was found that the values read by the EMG sensor in the forearm muscle, while it was still and at rest, were always between 1350 mV and 1400 mV, climbing to a maximum of approximately 1550 mV when contracted voluntarily, as shown in Figure 17.  
To prove that the system was working as desired, the apnea value was set above 1800 mV. This value was defined as higher than the normal functioning of the muscle because, as reported earlier, it is possible to stimulate the muscle externally, but it is impossible to consciously make it relax and stop functioning normally. With this in mind, whenever a reading is above the set value, in this case 1800 mV, it should send a stimulation pulse and send that information to the _Google Sheet_. Figure 18 shows exactly that. The sensor detected a higher value than the set number of 2324 mv--as can be seen on the left side of the figure--which caused the microcontroller to acquire the time of the occurrence and record these data online, on the _Google Sheet_--as shown on the right side of the image. The stimulus delivered to the muscle whenever an apnea was detected, generated via PWM, was recorded with the aid of an oscilloscope. The values obtained are shown in Table 1.