Sleep Reader Headband

by KalebB23 in Circuits > Wearables

5082 Views, 43 Favorites, 0 Comments

Sleep Reader Headband

Sleep Tracking Brain Wave Headband

Have you ever wondered how you sleep at night? Devices like FitBit track sleep by analyzing your movement throughout the night, but they can't look at what your brain is doing.

After a semester of learning about medical instrumentation, our class was challenged with the task of creating a wearable device to measure some biological variable. My partner and I chose to develop a headband that can look at what your brain does while asleep. The headband reads brain wave signals to monitor sleep patterns. It identifies how the user's brain waves progress through alpha, beta, gamma, and delta phases during the night. The data can then be exported and analyzed in Excel.

Did we mention its stylish too?

Materials & Tools

IMG_2075.JPG

In order to build the Sleep Reader Headband, you will need the following materials:

  1. Headband (a HOTER Sportline Headband was used for this project)
  2. Adafruit Flora Microcontroller
  3. Flora Wearable Bluefruit LE Module
  4. Flora RGB Neo Pixel LED
  5. Snaps
  6. Conductive Thread
  7. Wires
  8. Thread
  9. Battery Pack
  10. Bitalino EEG with UC-E6 Cable and 3-Lead Electrode Cable
  11. Fabric
  12. Elastic strap

The following tools will aid you in constructing the headband:

  1. Sewing pin
  2. Scissors
  3. Wire strippers
  4. Soldering Iron and filler metal

Preparation

prep.jpg

Before building your Sleep Reader Headband, take some time to learn about brain waves and some basic circuitry. Within the brain, special cells known as neurons orchestrate different activities within the body. These neurons run the show by sending little electrical signals which take the form of waves. The brain is known to produce four different types of waves - alpha, beta, theta, and delta. These waves are distinguishable by specific ranges of frequencies, and each range corresponds with certain levels of mental activity. Your headband will use a device called an electroencephalogram, or EEG, to identify these waves as your brain produces them during sleep.

In order to make your Sleep Reader, you will need to wire up a few devices to the headband. The main devices are a microprocessor, which is a little computer; a Bluetooth module, which is a chip that allows the headband to communicate with your computer; a NeoPixel, which is a color-changing light; an EEG; and a battery.

The complete system is built by connecting each device together at specific locations via conductive thread. If you haven't had any experience with using these threads a tutorial is available here. The threads are tied into snaps that allow you to easily attach and remove the Flora microprocessor and the bluetooth module. One end of the snap will go in the fabric and another goes onto an electrical device. A tutorial for implementing these snaps is available here.

After the system is built, it must be provided with a code. This project specifically uses Arduino code. If you would like to familiarize yourself with Arduino code, https://www.arduino.cc is full of useful tutorials. In order to implement the code used for this project, you will need to download the Arduino app at https://www.arduino.cc/en/Main/Software. This will need to be supplemented with the Flora board, available here. You will also need to download a handful of other libraries to expand your microprocessor’s capabilities; this can be done using www.github.com. The necessary libraries are:

Lastly, you should download the Adafruit Bluefruit LE Connect App on your smart phone for use with the headband.

Safety

safetyfirst250x200.png

The human body can only withstand limited exposure to electricity, so proper care is needed when using electronic devices. The main principle of electrical safety is to avoid making your body a path for electric current to flow through in the powered circuit. Some general practices to avoid this are:

  • Only touch wires and other metal circuitry while power is OFF
  • Use tools with insulated handles
  • Try to keep water away from the work area when building your circuit
  • Try to work with one hand instead of two as much as possible to reduce risk of electrical current flowing through your heart

Another concern to be aware of when building you circuit is that electric current can ignite flammable materials, so you must ensure that wires are completely connected in the circuit. Otherwise, you could light your hair or the headband on fire.

Warning: This headband is not a certified medical device, and should not be used for diagnosis of neurological conditions.

Hints and Tips

IMG_2062.JPG

Here are some tips to keep in mind as you are constructing your Sleep Reader Headband:

  • Make sure the ends of the conductive thread are not touching each other after you tie them off
  • If the port is unavailable in Arduino when you connect the micro controller to Arduino, take the following steps to upload your code:
    1. While the micro controller is connected, upload the code while holding down the reset button on the microcontroller
    2. When the status bar switches from compiling to uploading, let go of the reset button
    3. The code should upload and the port should now be recognized
  • When soldering on the snaps, be careful to avoid soldering two pins together so that you do not short your circuit. A multimeter can be used to test whether or not a connection has been created between pins
  • Make sure that snaps stay connected when putting on the headband
  • Make sure that the bluetooth module is in data mode and not command mode
  • Once your headband has been constructed, you will want to ensure that it works effectively! In order to achieve a good signal, make sure you have clean contact between the electrodes and your forehead by wiping away dust, loose threads, hair, or other interferences.

Start Building Your Circuit!

close-up-of-excited-man-celebrating-a-triumph_1154-177.jpg

Now that you have been equipped with some background knowledge and safety procedures, you are ready to build hour headband. Read the following instructions carefully and notice the comments left on the images with further instructions.

Circuit Diagram

Screen Shot 2018-05-07 at 1.45.20 PM.png

The above circuit diagram shows the connections in the completed circuit. Use this circuit diagram as a reference to make sure your circuit has been wired properly.

Solder Snaps Into Flora Microprocessor

IMG_2069.JPG

If you didn't check out the link to the tutorial on how to use snaps in the "Preparation" step, check it out now. At this point you will connect the snaps to the microprocessor and bluetooth module. You don't want to mess this part up since a messy solder job can ruin your circuit.

The microprocessor will require snaps on the following pins:

  • All 3 ground (GND) pins
  • Both 3.3V power pins
  • SCL #3
  • RX #0
  • TX #1
  • Digital Pin #9

Solder Snaps Into Bluetooth Module

IMG_2070.JPG

And the bluetooth module will require snaps on these pins:

  • 3.3V power
  • TX
  • RX
  • GND

Sew Snaps Into Fabric for Flora Microprocessor

IMG_2072.JPG

Now you can sew the other end of the snaps onto the fabric. Make sure to use the bluetooth module and microprocessor with their attached snaps to line these snaps up properly!

Sew Snaps Into Fabric for Bluetooth Module

IMG_2073.JPG

Now sew in the snaps for the Bluetooth.

Wire Bluetooth Module to Flora Microprocessor

IMG_2065.JPG

Next connect the Bluetooth module to the Flora Microprocessor by sewing conductive thread between the respective snaps for each device. The following pin connections are required:

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

Wire Neo Pixel to Flora MicroProcessor

IMG_2080.JPG

Connect the Neo Pixel to the microprocessor in the following way:

  1. NeoPixel LED In to Microprocessor Digital Pin #9
  2. NeoPixel Ground to Microprocessor Ground
  3. NeoPixel Power to Microprocessor Power

Wire Battery Pack to Flora Microprocessor

IMG_2081 2.JPG

This part is kind of important; you might need a source of power to make everything work!

Build EEG Cable

IMG_2024.JPG

This cable is constructed using the EEG chip, 3-lead electrode cable, and UC-E6 cable. The EEG chip must be properly aligned so that the end that reads "EEG" is connected to the electrode cable, as shown in the image above.

Wire EEG to Flora Microprocessor

IMG_2082.JPG

Connect the EEG cable to the Flora microprocessor. The image above are labelled with instructions to show the proper points to connect your wires. The following connections will be made:

  1. Red wire to power
  2. Black wire to ground
  3. Purple wire to SCL #3

Stitch Electrodes Into Headband

IMG_2066.JPG

Sew the electrodes into the inside of the headband. Make sure that the electrodes are placed in the proper positions. Looking at the inside of the headband, the red electrode should be place on the left, the white electrode should be in the middle, and the black electrode should be on the right.

Stitch Cloth and Strap to Headband

IMG_2074.JPG

Now you have completed your headband! Woohoo!

Upload Code

321816-computer-code.jpg

Now you can upload this code to your headband to give it mind-reading abilities!

​Connect Headband to Phone

IMG_2083.JPG

Open the Adafruit Bluefruit LE Connect App and connect your phone to you Adafruit Bluefruit LE.

Put on Headband and Collect Data

IMG_2084.JPG

Now you can put on your headband and test it out! You can select "UART" on the Adafruit Bluefruit LE Connect app to view the data as it comes in.

Export Data From Phone to Computer

IMG_2088.JPG

Once your data has been collected, you can export the data in multiple file formats. We recommend exporting it as a .txt file for analysis in Excel.

Data Analysis

Screen Shot 2018-05-11 at 12.57.23 PM.png

Here's an example of the type of graph you can make to visualize and interpret the data from your headband. We have the delta, theta, alpha, and beta ranges all marked off to show which range each point falls within.

Further Ideas

AdobeStock_134530766.jpg

After you've completed your Sleep Reader Headband, feel free to explore some modifications to the design. Maybe try to modify the code to automatically collect the data and generate a report that assesses the user's sleep patterns. Or you could connect a real-time clock to monitor the exact time of night when the user falls asleep, progresses through deep sleep and REM sleep, and wakes up. Maybe you are interested in recording sleep talk, in which case you can include an audio recorder that is activated when the user hits REM sleep. The possibilities are endless!

Recognition

GettyImages-185002046-5772f4153df78cb62ce1ad69.jpg

The fourier transform portion of the code for this project used the code posted on this page on Norwegian Creations. Also, the NeoPixel portion of the code referenced the examples provided by Adafruit.