Mindwave Mobile & Arduino
Mindwave Mobile & Arduino
Features
Interfaces with the MindWave Mobile with an Arduino board via BlueSMiRF Silver module
Acquiring the Attention and Meditation eSense values from the data stream.
Displaying your Attention level using LEDs
Introduction
This step-by-step guide is intended to quickly get a typical Arduino board user up and running with
the MindWave Mobile. This guide will show how to setup the BlueSMiRF Silver quickly for
communication with the MindWave Mobile and gives example code to parse the output stream. The
parsed output stream can then be used to perform various tasks such as to control the speed of a
motor, to light up LEDs, and to control the position of a servo motor, etc.
Required Materials
This application requires the following materials:
MindWave Mobile
Arduino Diecimila was used to develop (please see the note below if you are using a Mega
2560 or Uno)
BlueSMiRF Silver/Gold, https://www.sparkfun.com/products/10269
Terminal software, such as CoolTerm, RealTerm, or Terminal
Arduino development environment
Avago HDSP-4832 10-Element LED bar graph array
4 75 resistors
6 47 resistors
Breadboard
12V Power Source (included with Arduino Board)
Bluetooth dongle, if your computer does not have internal bluetooth capabilities
System Overview
The system uses the Aduino's hardware UART for both USB communication and Bluetooth
communication.
The basic setup flow is as follows:
1. Pair the MindWave Mobile to your computer to determine the MAC address
2. Connecting the BlueSMiRF to your Arduino board
3. Pair the BlueSMiRF to your computer to configure the device
4. Connect the LED array to the Arduino board.
5. Download the provided example code into the Arduino board using the Arduino development
environment.
6. Power up the whole system and observe the Attention eSense value on the LED array.
Detailed Instructions
Determining the MAC address of your MindWave Mobile
1. Open Bluetooth Settings on your computer, and click Add a Device or New Connection
2. To make the MindWave Mobile discoverable, power on the headset. Once the LED turns on,
hold the power switch up for 4-5 seconds, until the LED begins to double-blink. It is now
discoverable.
3. Pair the MindWave Mobile, and determine it's MAC address, which is a 12 digit hexadecimal
value
4. Write this down, we will use this value later
Connecting the BlueSMiRF to your Arduino Board
You can solder headers to the BlueSMiRF module, and then use jumper wires to connect to the Arduino
board. I soldered wires directly to the BlueSMiRF. Either method will work.
1. Short RTS and CTS together. I soldered a wire between the RTS and CTS.
2. Connect BlueSMiRF Vcc to Arduino's 3v3.
3. Connect BlueSMiRF GND to Arduino GND
4. Connect BlueSMiRF TX to Arduino RX
5. Connect BlueSMiRF RX to Arduino TX
Powering the Arduino
The Arduino may be powered by USB, by battery, or by an external power supply. Please see the
Arduino hardware page here http://arduino.cc/en/Main/Hardware for more information.
Configuring your BlueSMiRF Module
1. Once you power up your Arduino board and have the BlueSMiRF connected, you will see a red
LED blink on your BlueSMiRF module.
2. Pair the BlueSMiRF to your computer. It will appear, as similar to, RN-42-5922.
I. The Default Baud Rate is 115200
3. Open your Terminal Software, and connect the BlueSMiRF. The LED will turn green when it's
connected.
I. This may take a few tries. You can power cycle the Arduino if you experience issues.
4. Be sure to enable Local Echo to be able to view your input commands.
5. To put the BlueSMiRF into COMMAND mode, type $$$. Please reference this
website:http://www.sparkfun.com/datasheets/Wireless/Bluetooth/rn-bluetooth-um.pdf
I. If successful, you will see CMD
6. Type: D
I. You will see the current configuration of the BlueSMiRF.
7. Now type: SP,0000
I. This will change the pincode from '1234' to '0000'
8. Now type: SM,3
I. This will configure the BlueSMiRF to Auto-Connect Mode. Once the module is powered
up, it will immediately look to connect.
II. You should see AOK if this is done properly.
9. Now type: SR,MAC ADDRESS
I. Insert the 12 digit address you copied from the MindWave Mobile.
II. Again, look for AOK.
10. Now type: SU,57.6
I. This will change the BaudRate from 115200 to 57600
11. Type: D
I. Check to be sure that the stored address is the Mac address, and it's configure to Auto,
not Slave
12. Type: (three minus signs)
I. This will exit out of Coolterm. If successful, you will see END.
Checking BlueSMiRF configuration
1. Power on your MindWave Mobile headset
2. Power on your Arduino + BlueSMiRF board.
3. If the BlueSMiRF LED turns green, and the MindWave Mobile LED turns solid blue, you are now
connected and receiving data from the MindWave Mobile.
I. If not, please retry to configure your BlueSMiRF or check the proper MAC address/
Note for Arduino Mega 2560 and Arduino Uno Users
Do not attach the BlueSMiRF Rx / Arduino Tx connection. This will cause a communication bug.
Circuit Schematic
Sample Code
Sample Code
Running the Sample Code
1. Once you have synced the program and your board, disconnect the TX and RX lines coming out
of the Arduino
2. File > Upload to I/O Board
3. Once the program displays Done Uploading, you can disconnect the USB serial port and run
the Arduino from independent power source.
4. Reconnect TX and RX lines.
5. Power up the Arduino Board via power source
6. Arduino should have green PWR LED lit and dongle should have red LED lit
7. Turn on Mindwave Mobile Headset
8. Hit Reset button to pair the MindWave to the dongle.
9. Once connected MindWave Mobile LED will turn blue and BlueSMiRF will turn green.
10. Enjoy observing your Attention eSense value on the LED array.
Getting started with the Arduino development environment
Please see Arduino Getting Started guide here http://arduino.cc/en/Guide/HomePage
Arduino Code Description
Arduino code is based on the C/C++ language and requires very little else to get started. All the details or
regular microprocessor development such as processor clock speed, programming speed, clock sources,
etc. are all initialized by the Arduino core. With this in mind, the Arduino system will still be able to
perform much of the required tasks with no problem at all. The simplicity of using the microprocessor
peripherals combined with the C language along with the sample code provided provides for very quick
interface to theMindSet. The user is encouraged to extend the Arduino code by appending code after
the indicated section where the packet has been checked for a valid checksum.
Thereafter, the user may use the eSense values to do one of many things possible. Some of which is to
control the brightness of an LED, the height of an object, etc.
The bulk of the code is used for parsing the packet data. For further information, see
theMindSet Communication Protocol document in the MindSet Development tools (MDT). The MDT is
available at the NeuroSky Store for free. http://store.neurosky.com
Material Sources
The Level Converter and Arduino board can be obtained from:
Sparkfun Electronics
6175 Longbow Drive, Suite 200
Boulder, CO 80301
http://www.sparkfun.com
MindWave and Arduino
Features
Interfaces with the MindWave with the RF USB dongle for stand-alone operation
Acquiring the Attention and Meditation eSense values from the data stream.
Displaying your Attention level using LEDs
WARNING
NOTE: Completing this tutorial will VOID your warranty. The USB dongle will no longer work with your
computer. Please visit store.neurosky.com to purchase replacement dongles
Introduction
This step-by-step guide is intended to quickly get a typical Arduino board user up and running with
the MindWave. This guide will show how to setup quickly for communication with theMindWave and
gives example code to parse the output stream. The parsed output stream can then be used to perform
various tasks such as to control the speed of a motor, to light up LEDs, and to control the position of a
servo motor, etc.
Interfacing to the MindWave
Interfacing to the MindWave requires the user to hack the USB dongle.The following describes easiest
way to quickly get up and running using an Arduino board. The Arduino is sold by a vendor listed in the
sources section. The MindWave and USB dongle are available at theNeuroSky Store.
Required Materials
This application requires the following materials:
MindWave
Arduino Diecimila or Duemilanove
RF USB dongle
Arduino development environment
Avago HDSP-4832 10-Element LED bar graph array
4 75 resistors
6 74 resistors
Breadboard
SparkFun BOB-08745 Level Converter
12V Power Source (included with Arduino Board)
System Overview
The system uses the Aduino's hardware UART for both USB communication and Bluetooth
communication. After the system is up and running, the Arduino may be detached from the computer
and run independently.
The basic programming flow is as follows:
1. Connect the dongle to the Arduino board..
2. Connect the LED array to the Arduino board.
3. Download the provided example code into the Arduino board using the Arduino development
environment.
4. Power up the whole system and observe the Attention eSense value on the LED array.
Detailed Instructions
Connecting the dongle to the Arduino Board
Connecting the dongle to the Arduino Board requires removing the plastic covering from the dongle and
soldering wires to 4 of the pins.
1. Remove the plastic covering from the USB dongle.
2. Once the cover is off, you should see the board shown below (Note: Bottom View Orientation)
3. Find the 4 pins, located in the center of the board.
4. Starting at the end with the + sign the pin assignments are:
I. Pin 1 (starting at +): 3.0 V Power
II. Pin 2 : TX
III. Pin 3 : RX
IV. Pin 4 : Ground
5. Solder wires to these 4 pins, leaving enough wire to make the necessary adjustments.
6. Connect the boards together, according to the schematic shown below
Cutting Traces on the dongle
In order to for the dongle to properly receive the TX signal from the Arduino, two traces on the board
must be cut. Looking at the dongle from the top, there are two traces leading from the TX and RX pins to
the CH340 chip. With an X-Acto knife, cut these two traces. After the traces have been cut, check the
connections with a DMM to ensure that the CH340 chip (pins 3 &4) is no longer connected to the TX and
RX pins. NOTE: You will not be able to use the USB dongle with a computer after cutting the traces
Powering the Arduino
The Arduino may be powered by USB, by battery, or by an external power supply. Please see the
Arduino hardware page here http://arduino.cc/en/Main/Hardware for more information.
Getting started with the Arduino development environment
Please see Arduino Getting Started guide here http://arduino.cc/en/Guide/HomePage
Arduino Code Description
Arduino code is based on the C/C++ language and requires very little else to get started. All the details or
regular microprocessor development such as processor clock speed, programming speed, clock sources,
etc. are all initialized by the Arduino core. With this in mind, the Arduino system will still be able to
perform much of the required tasks with no problem at all. The simplicity of using the microprocessor
peripherals combined with the C language along with the sample code provided provides for very quick
interface to theMindSet. The user is encouraged to extend the Arduino code by appending code after
the indicated section where the packet has been checked for a valid checksum.
Thereafter, the user may use the eSense values to do one of many things possible. Some of which is to
control the brightness of an LED, the height of an object, etc.
The bulk of the code is used for parsing the packet data. For further information, see
theMindSet Communication Protocol document in the MindSet Development tools (MDT). The MDT is
available at the NeuroSky Store for free. http://store.neurosky.com
Syncing the Arduino Board
1. Open Mind_Wave.pde
2. Tools > Board > Arduino Diecimila
3. In Control Panel > Select Device Manager
I. Look in Ports to see which COM port the USB Serial Port is connected to
4. Tools > Serial Port > Select the corresponding COM port
Running Mind_Wave.pde
1. Once you have synced the program and your board, disconnect the TX and RX lines coming out
of the Arduino
2. File > Upload to I/O Board
3. Once the program displays Done Uploading, you can disconnect the USB serial port and run
the Arduino from independent power source.
4. Reconnect TX and RX lines.
5. Power up the Arduino Board via power source
6. Arduino should have green PWR LED lit and dongle should have red LED lit
7. Turn on Mindwave Headset
8. Hit Reset button to pair the MindWave to the dongle.
9. Once connected MindWave LED and dongle LED will both turn blue.
10. Enjoy observing your Attention eSense value on the LED array.
Switching to Attention/Meditation Mode
The default eSense reading in Mind_Wave.pde is attention. To switch the program to measure your
meditation level, requires changing a few lines of code. Inside the pde file, locate the code shown below.
Inside these lines of code, replace attention with meditation to operate in meditation. If you are
switching back to attention mode, replace meditation with attention.
The code can be downloaded here:
Mind_Wave. Note that this is in a docx format. Simply rename the extension from docx topde and run
the program.
Material Sources
The Arduino board can be obtained from:
Sparkfun Electronics
6175 Longbow Drive, Suite 200
Boulder, CO 80301
http://www.sparkfun.com