Putting All of our Subsystems Together Cohesively
Listening and Comparing with the Hub
The program that compares the incoming sound with the stored alarms was made using C, while the rest of the programs in the hub used Python. To fully integrate the code, it had to be in a program that would be able to complete all of the necessary processes. This would either involve translating the C code into Python or find a way to run the C code immediately after a sound is detected. By utilizing a Python library known as subprocess, it was possible to execute the compare function that was written in C in the Python code. The subprocess command can run any line of code the user inputs, which includes compiling and running other programs. Because C had more convenient libraries to perform the mathematical operations necessary to compare the sounds, it was easier to find a way to run that program rather than rewrite it entirely.
Bluetooth Messages and Alarm Detection
When first trying to figure out how to send bluetooth messages from the hub to the wristband, commands were sent via the terminal. After this was achieved, it was necessary to find a way to execute these same commands programmatically rather than through the terminal. Ideally, this would be done using Python since all of the functionality on the hub was done using Python. Using the terminal command "autoexpect", a script was generated based upon the user inputted terminal commands. The script steps through the same commands and tools necessary for bluetooth communication that would be used in the terminal one after the other. After this script was generated, it was executed using subprocess in the Python code to send an integer value that corresponds to the alarm detected.
Alerting the User with an LED and Vibrator
A 3-color LED and a vibrator are used to generate different alerts that correspond to each type of alarm. The LED would be green for low severity alarms, blue for moderate alarms, and red for the high severity alarms such as a fire or carbon monoxide. The vibrator, which was sewn into the wristband, pulses at different rates depending on the alarm as well. The LED and vibrator were both turned on using I/O pins from the nRF52832 chip. Unfortunately, the current from these pins was too low to turn on either the LED or vibrator and so a MOSFET network was designed. Biasing a MOSFET using the I/O pin would allow the current to be amplified enough to drive the LED and vibrator. The first MOSFET network designed using Eagle did not function, so a new network was designed that properly amplified the signals.
Packaging the Boards
In an effort to save space on the wristband, two small boards were used rather than one large board. The two boards were stacked on top of each other, connected by header pins coming out of the nRF board. The header pins were soldered to the nRF board but not the breakout board to make it easier to remove and program the nRF. The display was on a separate board that was connected to the nRF board by soldering wires where the header pins would have gone. All of the components of the MOSFET network (MOSFET, resistor, diode, etc) were soldered together at their leads and then soldered to the nRF board using wires.