Breathe Light Anxiety Device With Heart Rate Monitor
by BrysonandEmma in Circuits > Arduino
1782 Views, 17 Favorites, 0 Comments
Breathe Light Anxiety Device With Heart Rate Monitor
With the world getting busier, everyone is in an increasingly high-stress environment. College students are at an even higher risk of stress and anxiety. Exams are especially high-stress periods for students, and smartwatches with breathing exercise settings aren't typically allowed to be used during exams since they can also text and connect to the internet.
"Breathe Light" is a simplistic anxiety-centered device that does not have internet connectivity and will be welcomed in exams. This device is not user-specific which allows for it to be easily adapted to any person needing anxiety control. By using a series of four NeoPixel LEDs, the user will be able to follow steps to perform breathing exercises and also track their heart rate before and after the exercises to determine if their stress levels are lowering.
Materials and Tools Needed
Materials:
- Adafruit Flora ($14.95)
- Breadboard ($5.00)
- Adafruit NeoPixels (4) ($7.95)
- PulseSensor ($25.00)
- Alligator Clips ($3.95)
- Breadboard Jumper Wires ($3.95)
- Lithium-Ion Polymer Battery ($9.95)
- 220 Ohm Resistor ($6.28)
- Push Button ($5.99)
- Assorted Legos ($10-$40) (Note: You do not need many Lego's)
Total Cost: ($94-$124)
Tools:
- Arduino Software (FREE) - Required
- Needle Nose Pliers (~$6) or Cuticle Cutters (~ $4)- Suggested
- Soldering Kit/Materials (~$11)- Optional
Total Cost: ($15-17)
Preparation
Before beginning the project and using the materials above, it is important to develop good background knowledge of what is being used.
Adafruit Flora
The Adafruit Flora is a small, simple, and powerful microcontroller that is useful for both beginners and experts. It is very small (only slightly larger than a quarter) and wearable! The image above shows the pinout diagram for the Adafruit Flora. To learn more information about the Flora, visit the following link:
https://learn.adafruit.com/getting-started-with-fl...
Adafruit NeoPixels
The NeoPixels by Adafruit are individually addressable RGB LEDs that are designed specifically for wearables. The NeoPixels are chainable, meaning that you only need one pin connection to the microcontroller to connect as many LEDs as desired. They can be coded for in Arduino, but require some practice, research, and example help online to become familiar and to get the NeoPixels to perform as you want them to. The different steps in the following link is very helpful as it informs you about how the NeoPixels work and gives coding tips and examples with Arduino.
https://learn.adafruit.com/flora-rgb-smart-pixels/...
PulseSensor
The PulseSensor is a plug and play heart rate sensor for Arduino to gather live heart rate data for a variety of projects such as this one! The library that can be downloaded to Arduino (will be shown below shortly) has example codes to help you become an instant expert with implementing the PulseSensor into a project. The following link shows further information for the PulseSensor and describes example mini-projects to get persons started.
https://pulsesensor.com/pages/getting-advanced
Arduino Libraries
In order for the code to communicate with the Flora for certain functions and commands, the following libraries have to be installed into Arduino for the different electrical components. Use either this link or the one in the 'Intro and Supplies' section to download the software
- PulseSensor Playground
- (Note: The "PulseSensor_BPM" example Arduino file was helpful in creating the code for Breathe Light)
- Adafruit NeoPixel Library
- (Note: The "Strandtest" example Arduino file was helpful in creating the code for Breathe Light)
(Note: For further help on installing libraries, visit the following link: https://learn.adafruit.com/adafruit-all-about-ardu...)
GitHub
GitHub is a powerful platform that allows persons to build and share software together. The code created for Breathe Light is shared through GitHub and can be accessed here. It will also be referenced later in the instructable under Step 14. The Arduino libraries and examples mentioned above that are necessary for the project can also be accessed through the following GitHub links.
For more information on what GitHub is and why it is useful, watch this video.
Safety
When dealing with any electric circuit, including the one that you will create in this project, it is important to understand and follow all electrical safety protocols to keep your project safe and ensure that you do not get shocked. The following list details a few simple steps to follow.
- Do NOT have the Flora plugged into the computer when moving and attaching wires to the circuit.
- When touching wires or other metal components in the circuit, ensure that the power is OFF to avoid any current flowing through your body.
- Keep liquids, food, and anything else that may be spillable away from your circuit.
- Check for any frayed electrical wires each time before turning the power on.
WARNING:
This is NOT a medical device and should not be used in any clinical setting to rely on accurate heart rate measurements. Go see your doctor if you are wanting accurate heart rate data. This is simply a tool to help persons relieve stress, and should not be used to diagnose any condition.
Hints and Tips
Below are some hints and tips to keep in mind as you are building Breathe Light.
Troubleshooting Strategies
- If the code is not working properly, split up the different functions/sections of code and test those to determine where the problem is.
- Before jumping in with the code and project, use example codes given in the Arduino Libraries for the PulseSensor and NeoPixels to ensure that the devices work properly.
- Make sure that the PulseSensor has a tight and secure connection before gathering data to remove potential motion artifact.
- When wiring, use the same colored wires when connecting to the same ports to avoid confusion.
- Use small jumper cables to secure the wires down so that they will not lose connection when the device moves.
- If you have access to a soldering iron, consider using it to secure wire connections that may not be working well.
Insights
- To save time, test with alligator clips for prototyping before using wires.
- To save time and frustration, stretch out the wires tight to make a solid and constant connection with each NeoPixel.
- The Lego's are also very helpful in securing the Flora and battery pack.
Assembly Part 1a
Start by using an alligator clip to connect the #6 port on the FLORA . Then use another alligator clip to connect the GND port. Do the same with the VBATT port on the FLORA.
Assembly Part 1b
Now, connect the alligator clip connected to the 6 port to the inward facing arrow on the NeoPixel. Connect the GND port clip to the (-) on the NeoPixel and the VBATT port clip to the (+) on the NeoPixel.
We used this set up to test each NeoPixel to see if it was working using the instructions from the NeoPixel Adafruit page.
Assembly Part 2
Once you have confirmed each of the NeoPixels are functional, you can begin constructing the Breathe Light!
Start by connecting wires to the FLORA on the VBATT, #12, #6, GND, and #10. To avoid confusion, pick colors that will correspond to each of the ports. We will connect them to the breadboard in subsequent steps.
Assembly Part 3
Next, we will begin making the chain of NeoPixels. Like in the first step, we will eventually connect the (+) to the VBATT port, the (-) to the GND port, and the arrows will show the direction of signal flow in the line of NeoPixels. I started with the last one and worked my way up.
First, just add the wires to the NeoPixels in the corresponding colors. In the picture, you can see we used white for VBATT, green for GND, and yellow for the signal coming from port #6. Use the needle nose pliers to really wrap the wire around the little holes. You can also use cuticle cutters if you don't have needle nose pliers readily available.
(The small red wires in the background will be explained in subsequent steps. Don't worry about them for now.)
Assembly Part 4
Add wires to the other NeoPixels just like the first one. Make sure that the line of arrows is pointing from the port #6 on the FLORA to the bottom of the chain.
Then, connect each of the white wires to the (+) pins on the breadboard and the green wires to the (-) pins on the breadboard. Make sure the connections have some tension to secure the wires.
Assembly Part 5
Now, connect the green wire from the GND to the top of the (-) pins. Connect the white wire from the VBATT port to the (+) pins on the breadboard, and connect the #6 yellow wire to the beginning of your NeoPixel chain.
The purple wire and the red wire will be connected later.
(The red wires near the bottom help create tension between the yellow signal wires in between the NeoPixels, but you may not need them depending on how tight the connections are)
Assembly Part 6
Next, we will connect the button to our breadboard. This will begin the heart rate measurements and anxiety breathing exercise!
Place the button as seen in the picture. Then use a white wire to connect the top button pin to the (+). Place the 220 ohm resistor between the bottom pin on the same side and the (-) pins. Lastly, connect the #10 red wire to the bottom right button pin.
Assembly Step 7
Now, we will connect the Pulse Sensor! Connect the red sensor wire to the (+) pins on the breadboard and the black sensor wire to the (-) pins. Next, put the purple sensor wire and the purple wire coming from the #12 port in the same row to connect them.
Assembly Step 8
With assorted Legos, build a platform for the FLORA to sit on and a little cavity for the lithium battery pack. Make sure the FLORA has some tension on it for the yellow wires to connect properly. To do this, we used the yellow Legos seen in the picture above.
The Lego platform will vary in size depending on the size of your breadboard, but make sure the FLORA can sit flat, that there is some tension with the yellow signal wires, and that there is a cavity to insert the battery pack.
Assembly Step 9
To finish the assembly, add the Lego platform with the FLORA next to the breadboard. Connect the battery pack to the FLORA.
Assembly Step 10: Upload the Code and Finish Assembly!
The final step is uploading this code to Breathe Light. After the code is uploaded, the Breathe Light should work portably when the ON switch is activated in the middle of the FLORA!
How to get code from GitHub to Flora
- Use the link above to get to the GitHub website.
- Click on "Clone or Download"
- Click "Download ZIP"
- Save the downloaded zip file to the desired location on your computer.
- Open the "Breathe_Light_V3.0" file in Arduino.
- Under "Tools" on the top Arduino bar, go to "Board:" and select "Adafruit Flora"
- Finally (with the Flora plugged into your computer), click "Upload" (The right arrow at the top of your screen)
After the above steps are completed, the code should be uploaded to the Flora. The Flora can be disconnected from the computer and Breathe Light is ready for use!
Assembly Step 11: Code Explanation
This is what the code does:
First, the code collects the subject's initial heart rate using a PulseSensor and displays it through four individual NeoPixels that are in a line. Based on what heart rate is detected, a certain series of LEDs/colors will be displayed. For instance, if the heart rate is 76, there will be 3 NeoPixels that are lit up in blue. These colors/thresholds are given to the subject via a sticker on the device (seen above) so that they know what their heart rate is.
Then, after the heart rate is detected, it goes through an anxiety exercise which aids in deep, slow inhaling and exhaling. At the beginning of this exercise, all four LEDs are green. As the exercise goes on, the LEDs turn blue one by one which corresponds to when the subject should be inhaling. After all four LEDs are lit, the subject is to hold their breath, and as the LEDs turn back to green they can slowly exhale. After the anxiety exercise is performed, the code will again detect and display the person's heart rate again to determine if they were able to calm down.
Circuit Diagram
This circuit diagram was made in EAGLE. Everything within the big rectangle is the Adafruit FLORA microprocessor. It has a lot of detail, but as a whole, it is contained within the rectangle. All the components we added to the FLORA are under the big rectangle.
The 4 Neopixels can be seen connected to the D6* FLORA output. The button is connected to the IO10*, and the Pulse Sensor is connected to the FLORA through the IO12* port.
Downloads
Further Ideas
There are many ways in which Breathe Light could be taken further, and here are a few suggestions.
- Make it wearable: Use a headband or watch cuff (such as this one) and use conductive thread to make all of the wire connections.
- Add to the anxietyExercise () function to create a more visually appealing breathing exercise (such as adding more colors).
- Replace the individual NeoPixels with a NeoPixel Ring or a NeoPixel Array to add more LEDs and to increase the capabilities of both the heartRateDisplay() and anxietyExercise() functions.