Está en la página 1de 46

Mindwave Mobile

Mindwave mobile, Neuro sky is the manufacturer of Mindwave mobile. The NeuroSky biosensor
platform provides a powerful foundation for the development of a variety of applications that
promote Mind health such as improved focus, concentration, working memory and acuity. Other
uses include meditation and relaxation monitoring or improved educational processes. Our low
cost, complete OEM solution is a high-performance bio-signal on a single chip solution for
accurate Mind activity detection and processing.

Bluetooth Module (HC-05)

It's a high performance Bluetooth module HC-05. This is a standalone BTM-05 Bluetooth
module. Its works as TTL Master/Slave Transceiver module with serial UART protocol for
communication. Designed by Full speed Bluetooth operation with full piconet support. It allows
you to achieve the industry's highest levels of sensitivity, accuracy, with lowest power
consumption.

PROJECT DESCRIPTION

Connecting wires:

The connecting wires are both sides having female type, because Arduino and HC-05 models are
having male type connector for interfacing.

HC-05 module data communication:

 Serial Interface UART

Configuration of HC-05:

 Its configure as master mode


 Mindwave Kit act as slave device

Hardware's:

 Mindwave Mobile Kit


 Arduino Board
 HC-05 Bluetooth Module
 USB cable (for Arduino)
 Connecting Wires.

Software's:

 Cool Term ,X-CTU (any serial communication software)


 Arduino 1.0.5-r2

Front view of HC-05 Module

Rear view of HC-05 Module


Find the Unique number of your Mindwave Device

1. Select your Mindwave device

Right click → Properties → Bluetooth Then know your Unique Identifier Number (Note it)
Example: This module Unique no =9cb7,0d,89e51c

Diagram for HC-05 Bluetooth Module with Arduino:

Method 1 for AT Commands


Note: Here the Arduino Board used only for USB to UART converter. So don't want to
download any source code (Sketch) to board.

Real view of Arduino with HC-05 Module


Modes of HC-05 Bluetooth Module:

How to HC-05 Module Enter into Command mode:

Press and Hold the Push switch in HC-05 module at few secs, when its power ON (In between
OFF state to ON state).

If HC-05 Module in Command mode means, the LED blink at low toggle (blinking slowly).

Buadrate for Command Mode

In command mode the HC-05 module works in 38400 buadrate (fixed buadrate).

How to HC-05 Module Enter into Data mode:

In default state, the HC-05 module works as a Data mode operation.

If HC-05 Module in Data mode means, the LED blink at High toggle.
Buadrate for Data Mode

In Data mode the HC-05 module works in variable buadrate.

AT Commands for HC-05 Module Initialize for Mindwave Kit

First Enter into command mode, after then enter the following commands for HC-05 module to
communicate our Mindwave Kit.

1. AT+NAME=”PANTECH”

2. AT+UART=”57600,0,0”

3. AT+ROLE=”1”

4. AT+PSWD=”1234”

5. AT+CMODE=”0”

6. AT+BIND=”XXXX,YY,ZZZZZZ” (Mindwave Unique Number)

7. AT+IAC=”9E8B33”
8. AT+CLASS=”0”

9. AT+INQM=”1,9,48”

Verification commands for HC-05 Module

1. AT

OK

2. AT+UART?

UART:57600,0,0
OK

3. AT+ROLE?

+ROLE:1

OK

4. AT+PSWD?

+PSWD:1234

OK
5. AT+CMODE?

+CMODE:0

OK

6. AT+BIND?

BIND:9cb7:0d:89e51c

OK

7. AT+IAC?

IAC:9E8B33

OK

8. AT+INQM?

+INQM:1,7,48

OK

Note1: For using above AT commands don't use “(Double quotes) only enter In-between
commands from double quotes. After the end of every command press “Enter Key”
Open serial communication software

(Here we have to use Flashmagic software)

1. Select your Port and set Baudrate is 38400

2. Enter the AT commands (Initialize)


3. Enter the AT commands (Verification)
Some Tips about HC-05 Module Configuration
1. HC-05 module configure as Mater device and Mindwave kit act as Slave device

2. And the HC-05 module was configuring as Specific address mode. Therefore it's Pair with
only the specific device

3. Here the specific device is our Mindwave kit (Using BIND AT command, we configured the
Mindwave unique no to HC-05).

4. So the Mindwave and HC-05 module automatically paired, when we switch ON the both
device.

INTERFACING ARDUINO WITH MINDWAVE KIT

Connection Diagram
Steps to follow

1. Switch ON the Mindwave kit and unpaired the last connections, then OFF the Mindwave
device.

2. Program (Upload the sketch) the “Mindwave with Arduino” source code to Arduino Board
using Arduino compiler.

3. Open the “Serial Monitor” in Arduino compiler with 57600 baudrate.


4. Make all the connection as per the above image, and then switch ON the Arduino Board.

5. After the 7 Seconds, switch ON the Mindwave device.

6. Now the Mindwave device and Arduino Board will pair automatically.

7. Wear the Mindwave device in Head, and give the attention.

8. Check the LED variation with respect your attention level.

9. And also see the Serial Monitor to know your Poor quality and attention levels.

Real view1 of Arduino with Mindwave Kit


Upload the sketch to Arduino board
LED's Output (variation w.r.t Attention level)
Serial Monitor Output
Program for Interfacing Arduino with Mindwave Kit

Title: Mindwave with Arduino

////////////////////////////////////////////////////////////////////////

// Arduino Bluetooth Interface with Mindwave

//

// This is example code provided by NeuroSky, Inc. and is provided

// license free.
////////////////////////////////////////////////////////////////////////

#define LED 13

#define BAUDRATE 57600

#define DEBUGOUTPUT 0

#define GREENLED1 3

#define GREENLED2 4

#define GREENLED3 5

#define YELLOWLED1 6

#define YELLOWLED2 7

#define YELLOWLED3 8

#define YELLOWLED4 9

#define REDLED1 10

#define REDLED2 11

#define REDLED3 12

#define powercontrol 10

// checksum variables

byte generatedChecksum = 0;

byte checksum = 0;

int payloadLength = 0;

byte payloadData[64] = {0};

byte poorQuality = 0;
byte attention = 0;

byte meditation = 0;

// system variables

long lastReceivedPacket = 0;

boolean bigPacket = false;

//////////////////////////

// Microprocessor Setup //

//////////////////////////

void setup()

pinMode(GREENLED1, OUTPUT);

pinMode(GREENLED2, OUTPUT);

pinMode(GREENLED3, OUTPUT);

pinMode(YELLOWLED1, OUTPUT);

pinMode(YELLOWLED2, OUTPUT);

pinMode(YELLOWLED3, OUTPUT);

pinMode(YELLOWLED4, OUTPUT);

pinMode(REDLED1, OUTPUT);

pinMode(REDLED2, OUTPUT);

pinMode(REDLED3, OUTPUT);

pinMode(LED, OUTPUT);
Serial.begin(BAUDRATE); // USB

////////////////////////////////

// Read data from Serial UART //

////////////////////////////////

byte ReadOneByte()

int ByteRead;

while(!Serial.available());

ByteRead = Serial.read();

#if DEBUGOUTPUT

Serial.print((char)ByteRead); // echo the same byte out the USB serial (for debug
purposes)

#endif

return ByteRead;

/////////////

//MAIN LOOP//

/////////////

void loop()
{

// Look for sync bytes

if(ReadOneByte() == 170)

if(ReadOneByte() == 170)

payloadLength = ReadOneByte();

if(payloadLength > 169) //Payload length can not be greater than 169

return;

generatedChecksum = 0;

for(int i = 0; i < payloadLength; i++)

payloadData[i] = ReadOneByte(); //Read payload into memory

generatedChecksum += payloadData[i];

checksum = ReadOneByte(); //Read checksum byte from stream

generatedChecksum = 255 - generatedChecksum; //Take one's compliment of


generated checksum

if(checksum == generatedChecksum)

poorQuality = 200;
attention = 0;

meditation = 0;

for(int i = 0; i < payloadLength; i++)

{ // Parse the payload

switch (payloadData[i])

case 2:

i++;

poorQuality = payloadData[i];

bigPacket = true;

break;

case 4:

i++;

attention = payloadData[i];

break;

case 5:

i++;

meditation = payloadData[i];

break;

case 0x80:

i = i + 3;

break;

case 0x83:

i = i + 25;
break;

default:

break;

} // switch

} // for loop

#if !DEBUGOUTPUT

// *** Add your code here ***

if(bigPacket)

if(poorQuality == 0)

digitalWrite(LED, HIGH);

else

digitalWrite(LED, LOW);

Serial.print("PoorQuality: ");

Serial.print(poorQuality, DEC);

Serial.print(" Attention: ");

Serial.print(attention, DEC);

Serial.print(" Time since last packet: ");

Serial.print(millis() - lastReceivedPacket, DEC);

lastReceivedPacket = millis();

Serial.print("\n");
switch(attention / 10)

case 0:

digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, LOW);

digitalWrite(GREENLED3, LOW);

digitalWrite(YELLOWLED1, LOW);

digitalWrite(YELLOWLED2, LOW);

digitalWrite(YELLOWLED3, LOW);

digitalWrite(YELLOWLED4, LOW);

digitalWrite(REDLED1, LOW);

digitalWrite(REDLED2, LOW);

digitalWrite(REDLED3, LOW);

break;

case 1:

digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, HIGH);

digitalWrite(GREENLED3, LOW);

digitalWrite(YELLOWLED1, LOW);

digitalWrite(YELLOWLED2, LOW);

digitalWrite(YELLOWLED3, LOW);

digitalWrite(YELLOWLED4, LOW);

digitalWrite(REDLED1, LOW);

digitalWrite(REDLED2, LOW);
digitalWrite(REDLED3, LOW);

break;

case 2:

digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, HIGH);

digitalWrite(GREENLED3, HIGH);

digitalWrite(YELLOWLED1, LOW);

digitalWrite(YELLOWLED2, LOW);

digitalWrite(YELLOWLED3, LOW);

digitalWrite(YELLOWLED4, LOW);

digitalWrite(REDLED1, LOW);

digitalWrite(REDLED2, LOW);

digitalWrite(REDLED3, LOW);

break;

case 3:

digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, HIGH);

digitalWrite(GREENLED3, HIGH);

digitalWrite(YELLOWLED1, HIGH);

digitalWrite(YELLOWLED2, LOW);

digitalWrite(YELLOWLED3, LOW);

digitalWrite(YELLOWLED4, LOW);

digitalWrite(REDLED1, LOW);

digitalWrite(REDLED2, LOW);

digitalWrite(REDLED3, LOW);
break;

case 4:

digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, HIGH);

digitalWrite(GREENLED3, HIGH);

digitalWrite(YELLOWLED1, HIGH);

digitalWrite(YELLOWLED2, HIGH);

digitalWrite(YELLOWLED3, LOW);

digitalWrite(YELLOWLED4, LOW);

digitalWrite(REDLED1, LOW);

digitalWrite(REDLED2, LOW);

digitalWrite(REDLED3, LOW);

break;

case 5:

digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, HIGH);

digitalWrite(GREENLED3, HIGH);

digitalWrite(YELLOWLED1, HIGH);

digitalWrite(YELLOWLED2, HIGH);

digitalWrite(YELLOWLED3, HIGH);

digitalWrite(YELLOWLED4, LOW);

digitalWrite(REDLED1, LOW);

digitalWrite(REDLED2, LOW);

digitalWrite(REDLED3, LOW);

break;
case 6:

digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, HIGH);

digitalWrite(GREENLED3, HIGH);

digitalWrite(YELLOWLED1, HIGH);

digitalWrite(YELLOWLED2, HIGH);

digitalWrite(YELLOWLED3, HIGH);

digitalWrite(YELLOWLED4, HIGH);

digitalWrite(REDLED1, LOW);

digitalWrite(REDLED2, LOW);

digitalWrite(REDLED3, LOW);

break;

case 7:

digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, HIGH);

digitalWrite(GREENLED3, HIGH);

digitalWrite(YELLOWLED1, HIGH);

digitalWrite(YELLOWLED2, HIGH);

digitalWrite(YELLOWLED3, HIGH);

digitalWrite(YELLOWLED4, HIGH);

digitalWrite(REDLED1, HIGH);

digitalWrite(REDLED2, LOW);

digitalWrite(REDLED3, LOW);

break;

case 8:
digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, HIGH);

digitalWrite(GREENLED3, HIGH);

digitalWrite(YELLOWLED1, HIGH);

digitalWrite(YELLOWLED2, HIGH);

digitalWrite(YELLOWLED3, HIGH);

digitalWrite(YELLOWLED4, HIGH);

digitalWrite(REDLED1, HIGH);

digitalWrite(REDLED2, HIGH);

digitalWrite(REDLED3, LOW);

break;

case 9:

digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, HIGH);

digitalWrite(GREENLED3, HIGH);

digitalWrite(YELLOWLED1, HIGH);

digitalWrite(YELLOWLED2, HIGH);

digitalWrite(YELLOWLED3, HIGH);

digitalWrite(YELLOWLED4, HIGH);

digitalWrite(REDLED1, HIGH);

digitalWrite(REDLED2, HIGH);

digitalWrite(REDLED3, HIGH);

break;

case 10:

digitalWrite(GREENLED1, HIGH);
digitalWrite(GREENLED2, HIGH);

digitalWrite(GREENLED3, HIGH);

digitalWrite(YELLOWLED1, HIGH);

digitalWrite(YELLOWLED2, HIGH);

digitalWrite(YELLOWLED3, HIGH);

digitalWrite(YELLOWLED4, HIGH);

digitalWrite(REDLED1, HIGH);

digitalWrite(REDLED2, HIGH);

digitalWrite(REDLED3, HIGH);

break;

#endif

bigPacket = false;

else {

// Checksum Error

} // end if else for checksum

} // end if read 0xAA byte

} // end if read 0xAA byte

DIAGRAM FOR HC-05 WITH ARDUINO (WITH SKETCH)


Method 2 for AT Commands

Connection Diagram

Steps to Follow

1. Make connections as per the connection diagram.

2. Program (Upload the sketch) the” HC-05 with Arduino” source code to Arduino board using
Arduino compiler

3. Open the “Serial monitor” with buadrate of 9600.

4. Type the AT commands and click Enter in Serial monitor

Serial Monitor Screen


Program for HC-05 with Arduino Board

Title: HC-05 with Arduino

/*

AUTHOR: Hazim Bitar (techbitar)

DATE: Aug 29, 2013

LICENSE: Public domain (use at your own risk)

CONTACT: techbitar at gmail dot com (techbitar.com)

*/

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(10, 11); // RX | TX


void setup()

pinMode(9, OUTPUT); // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module
to AT mode

digitalWrite(9, HIGH);

Serial.begin(9600);

Serial.println("Enter AT commands:");

BTSerial.begin(38400); // HC-05 default speed in AT command more

void loop()

// Keep reading from HC-05 and send to Arduino Serial Monitor

if (BTSerial.available())

Serial.write(BTSerial.read());

// Keep reading from Arduino Serial Monitor and send to HC-05

if (Serial.available())

BTSerial.write(Serial.read());

Reference Video Links


- See more at: https://www.pantechsolutions.net/interfacing-mindwave-mobile-with-
arduino#sthash.GOUB1ijh.dpuf
Introduction
Brought to you by Hacker in Residence, Sophi Kravitz.

Have you ever wanted to control something just by thinking about it? Well, you’re in luck. The
MindWave allows you to turn electronic signals that flow in your body into digital signals that
can be understood by a microcontroller. There is also the MindWave Mobile, which is designed
to interface with your mobile devices. This tutorial will serve as half teardown/review and half
project. After we explore the inner-workings of the MindWave Mobile, we’ll switch gears and
focus on hacking it.

Covered in This Tutorial

This tutorial will go over:

 What is MindWave Mobile?


 Configuring the RN42 Bluetooth module
 Pairing MindWave Mobile with the RN42
 What is the data you will see coming out of the MindWave? What does it mean?
 Programming the Arduino with provided source code to see MindWave data
 Using Processing to graph specific values from the digital data
 Next steps, after the MindWave
Suggested Reading

This tutorial builds on some previously covered topics. Please visit any of the links below if you
are unfamiliar with the concepts mentioned.

 What is Electricity?
 What is an Arduino?
 Serial Communication
 Serial Terminal Basics
 Bluetooth Basics
 BlueSMiRF Hookup Guide
 Connecting Arduino to Processing

What is the MindWave Mobile?

The MindWave Mobile from NeuroSky

To understand the MindWave and MindWave Mobile, we must first understand what an EEG
sensor is. The first recording of the human brain’s electric field was made by Hans Berger, a
German psychiatrist, in 1924. Berger gave the recording the name electroencephalogram (EEG).
Put simply, the EEG is performed by placing electrodes all over the subject’s scalp, and then
reading in the electrical signals for analysis. Fast forward to today, and you have all of this
technology packed into a compact form factor that is the MindWave and the MindWave Mobile.

Project Scope

The amplitude of the EEG is ~ 100 µV when measured on the scalp, and about 1-2 mV when
measured on the surface of the brain. The bandwidth of this signal is from under 1 Hz to about
50 Hz.

Because of the amplitude and low frequency of the brainwave signal, I was curious about how
well a relatively cheap (~$100) sensor would measure brain signals.

In this project, the analog brainwaves enter a processing ASIC chip and have digital values that
are communicated over Bluetooth. I accessed only the digital data. It is certainly possible to look
at the analog brain waves before they enter the processing ASIC, but it would be much more
difficult, requiring a schematic and specialized oscilloscope probes.

The Mindwave Mobile was chosen because because it uses Bluetooth, making it easier to
interface it with a microcontroller or other hardware. Please note that Neurosky has multiple
models of the MindWave.
SFE Creative Technologist, Nick Poole, sporting the MindWave. The electrode rests on the
forehead, above the eyebrow, and the reference clips onto the ear.

Taking it Apart
Pictured here is the MindWave headset. Nick Poole took one of these apart, so the insides of the
headset are pictured here as well.

Here is a closeup of the internal circuitry. You may recognize the MSP430 hanging out at the
top.

And, the backside….

In between the two boards is an ASIC. The ASIC on the Neurosky calculates a value for
Attention and Meditation. It also processes five types of brainwaves (more on this shortly) and
sends out unitless values for each one. This unit measures eyeblinks too.

Gathering Materials
In order to interface with the MindWave, you’ll need a few bits of hardware and software.

Hardware

To interface with the MindWave, the RN-42 Bluetooth module was chosen. For this project, I
created a custom PCB, however, you could also use a BlueSMiRF or a Bluetooth Mate. The
Bluetooth module will be connected to an Arduino Uno to read in the data being transmitted
wirelessly.

The BlueSMiRF Silver module from SparkFun.


Once you’ve decided on which hardware you’ll be using, connect everything. Again, the
Bluetooth Basics and BlueSMiRF tutorials should cover how to do this extensively.

Software

You’ll want to get some programs to be able to read data from and configure the RN42
Bluetooth module.

 X-CTU, CoolTerm, or another serial terminal program of your choice.


 RS232 Port Logger

If you are unfamiliar with serial terminal emulators, please check out our tutorial.

Firmware

Here is the firmware for the Arduino side of this project. If you are following along, you’ll want
to upload this to whichever Arduino board you are using.

///////////////////////////////////////////////////////////////
// Arduino Bluetooth Interface with Mindwave
// Sophi Kravitz edit 11-4
// Shane Clements edit 11-5
////////////////////////////////////////////////////////////////////////
#include <SoftwareSerial.h> // library for software serial
SoftwareSerial mySerial(5, 6); // RX, TX
int LED = 8; // yellow one
int LED1 = 7; //white one
int BAUDRATE = 57600;

// checksum variables
byte payloadChecksum = 0;
byte CalculatedChecksum;
byte checksum = 0; //data type byte stores an 8-bit unsigned
number, from 0 to 255
int payloadLength = 0;
byte payloadData[64] = {0};
byte poorQuality = 0;
byte attention = 0;
byte meditation = 0;

// system variables
long lastReceivedPacket = 0;
boolean bigPacket = false;
boolean brainwave = false;
void setup() {
pinMode(LED, OUTPUT);
pinMode(LED1, OUTPUT);
digitalWrite(LED, HIGH); // hello sequence
delay(100);
digitalWrite(LED, LOW);
delay(100);
Serial.begin(57600); // Bluetooth
delay(500);
mySerial.begin(4800); // software serial
delay(500);
mySerial.print("Communicating... ");
mySerial.println();
}
byte ReadOneByte() {
int ByteRead;
// Wait until there is data
while(!Serial.available());
//Get the number of bytes (characters) available for reading from the
serial port.
//This is data that's already arrived and stored in the serial receive
buffer (which holds 64 bytes)
ByteRead = Serial.read();
return ByteRead; // read incoming serial data
}

unsigned int delta_wave = 0;


unsigned int theta_wave = 0;
unsigned int low_alpha_wave = 0;
unsigned int high_alpha_wave = 0;
unsigned int low_beta_wave = 0;
unsigned int high_beta_wave = 0;
unsigned int low_gamma_wave = 0;
unsigned int mid_gamma_wave = 0;

void read_waves(int i) {
delta_wave = read_3byte_int(i);
i+=3;
theta_wave = read_3byte_int(i);
i+=3;
low_alpha_wave = read_3byte_int(i);
i+=3;
high_alpha_wave = read_3byte_int(i);
i+=3;
low_beta_wave = read_3byte_int(i);
i+=3;
high_beta_wave = read_3byte_int(i);
i+=3;
low_gamma_wave = read_3byte_int(i);
i+=3;
mid_gamma_wave = read_3byte_int(i);
}

int read_3byte_int(int i) {
return ((payloadData[i] << 16) + (payloadData[i+1] << 8) +
payloadData[i+2]);
}

void loop() {
// Look for sync bytes
// Byte order: 0xAA, 0xAA, payloadLength, payloadData,
// Checksum (sum all the bytes of payload, take lowest 8 bits, then bit
inverse on lowest
if(ReadOneByte() == 0xAA) {
if(ReadOneByte() == 0xAA) {
payloadLength = ReadOneByte();
if(payloadLength > 169) //Payload length can not be greater than 169
return;
payloadChecksum = 0;
for(int i = 0; i < payloadLength; i++) { //loop until payload
length is complete
payloadData[i] = ReadOneByte(); //Read payload
payloadChecksum += payloadData[i];
}
checksum = ReadOneByte(); //Read checksum byte from
stream
payloadChecksum = 255 - payloadChecksum; //Take one’s compliment
of generated checksum
if(checksum == payloadChecksum) {
poorQuality = 200;
attention = 0;
meditation = 0;
}
brainwave = false;
for(int i = 0; i < payloadLength; i++) { // Parse the payload
switch (payloadData[i]) {
case 02:
i++;
poorQuality = payloadData[i];
bigPacket = true;
break;
case 04:
i++;
attention = payloadData[i];
break;
case 05:
i++;
meditation = payloadData[i];
break;
case 0x80:
i = i + 3;
break;
case 0x83: // ASIC EEG POWER INT
i++;
brainwave = true;
byte vlen = payloadData[i];
//mySerial.print(vlen, DEC);
//mySerial.println();
read_waves(i+1);
i += vlen; // i = i + vlen
break;
} // switch
} // for loop

if(bigPacket) {
if(poorQuality == 0){
}
else{ // do nothing
}
}
if(brainwave && attention > 0 && attention < 100) {
mySerial.print("Attention value is: ");
mySerial.print(attention, DEC);
mySerial.println();
mySerial.print("Delta value is: ");
mySerial.print(delta_wave, DEC);
mySerial.println();
mySerial.print("Theta value is: ");
mySerial.print(theta_wave, DEC);
mySerial.println();
mySerial.print("Low Alpha value is: ");
mySerial.print(low_alpha_wave, DEC);
mySerial.println();
mySerial.print("High Alpha value is: ");
mySerial.print(high_alpha_wave, DEC);
mySerial.println();
mySerial.print("Alertness value1 is: ");
mySerial.print(low_beta_wave, DEC);
mySerial.println();
mySerial.print("Alertness value2 is: ");
mySerial.print(high_beta_wave, DEC);
mySerial.println();
mySerial.print(low_gamma_wave, DEC);
mySerial.println();
mySerial.print(mid_gamma_wave, DEC);
mySerial.println();
}

if(attention > 40){


digitalWrite(LED1, HIGH);
}
else
digitalWrite(LED1, LOW);
}
}
}

Here is the Processing code, which interprets the data coming from the MindWave to the
Arduino, and then gives you a visual representation of that data.

//Processing code to graph Attention values


//Comment out all of the lines after “if(brainwave && attention > 0 &&
attention < 100) {“
//Except for
//mySerial.print(attention, DEC);
// mySerial.println();
//This will print out ONLY an Attention value and a new line afterwards

// Graphing sketch by Tom Igoe


// Sophi Kravitz edit 11/8

import processing.serial.*;
Serial myPort; // The serial port
int xPos = 1; // horizontal position of the graph
void setup () {
// set the window size:
size(400, 300);
String portName = Serial.list()[1]; //[1] println(Serial.list()) to
find the ports
myPort = new Serial(this, "COM16", 4800); // make sure the Baud rate
matches the Arduino code
myPort.bufferUntil('\n'); // Wait for newline character:
background(0); // set inital background color: 0
= black, 255 = white
}

void draw () { // everything happens in the


serialEvent()
}

void serialEvent (Serial myPort) {


String inString = myPort.readStringUntil('\n');

if (inString != null) { // trim whitespace:


inString = trim(inString); // convert to an int and map to
the screen height:
float inByte = float(inString);
inByte = map(inByte, 0, 100, 0, height); // take number from 0 to 100, and
map it to 0 to height
stroke(5,34,255); // draw the line:
line(xPos, height, xPos, height - inByte);

if (xPos >= width) { // at the edge of the screen, go


back to the beginning:
xPos = 0;
background(0);
}
else {
xPos++; // increment the horizontal
position:
}
}
}

Configuring the Bluetooth Module


The RN42 module can be configured to behave in a variety of different ways. If you have never
configured one of the RN Bluetooth modules, please read our BlueSMiRF Hookup Guide.

You can use any serial terminal you wish to configure the bluetooth module. For this project, I
used my Android phone with an app called S2 Terminal for Bluetooth to configure the RN42.
The configuration process went as so:

Note: If you are using the S2 Terminal program, you will need to type in ASCII and put a return
after each command. Also, you only have 60 seconds after power up to enter the first command.

1. To put the RN42 into COMMAND mode, type $$$ (NO carriage return). If successful,
you will see “CMD”.
2. Type: D + carriage return. You will see the current configuration of the RN42.

3. Type: SP,0000 + carriage return. This will change the pincode from ‘1234’ to ‘0000’.
You will see “AOK” if this is done properly.
4. Type: SM, 3 + carriage return. This will configure the RN42 to Auto-Connect Mode.
Once the module is powered up, it will immediately look to connect (pair).You will see
“AOK” if this is done properly.
5. Type: SR,MAC ADDRESS + carriage return. Insert the 12 digit address you copied from the
MindWave Mobile. Look for AOK. If you don’t see AOK, you’ll have to retype the
MAC address command.
6. Now type: SU,57.6 + carriage return. This will change the baud rate from 115200 to
57600.

7. Type D + carriage return. Double check that the stored address is the Mac address you
entered in step 5 and that it’s configured to Auto, not Slave.
8. Type: --- (three minus signs) + carriage return You should then see END.

Turn the Mindwave on. The blue light flashes for a few moments, then it will pair with your
hardware. You’ll know that the Mindwave Mobile is paired because the blue light on the
Mindwave Mobile is solid. If it is solid red, it is out of battery (AAA, lasts for about 8 hours).

Deciphering the MindWave Data


Using an FTDI basic, I was able to view the data coming in from the Arudino through my USB
port. I used X-CTU to read the data. The Arduino code mentioned in the Gathering Materials
section is mostly a combination of the Mindwave Mobile example code and Shane Clements’
massaging. The code is set up to print all of the digital data available out of the Mindwave
Mobile. The data runs through the software serial port and is read easily on the X-CTU screen.

You can see unitless values for Delta, Theta, Alpha, Low Beta, High Beta and Gamma waves.
The Mindwave’s ASIC also presents a calculated value for both Attention and Meditation. A
number between 20 and 100 for Attention is normal, and a value above 40 means you are
concentrating.

I was able to get repeatable values with the Attention value by counting backwards from 100 to1.
We had a Bring A Hack dinner in Boulder, CO, and a few other people were able to make the
Attention value rise by counting backwards from 100 to 1 also.
What is interesting is that the 5 types of brainwaves measured and reported originate from
different parts of the brain. They also have extremely low amplitudes and frequencies.

 Gamma waves are oscillating waves with frequencies around 40 Hz, although they can be
as high as 100 Hz and as low as 24 Hz. These originate from the thalamus (buried deep in
the center of the brain) and are responsible for states of high attention and concentration.
 Beta waves are between 12 and 30 Hz and are the states associated with normal waking
consciousness. These are emitted from the motor cortex, a region of the cerebral cortex,
which is the outermost layer of tissue on the brain. Beta waves are split into three
sections: Low Beta Waves (12.5-16 Hz, “Beta 1 power”); Beta Waves (16.5–20 Hz,
“Beta 2 power”); and High Beta Waves (20.5-28 Hz, “Beta 3 power”).
 Alpha waves originate at the Occipital lobe and have a frequency of 8-12Hz. These are
most present when you are awake but are very drowsy or relaxed.
 Theta waves are oscillating waves that are located in the Hippocampus and are associated
with dreaming. They are in the 4-7Hz range.
 Delta waves are associated with very deep, dreamless sleep cycles and are high amplitude
waves, which have a 0 to 3Hz frequency. These waves emit from both the thalamus and
the cortex.

The difference between these waves can be more easily understood when seen side-by-side.

If you used an Arduino with the code from the Gathering Materials section uploaded, you should
be able to see these values printed out in X-CTU or the Serial terminal program of your choice.
The Processing code found in the same section as the Arduino code can be used and modified to
graph different values from the Arduino.

The attention value being graphed on Processing.

Resources and Going Further


The best results using the MindWave Mobile came when I looked at the processed Attention
value. It was easy to see that when I (or anyone else) counted backwards from 100 to 1, the
Attention values went up.

The deep brainwave values that I really wanted to see, such as Gamma, Beta, etc., were all over
the place, and it was difficult to see any consistency in those values at all. In fact, the brainwave
values varied the same when the unit was on the head as when off the head!

The Android app that comes with the Mindwave Mobile didn’t work at all, I tried it on a few
phones without success. Neurosky support thought that it was possible that my Android
operating system was not compatible.

Overall, I don’t think using the Neurosky Mindwave product yields any data that is very useable.
I look forward to trying Neurosky’s next revision, and I am really looking forward to trying
OpenBCI!

For more teardowns, check out these other offerings from SparkFun: