Backpack ECG

by gabigriffith27 in Circuits > Wearables

2921 Views, 14 Favorites, 0 Comments

Backpack ECG

ECG Backpack

When you look around college campuses today, there is one characteristic that seems to be the same at each: Stressed out students! Today's college student is often being pulled in multiple different directions due to social and academic pressures. This is causing many students to become overwhelmed, and often times results in poor performance in academics, athletics, and social interaction.

Throughout the semester, our class has being learning about biomedical instruments that can measure various biological signals from a patients body such as, muscle contraction, brain waves, and cardiac waves. We wanted to design a medical instrument that could be used to monitor a students stress levels using their heart rate. Our Electrocardiogram (ECG) Backpack is equipped with an ECG sensor that will track a patient's heart rate, and provide live feedback in the shape of an LED light and Bluetooth phone application. The ECG Backpack will alert the user with an LED when their stress levels are too high compared to a preset resting heart rate. The data from the mobile application can also be exported to Excel where further analysis can be carried out.

Materials & Tools

Materials.JPG

In order to create the ECG backpack, you will need the following items:

1. Backpack, any backpack will work however I found it easiest with a backpack with a front pocket in order to have a spot for all the wiring ($7.99)

2. Adafruit FLORA ($14.95)

3. Flora Wearable Bluefruit LE Module ($17.50)

4. LED (about $0.03 each)

5. Battery Pack ($12.50)

6. Potentiometer (found in arduino starter kit)

7. Conductive Thread ($6.99)

8.Snaps ($3.95)

9. Bitalino ECG with Sensor Cable and 3 Lead Electrode Cable (about $55 after converting from Euros to USD)

10. 220 ohm resistor (found in arduino starter kit)

11. 10 Alligator Clips ($5.99)

12. 3 thin small wires (found in arduino starter kit)

13. 3 Electrode Pads

Total estimated max cost: $125

Required tools in order to create the backpack ECG:

1. Scissors

2. Sewing Needle

Helpful tools in order to create the backpack ECG:

1. Soldering Iron and Filler Metal

2. Clear Nail polish

3. Thread

4. Electrical Tape

5. Sharpie

Preparation

2028_Cardiac_Cycle_vs_Electrocardiogram.jpg

In order to fully understand the ability of the ECG Backpack, you must first have a basic understanding of what an ECG captures. The ECG captures the electrical signals from the heart. During each cardiac cycle, the heart goes through several different systole (contraction) and diastole (relaxing), cycles, and each of these cycles correspond to the signal wave produced during a cardiac cycle. While looking at an ECG reading, we are looking to see 3 main sections: The P wave, the QRS complex and the T wave. The corresponding wave and action of the heart are shown in the picture above. The time between each QRS Complex allows for us to determine the heart rate. All of this will be provided with the code later on.

Along with a basic understanding of the method behind the ECG, you must have the ability to use Arduino code. This may mean that you will need to download the Arduino software. Arduino provides a full, in depth installation tutorial on their website. This can be accessed by clicking here. Along with the Arduino Software, you will also need to add the Flora board. A detailed instruction on how to do so can be found here. Lastly, you will need access to a GitHub Library for the Adafruit Bluetooth. That GitHub library can be found here.

Safety

Safety-manager.jpg

When working with electrical circuitry, there are few safety precautions that you should take:

  • When changing anything on the circuit, make sure the power is OFF or the circuit is unplugged.
  • Avoid having liquids or other foods around the circuit in case of a spill
  • For the ECG Backpack, do not wear during physical activity to avoid wires coming off the circuit or sweat getting into the hardware.
  • Work with insulated wires and tools to avoid being shocked

WARNING:
This is not a medical device and is only a tool to track heart rate. Please go see a doctor for more accurate heart rate reading and medical advice.

Hints & Tips

potentiometerplot.JPG

Here are some hints and tips in order to create your ECG backpack:

  • When soldering make sure to be clean and avoid soldering two pins together because this could short the circuit. A multimeter can be used for troubleshooting and can help verify if a faulty connection has been created
  • Make sure the lines of conductive thread do not cross with another line of conductive threads. This could cause a short circuit and potentially be dangerous.
  • Make sure the ends of the conductive thread do not touch each other after they are tied off
  • Make sure the boards are securely snapped when starting the ECG
  • When starting to collect data make sure the Flora board is switched “ON”
  • When choosing a backpack consider the size of the patient. For example, if you want to make this for an adult use a normal sized backpack. If you want to make it for a child use a smaller backpack. The straps further allow customization and will allow the electrodes to be placed in the right location

  • To save money, repurpose an old backpack that you already have

  • Make sure to have good connection with the electrodes and skin. Ways to get a good signal include cleaning the skins surface with an alcohol pad, removing dust or particles, making sure there is no interference

  • To save time, check if the LED and the potentiometer work correctly by using the two codes found in github, "potentiometercheck" and "LEDcheck", before running the entire ECG code. As shown in the image above, we can view the potentiometer's function in the serial plotter. When twisting the knob the line will spike up and eventually flatten, and when twisting the other way the slope will move downward until it hits a point where it flattens. This will be important to help adjust our ECG signal. The LED is functioning if the light turns on after uploading the code.
  • Label locations of snap pins and wires (including ground, pin numbers, and 3.3V) inside the bag with sharpie or a fabric market in order to stop future confusion

Circuit Diagram

Circuit Diagram_bb.jpg

Here is a circuit diagram of the connections that will be described in the following steps. For simplicity we have included a Fritzing Circuit Diagram that is easy to follow.

Circuit Diagram Continued

Schematic ECG Backpack.JPG

We have also included an Eagle diagram which shows the Bluefruit Bluetooth Module on the left outlined rectangle and the Flora on the right in the outlined rectangle. Also included is our potentiometer, LED, and ECG.

The ECG, LED, and resistor can be seen in the left hand corner that outlines the Flora microprocessor. The potentiometer is shown on the bottom right in the box that outlines the Flora microprocessor.

Begin Building Your Backpack ECG

ecg picture.JPG

Now that you have learned about the preparation, safety, and tips you can now begin to create your backpack ECG!

Solder Snaps Into Adafruit Flora

florasoldering.JPG

Snaps are a very useful tool in connecting our boards to fabrics. Adafruit has created a useful tutorial on how to use snaps and can be found here. It is important to be careful when soldering since a wrong connection could mess up the entire circuit.

The Flora microprocessor will need the following pins:

  • Both 3.3V power pins
  • RX #0
  • TX #1
  • 2 ground (GND) pins (our picture features all 3 ground pins but we learned we only needed to use the bottom left GND pin and the top left GND pin)
  • Digital Pin #9
  • Digital Pin #10

Note: a few pins in the picture (3rd GND pin and SCL #3 were actually unnecessary)

Solder Snaps Into Bluefruit Bluetooth Module

bluefruit.JPG

The Bluefruit Bluetooth module will require snaps on the following pins:

  • 3.3V power
  • TX
  • RX
  • GND

Sew Snaps and Wire Bluefruit Bluetooth to Flora

snapsbluetooth.JPG

First it is important to line up snaps with where they align on the microprocessor and Bluetooth module. This can be done by using chalk to draw on each snap and pressing both boards in their desired locations.

After this secure a snap by starting behind the backpack and loop through each of the four holes on the snap with the conductive thread.

In order to connect the Bluetooth module and the Flora you must sew conductive thread between the respective snaps.

Then you will secure the snap for the Bluetooth Module the same way as you did for the Flora. After completion tie a knot behind the backpack.

The following pins need to be connected in order to wire the Bluetooth to the Flora:

  1. Flora GND to Bluetooth GND
  2. Flora TX #1 to Bluetooth RX
  3. Flora RX #0 to Bluetooth TX
  4. Flora 3.3V to Bluetooth 3.3V

In the picture above the Bluetooth Module will be featured on the left and the Flora will be on the right.

Add Battery Pack to the Circuit

batter.JPG

Place a small hole under the Flora microprocessor to allow the battery wires to reach the board. After cutting this hole carefully pull the wires through and attach it to the board. At this point when the board is switched ON the Flora will have a green light and the Bluetooth module will have a blinking red light.

Attach Snaps That Will Power the Potentiometer and LED

snapsecg.JPG

Next we will add the snaps at the top of the Flora board.

These include snaps include:

  • GND which will attach to the LED and potentiometer
  • 3.3V which will attach to the potentiometer
  • pin #10 which will attach to the potentiometer
  • pin #9 which will attach to the LED

After attaching the snaps and pulling the wire through to the back of the backpack pocket I recommend leaving enough thread to continue stitching since some of these components will attach to more snap pins on the other side.

Attach Internal Snaps That Will Allow for Multiple Connections

Groundpin.JPG

Since many of the different components will have to connect to ground and 3.3V it is important to add another snap pin on the inside of the bag so that multiple alligator clips can latch on to this connection.

In the previous step we left extra thread in order to complete this step. Sew this snap pin the same way as before, paying extra attention to make sure wires do not cross each other.

The picture above shows an example of a internal snap that I used for ground.

Build ECG Cable

ECGwires.JPG

The cable is made by using the ECG chip, the 3-lead electrode cable, and the UC-E6 cable. The ECG chip which states "ECG" must be connected to the electrode cable. In order to connect the cables to the internal clips I attached alligator clips to the different components of the ECG.

Here is how I connected the different wires:

  • Red ECG wire to a Red Alligator Clip
  • Black ECG wire to Green Alligator Clip
  • Purple ECG wire to Blue Alligator Clip

Continue to Build ECG Cable

wirecont.JPG

Continue modifying your ECG cable by adding smaller wires to the alligator clips

Here is how I connected the different wires:

  • Red ECG wire to a Red Alligator Clip to orange wire
  • Black ECG wire to Green Alligator Clip to yellow wire
  • Purple ECG wire to Blue Alligator Clip to green wire

Electrical tape was added to secure the connection.

These small wires will eventually be connected directly to the Flora Board.

Cut a Hole to Allow ECG Wires to Move to the Top of the Bag

Hole.JPG

In the back corner of the front compartment where all your wires are located, cut a hole that connects to the main compartment of the backpack. This will allow for the ECG electrode wires and the Bitalino to be in the main compartment of the backpack.

Conveniently, I used a backpack that was originally used for medical purposes so it already had a hole in this location. The picture above shows the wires going through the hole.

Run ECG Wires Through the Backpack to Allow for Wires to Flow Down the Straps

backpack.JPG

As shown in the picture above, once the wires are pulled through the hole that we cut in the previous set (shown with the red box). You can then pull the wires up through the main compartment of the backpack and allow them to dangle from the top of the backpack.

Run ECG Electrode Cables Through Backpack Straps

strapsbackpack.JPG

Cut a hole at the top of each strap that goes to where the padding is on the strap. Run the wires down the back pack strap to their specified locations.

The black electrode should be on the right side of the user and positioned to be higher than the red electrode. The red electrode should be on the user's left side and lower down. The red and black electrodes should be diagonal to each other and across the heart. The white electrode needs to be placed on a bone. It can be placed at the top of a strap in order to be placed on a shoulder bone.

Wire ECG to Flora

attaching ECG wires.JPG

As described in a previous step the ECG was connected to alligator clips which were then connected to wires:

  • Red ECG wire to a Red Alligator Clip to orange wire
  • Black ECG wire to Green Alligator Clip to yellow wire
  • Purple ECG wire to Blue Alligator Clip to green wire

Then the wires needed to be connected to a pin #6(analog 7), ground (GND), and 3.3V.

A few small holes were placed in the bag to allow the wires to move from inside the bag to the front.

Here is a description of how each clip should connect to internal pins that are connected to the Flora:

  • The green wire(purple ECG wire) should be connected to pin #6
  • The orange wire(red ECG wire) should be connected 3.3V
  • The yellow wire(black ECG wire) should be connected to ground (GND)

The wires connected to ground and 3.3V were each wrapped around the respective snaps. The green wire was wrapped around pin #6.

Wire Potentiometer to Flora

potentiometersetup.JPG

The potentiometer must be wired to pin #10, ground, and 3.3V. All three of these locations are circled on the picture above. Pin #10 is just a thread that is connected to this snap on the Flora board. A diagram of how a potentiometer works is located here and can help in determining where each part of the potentiometer connects to your circuit.

Create a Small Hole to Allow for the User to See the LED

LEDhole.JPG

As shown in the picture above, create a small hole that allows for the LED light to poke through. The first yellow circle in the diagram shows the small hole in the before picture, and the second yellow circle on the right shows after the LED has been inserted. This picture was taken after the LED was wired, and was programmed to have the light turned on.

Wire LED to the Flora

LED wiring.JPG

To wire the LED:

  • Place the LED through the hole and press down the legs so they are flat against the backpack.
  • Attach the cathode (short leg) of the LED to an alligator clip and then to a 220 ohm resistor. Then attach another alligator clip to the resistor and clip that to the ground pin.
  • Attach the anode (the longer leg) of the LED to pin #9.

Step 20: Upload Code to Flora!

Downloading ECG Backpack Code From Github

The code to be uploaded to the Flora in order to use use the backpack can be found on GitHub by following the link here.

For additional help downloading the code and using the code, view the video above.

Before uploading the code, you may need to install the correct board for the Flora. Adafruit has a tutorial on how to do this with this link.

Now your ECG Backpack should be ready to go!

Adjust Code to Turn LED "ON" When Above Normal Resting Heart Rate Range

heartrateimage.jpg

View the normal resting heart rate for your age and gender from the chart provided above or from a doctor. Then go into the code provided in the previous step.

If your heart rate should stay below 90, keep the code the same. But if your heart rate should be below another number change the range in the code by seeing this portion of the code...

if(HR > 90)

{ digitalWrite(LEDpin, HIGH);

} // If the resting HR is above 90, or another preset HR, turn the LED on. HR number can be changed based off of chart in Instructable

Change the number based off of your personal range

Place Sticky Electrodes on Body

leadplacement.JPG

Place sticky electrodes on the person's body as shown in the image above. The green electrode in the picture will be placed on a bone on the shoulder. The red electrode in the picture represents the black lead of our ECG wires and the yellow represents the red lead of our ECG wire.

Snap Cables From the Backpack to Already Placed Electrodes

snapping.JPG

Electrodes can snap into each of the three locations on the backpack. Adjust the straps to accurately fit the user and allow the already placed electrode to be snapped onto the wires in the straps.

Adjust Potentiometer

adjustingpot.JPG

Plug the Flora into the computer and upload the code by pressing the arrow button at the top left corner. Once it is completely uploaded selected the serial plotter. When twisting the potentiometer you should see a line move in the graph. Make sure the potentiometer is being hit by the top of the "QRS" complex as shown in the figure above, in order to get an accurate heart rate reading. Without a correctly set potentiometer the heart rate calculation could be very inaccurate.

Download Bluefruit LE Connect

Bluefruitapp.JPG

Download the Bluefruit LE connect app described on this website. This will allow you to get your data to your phone from the Bluetooth monitor.

Connect Phone to Bluetooth

connect to bluefruit.JPG

Click on the app and then connect to the Adafruit Bluefruit LE shown above. Then click "Uart" after that the data will appear with heart rate being the first number in the line.

Wear Backpack

BackpackECG.JPG

Begin by turning on the Flora. Then wear the backpack while doing activities that do not involve a large amount of movement. Movement can cause motion artifact so it is best to avoid running and jumping.

Export Data

gear.JPG

Then hit the gear picture at the top right of the app and then hit export. This will allow you to email the data in a text file to yourself or to someone else who would like to analyze the data.

View Data in Excel to See ECG

newecggraph.JPG

Place all the data into excel. Then select all the data then graph a line chart. The threshold for the potentiometer is the yellow line and the heart beat is the grey line. Heart rate is determined by the beats per minute, so how many times the grey line touches the yellow line in a minute.

Further Ideas

pressure.JPG

This design could be further improved by...

  • Creating a location where the potentiometer is more accessible and easier to adjust. As of now every time I want to adjust the bag I have to open the pocket with all my wiring to find the potentiometer.
  • Adding another sensor such as a pressure sensor to track respiratory rate. This would allow us to see when a person's breathing rate is elevated to monitor patient's stress and relaxation. Since backpacks usually have a strap that can go across the chest this would be a convenient place to put the sensor.

Final Product

heartrate.JPG
backpacknew.JPG

Pictured above is the data received from the Bluetooth application to my phone. The heart rate is shown to be 96 during this time frame. The data was compared to the heart rate found by an apple watch and was found to be very similar ranging between 95-98 beats per minute during the same time frame. As shown above the LED is turned on because the heart rate is greater than 90. This number was used because it was greater than the user's resting heart rate, and indicates higher levels of stress and anxiety.