Introduction: Connecting NeuroSky's MindWave Mobile With PJRC's Teensy

Tutorial for connecting a Teensy and NeuroSky MindWave Mobile using a BlueSMiRF Silver bluetooth module.

Materials needed:

  • Teensy (In this tutorial, I am using the Teensy 3.1, but you'll be able to use this tutorial with other versions of the Teensy)
  • BlueSMiRF Silver bluetooth module
  • A way to connect the two, such as: Breadboard, Solidcore wire, male headers
  • A computer with bluetooth capability (or a bluetooth USB dongle to add bluetooth capability to your computer)
  • A Terminal software, such as CoolTerm or RealTerm (this tutorial makes use of CoolTerm)
  • NeuroSky's MindWave Mobile headset

Intro:

The NeuroSky MindWave Mobile is NeuroSky's EEG headset that is bluetooth compatible (it is colored black, as opposed to their MindWave, which is white and is not bluetooth compatible). It outputs raw EEG data as well as "eSense" values for Meditation and Attention. These eSense values are processed inside the headset and, although NeuroSky does not reveal the algorithms they use, these values do seem to actually mean what they are supposed to.

The Teensy is a great tool for working with the MindWave Mobile. It is smaller and more powerful than many Arduinos (especially ones that are novice-friendly). The extra processing power should allow you to process the MindWave Mobile's raw data more than an Arduino might.

The BlueSMiRF Silver is a bluetooth module from Sparkfun. The onboard chip that does the actual bluetooth communication is called the RN-42. This chip allows wireless communication up to 18 meters. The BlueSMiRF Gold is similar but uses the RN-41 chip, which has a range of 100 meters but draws much more current. Unless you need your Teensy to communicate more than 18 meters from the MindWave Mobile, you should choose the BlueSMiRF Silver to save battery power. The Bluetooth Mate Silver and Gold boards are the same as the BlueSMiRF Silver and Gold boards but with the pins in a different order (to make it more compatible with the Arduino Pro board).

Overview:

First you will determine the MAC address or unique identifier of your MindWave Mobile headset. Using this address, you will make the BlueSMiRF look to connect to this headset as soon as it is turned on. Be warned though, once you configure your BlueSMiRF to look exlusively for the headset, it will not be able to connect to your computer unless you reset it to factory settings.

Then you will hardwire your BlueSMiRF to your Teensy, so that the two can communicate and so that the BlueSMiRF can be powered by the Teensy.

Next you will connect the BlueSMiRF board with your computer and configure it using your terminal software (e.g. CoolTerm).

Finally you will test your connection using a sample code that reads the EEG data from the MindWave Mobile!

Step 1: Determine the MAC Address or Unique Identifier of Mindwave Mobile

  1. Turn on your MindWave Mobile headset. Hold the on switch in the 'pair' position (further than the 'on' position) for 3 seconds or until the LED starts to 'double-blink' blue. Your headset is now discoverable. (A list of the MindWave Mobile LED states and what they indicate: s3.amazonaws.com/entp-tender-production/assets/e1448439b28d6760c8f6ce254d5da811dc89ec5f/mwm_led.pdf?)
  2. On your computer, open the window which adds a bluetooth device (on a PC: "Add a Bluetooth Device").
  3. Pair the headset with your computer. Check that the headset is paired by looking for it in your computer's list of devices.
  4. Find the MAC address or Unique Identifier of your headset. This is a 12 digit hexadecimal value. In windows, I open "Devices and Printers" right-click on MindWave Mobile, select "properties" and move to the "Bluetooth" tab. Write down the 12 digit value for your headset. Save this for later.

Step 2: ​Hardwiring Teensy and BlueSMiRF

Although you could solder wires directly to your two devices, this tutorial will explain how to hardwire the devices using a breadboard.

  1. Solder male headers to your Teensy if your Teensy does not already have headers.
  2. Solder male headers to your BlueSMiRF.
  3. Use the breadboard and jumper cables (or solid core wire) to make the following connections (see pictures):

[BlueSMiRF--->Teensy]

VCC--->3.3V (I use the 100mA maximum pin because the BlueSMiRF Silver board uses 50mA max, but the other 3.3V pin is okay too. If you are breadboarding and want to use the 3.3V pin on the short side of the Teensy, you will need to use female headers that come up away from the breadboard instead of male headers that go down into the breadboard. Using male headers would mean that these pins would be connected to each other in the breadboard.)

GND--->GND (Again, I used the GND near the USB port. You could instead use the GND pin on the short side.)

TX-0--->RX (TX is transmit and RX is receive. I used pin 9 which is RX2, but you can use RX1 or 3 as well. Just make sure you use the same for your TX pin. In other words, use pins 0/1, 9/10, or 7/8. Also, your code will vary depending on which serial pins you choose to use on the Teensy. You will call Serial1 if you connect to 0/1, Serial2 for 9/10, and Serial3 for 7/8.

RX-1--->TX (This is optional. This would only be necessary if you wanted to send a signal to the MindWave Mobile headset from your Teensy, which you would only do if you wanted to change the headset's settings. Read more about changing the headset's settings in the headset user manual. One user reported that making this connection causes a bug, so you may want to skip this step if you are running into unknown difficulties and do not need to send any information to the headset. However, I have not experienced this bug.)

You will also want to short the CTS-1 and RTS-0 pins. CTS stands for clear-to-send and RTS is reqeust-to-send. The BlueSMiRF sends a RTS signal and waits for a CTS signal from the Teensy. Instead of using this protocol, you can short the CTS and RTS pins so that your BlueSMiRF immediately gets a CTS signal upon sending a RTS signal. Additionally, you are able to short these pins by soldering together the pads on the back of the board instead of connecting wires between the pins (see picture). Read more about flow control here.

Step 3: Configure BlueSMiRF Using Terminal Software

  1. Power on your Teensy (and therefore BlueSMiRF). Your BlueSMiRF will begin to blink red.
  2. On your computer, open "Add a Bluetooth Device" and connect your BlueSMiRF. Mine is listed as RNBT-77AC.
  3. Your computer may ask about a pairing code. The board is preset to have a pairing code of 1234. If this is not a new board, the pairing code may have been changed and you will need to reset your BlueSMiRF to factory settings (see additional resources section).
  4. Right-click on the BlueSMiRF and open properties. In the "Hardware" tab, find what COM port you are connected with. Mine says "Standard Serial over Bluetooth link (COM14), so I note down COM14.
  5. Open your terminal software, such as CoolTerm. In the options, change the port to your COM port and change your Baudrate to 115200 (this is the default communication rate for the BlueSMiRF). Select "terminal" in the sidebar and turn on Local Echo (this will allow you to see what you are typing when you configure your BlueSMiRF).
  6. Click Connect. Type $$$. If this works, the program will output CMD and the red LED will begin to blink very fast. If this does not work, you will need to try again. This might take some tries, and you might need to turn off and turn on your BlueSMiRF. Stick with it, you've got it.
  7. Once you're able to type $$$ and see CMD, you've entered command mode and can configure your board. Use the following commands to configure your board:

SP,0000

This changes the pairing code from 1234 to 0000, meaning that you do not need to enter a code to pair.

SM,3

This changes your board to autoconnect mode, meaning that as soon as it is powered on, it will look to connect to your MindWave Mobile.

SA,0

This changes the authentication mode to no authentication

SR,Unique Identifier code (the value you wrote down in section 1, with no periods or colons)

This tells the board what bluetooth device to look to pair with.

SU,57.6

This changes the baudrate to 57600, the default communication rate of the headset.

D

This will output the new settings of your board. Make sure the settings have changed how you want them to, but especially make sure the unique identifier has no typos.

--- (three minus signs)

This will exit command mode. The red LED should stop blinking, leaving only the green LED.

You can now click disconnect and close CoolTerm. Your board is configured!

Step 4: Test Code

Download the zip file below and rename it Teensy-MindWave-tutorial.zip. Then, without first expanding the zip file, add it to your Arduino IDE: "sketch --> include library --> Add .Zip Library --> (select the .zip file)"

Open the example by following "file --> Examples --> Teensy-MindWave-tutorial". Upload the example to your Teensy and see it work! You may have to change "Serial1" in the source file (.cpp) to "Serial2" or "Serial3" depending on how you connected your BlueSMiRF.

If the code is working, you should see the onboard LED turn on when your headset is communicating with your Teensy and has a good connection with your skin, and you should be able to read the eSense outputs by opening the serial monitor (button in top right corner of Arduino IDE). Have fun controlling your Teensy with your brain!!

Step 5: Additional Resources

  • Youtube video showing how to reset your BlueSMiRF to factory settings, in case you enter the wrong MAC address, don't know the pairing code, or otherwise are stumped and don't know what else to try:

  • A list of opensource codes for MindWave Mobile: pantechsolutions.net/blog/list-of-source-codes-available-for-neurosky-mindwave-mobile/
  • NeuroSky's guide for working with the MindWave Mobile when using a microcontroller: