Introduction: Sleep Reader 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?
Step 1: Materials & Tools
In order to build the Sleep Reader Headband, you will need the following materials:
- Headband (a HOTER Sportline Headband was used for this project)
- Adafruit Flora Microcontroller
- Flora Wearable Bluefruit LE Module
- Flora RGB Neo Pixel LED
- Conductive Thread
- Battery Pack
- Bitalino EEG with UC-E6 Cable and 3-Lead Electrode Cable
- Elastic strap
The following tools will aid you in constructing the headband:
- Sewing pin
- Wire strippers
- Soldering Iron and filler metal
Step 2: Preparation
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.
Step 3: Safety
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.
Step 4: Hints and Tips
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:
- While the micro controller is connected, upload the code while holding down the reset button on the microcontroller
- When the status bar switches from compiling to uploading, let go of the reset button
- 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.
Step 5: Start Building Your Circuit!
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.
Step 6: Circuit Diagram
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.
Step 7: Solder Snaps Into Flora Microprocessor
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
Step 8: Solder Snaps Into Bluetooth Module
And the bluetooth module will require snaps on these pins:
- 3.3V power
Step 9: Sew Snaps Into Fabric for Flora Microprocessor
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!
Step 10: Sew Snaps Into Fabric for Bluetooth Module
Now sew in the snaps for the Bluetooth.
Step 11: Wire Bluetooth Module to Flora Microprocessor
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:
- Bluetooth 3.3V to Microprocessor 3.3V
- Bluetooth TX to Microprocessor RX #0
- Bluetooth RX to Microprocessor TX #1
- Bluetooth GND to Microprocessor GND
Step 12: Wire Neo Pixel to Flora MicroProcessor
Connect the Neo Pixel to the microprocessor in the following way:
- NeoPixel LED In to Microprocessor Digital Pin #9
- NeoPixel Ground to Microprocessor Ground
- NeoPixel Power to Microprocessor Power
Step 13: Wire Battery Pack to Flora Microprocessor
This part is kind of important; you might need a source of power to make everything work!
Step 14: Build EEG Cable
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.
Step 15: Wire EEG to Flora Microprocessor
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:
- Red wire to power
- Black wire to ground
- Purple wire to SCL #3
Step 16: Stitch Electrodes Into Headband
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.
Step 17: Stitch Cloth and Strap to Headband
Now you have completed your headband! Woohoo!
Step 18: Upload Code
Now you can upload this code to your headband to give it mind-reading abilities!
Step 19: Connect Headband to Phone
Open the Adafruit Bluefruit LE Connect App and connect your phone to you Adafruit Bluefruit LE.
Step 20: Put on Headband and Collect Data
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.
Step 21: Export Data From Phone to Computer
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.
Step 22: Data Analysis
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.
Step 23: Further Ideas
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!
Step 24: Recognition
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.
This is an entry in the
We have a be nice policy.
Please be positive and constructive.