Introduction: Necomimi Bluetooth EEG Data Hack.
There are a bunch of EEG toys out there that can be hacked, allowing the data to be viewed and used. I'm going to focus on the Necomimi here but I'll make some notes on the MindFlex and the StarWars ForceTrainer also along the way.
Necomimi and MindFlex use a module made by NeuroSky to read brainwaves and interpret them in different ways. The ForceTrainer also uses a similar module but it appears to be a slightly different design.
- I'm going to show you how to modify the hardware and add a blue tooth module so we can extract the data.
- We'll then explore a few options for viewing and visualising that data on Android devices or PCs.
- And finally I'll show you how i used that data to operate some home made hardware.
This is kind or a pick 'n mix tutorial. Build the bits you like. Ignore the bits you don't..
Here are some of the things you're going to need:
- A soldering iron and associated tools for modifying the hardware.
- A slave bluetooth module such as the HC-06 or HC-05.
- An android phone or tablet to view the data or a PC. A Mac may also work but I've not tried.
- An Arduino or compatible device (needed for necomimi and hardware projects only).
- Some servo motors.
- Assorted wires and connectors.
Step 1: Setting Up the Bluetooth Module for the Necomimi
First off lets consider the bluetooth module.
The ForceTrainer and Mind Flex use the same default baud rate as the HC-06 module of 9600 baud.
So if you're using those you can skip to STEP 2
If you're hacking a Necomimi we have to change the baud rate to 57600.
We'll use the Arduino to achieve this.
Load the following sketch to your Arduino:
Disconnect the Arduino and wire it to the HC-06 module as shown above,
Check your wiring then power up the Arduino once more.
Give the Arduino sketch a few moments to do its thing.
Step 2: It's Circuit Bending Time.
Time for some hacking.
FIRST REMOVE THE BATTERIES (yes i destroyed the power reg on my ForceTrainer by not doing this).
Take apart your headset and you'll find a daughter board, the NeuroSky EEG module.
Refer to the images above for tips on disassembling your headset.
At one corner the EEG module has a 6 pin header. We are interested in the pin marked "T" This is the "TXD" Transmit Data pin. Solder a fine wire to thes pin. It will connect to the BlueTooth module "RXD" Receive Data pin. The module will also need power so solder a wire to the battery compartment "+" terminal and another to the "-" terminal.
Attach the T wire to the RXD pin
Attach the + wire to the VCC pin
Attach the - wire to the GND pin
A spot of hot glue can help secure the wires.
Step 3: Lets See If We're Recieving Data
<3 machines on>
Plug in the Bluetooth module and power up your head set.
Pare your module with the device and note the com port number. By default the device name is probably "HC-06" and the pass word is probably "1234".
For PC and maybe Mac,
Launch some terminal software and set the com port and baud rate to match your Bluetooth module settings (57600baud for Necomimi. 9600baud for ForceTrainer and MindFlex).
I had good results using "REALTERM"
Display the data as "Hex[space]" and you should see data packets arriving. There are detailed descriptions of what all the data means on the Neurosky web site. but in essence it's as follows:
Necomimi baud 57600 ForceTrainer and MindFlex baud 9600.
A packet like the following is received every second or so:
AA AA packet begins
20 packet length. hex 20
02 00 signal, 00 - good
83 18 ASIC_EEG_POWER, length hex 18*
06 4A EC ((06*FF*FF)+(4A*FF)+(EC))
00 2F 37
00 0B 74
00 17 ED
00 29 F8
00 25 EF
00 08 53
00 08 7E
04 43 ATTENTION 43
05 38 MEDITATION 38
The Necomimi also spits out RAW data at a much faster rate:
AA AA packet begins
04 packet length. hex 04
80 02 RAW, length hex 02**
00 4D raw = Value*256 + Value; if( raw >= 32768 ) raw = raw - 65536;
* 24 ASIC_EEG_POWER: eight big-endian 3-byte unsigned integer values representing delta, theta, low-alpha, high-alpha, low-beta, high-beta, low-gamma, and mid-gamma EEG band power values
**This Data Value consists of two bytes, and represents a single raw wave sample. Its value is a signed 16-bit integer that ranges from -32768 to 32767. The first byte of the Value represents the high-order bits of the twos-compliment value, while the second byte represents the low-order bits. To reconstruct the full raw wave value, simply shift the first byte left by 8 bits, and bitwise-or with the second byte:
For Android. Pare your bluetooth module "HC-06", pass "1234".
There are a few apps that nicely visualise the data.
NeuroSky's own app "Brainwave Visualizer" is cool and appears to work with the modified MindFlex and Necomimi although I couldn't get it to work with the ForceTrainer. I don't understand why. The data packets look the same as the MindFlex ones. I must be missing something.
This app "BioZen" does appear to like the ForceTrainer and it will also log the data. That's a nice feature.
Step 4: Lets Do Some Processing With the Data.
These are brain wave visualisers written with PROCESSING.
This is a modified version of Processing-Brain-Grapher Created by Eric Mika.
I added a messy hack that eliminates the need for am Arduino with the .brain library which i found problematic with the Necomimi and and ForceTrainer.
I also added some code to spit out values on a second com port to run machines based on brain activity but we'll get to that.
You may also like to try my much simpler visualiser.
It's easier to tell what "Artronix_Simple_Brain" is doing so it may be a better starting point for your own projects. It also works in Processing3 and doesn't require the library.It's a lot less pretty though.
Install the software. Turn on your Necomimi and give it time to pare. Run the software. You will see a list of available ports. Edit the code so the port number corresponds to your Bluetooth module.If you're using the ForceTrainer or MindFlex be sure to edit the serial in baud rate to 9600.
// Put the index found above here:
// serial in
// MindFlex and ForceTrainer baud rate 9600
// Necomimi baud rate 57600
serial = new Serial(this, Serial.list(), 57600);
Start it all up again.
Sometimes it take a few attempts to start (com port busy? I know not why). but hopefully it'll all fire up eventually.
Step 5: Putting Our Minds to Work.
Once you have one of the visualisers running you can add an Arduino and get your brainwaves to run some machines. This Arduino sketch will move up to 8 servo motors based on your brain activity (and run a stepper motor if you fancy building something like our EEG pen plotting machine).
Load the sketch into the Arduino then close the Arduino software.
Connect some servos as shown above.
Load the processing software we used earlier and modify the line:
// Set up output for arduino hardware 0 = no com out. 1 = com out
serialOutput = 1;
This enables the second com port. Turn on the Necomimi headset.
Note the com port used by your Bluetooth module and the Arduino.
Run the software.
Edit the code according to the com port list.
Turn on your servos and run the software again.
WOOHOO you should now have brainwave data on screen and servo motors responding to the results.
Step 6: What Else?
One final idea. it would be nice to eliminate the PC and have the headset control the
Arduino hardware wirelessly and direct. We'll have to add a bluetooth
module configured as a MASTER to do this.
We could configure an HC-05 with the Arduino.
I've not had a chance to try this yet but it's the obvious next step. I'll Post some code when i get the chance.
That about wraps it up. there's still a lot more fun to be had with the EEG module, for example you can reconfigure it with its 'R' pin and a Bluetooth module or Arduino and pull other kinds of data from it (although doing so will probably interfere with the toy's functionality).
Do let me know what you make with this in the comments. Thanks.
"If I have seen further it is by standing on the shoulders of Giants". Isaac Newton .
In other words check out all this cool work that I've drawn upon heavily to create this I hope I've credited everyone:
If you'd like to see some more photographs of us demoing this project at the opening if the Princes Trust's new Samsung sponsored Digital Classroom, why not take in our flickr gallery.