Mini Arduino Portable EEG Brain Wave Monitor
Mini Arduino Portable EEG Brain Wave Monitor
Table of Contents
Step 3: Create Preliminary sketch to checkout screen layout (pre- Alpha Version) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
http://www.instructables.com/id/Mini-Arduino-Portable-EEG-Brain-Wave-Monitor-/
Intro: Mini Arduino Portable EEG - Brain Wave Monitor +
This is another example of the versatility , and of what , the Arduino, a small LCD Color display and the right type of sensors, are capable of doing.
NOTE:
This is a work in progress ..... I will be working on several phases until I complete a " Portable Human Vital Signs monitor"
I will be using the mini monitor setup that I used in my mini environment monitor , so I won't go into any of the details about building the monitor here.
Basic assumptions:
I am assuming that you already know how to download and install Arduino libraries, and that you have at least constructed the mini environment monitor, as the same
skill-set is required,
Heart Rate
Body Temperature
GSR
EEG
Brain wave values of:
Attention
Meditation
Alpha
Beta
Delta
Gama
DISCLAMER: This project is not intended to be used as a medical device, use of this device for those purposes is at your own risk.
That said, practical uses of this monitor are biofeedback - meditation aid, lie detector toy, heart rate monitor / logger , etc...
http://www.instructables.com/id/Mini-Arduino-Portable-EEG-Brain-Wave-Monitor-/
Image Notes Image Notes
1. Wires coming from MindFlex headband 1. Mind flex headband with hack
2. Mini display stripped from all other sensors 2. TFT Display
3. Arduino 3. Arduino
4. Jumper wires (long ones preferred)
http://www.instructables.com/id/Mini-Arduino-Portable-EEG-Brain-Wave-Monitor-/
Image Notes
1. Mind Flex Head Set
Image Notes
1. Space reserved for RTC data:
Date, Time, elapsed time, etc..
2. Sensor data display area
3. Data coming from MindFlex EEG headband-For test purposes
4. Arduino
5. Mini Arduino monitor
Step 3: Create Preliminary sketch to checkout screen layout (pre- Alpha Version)
Note : you don't really need to do this step, it's just for documentation purposes
Below is the preliminary code to check out the screen layout of the data we want to display
// copy the sketch below and paste it into the Arduino IDE compile and run the program.
// this sketch was created using code from both the adafruit and the Braintest( by Eric Mika, 2010 ) sample sketches
// You can use any (4 or) 5 pins
#define sclk 4
#define mosi 5
#define cs 6
#define dc 7
#define rst 8 // you can also connect this to the Arduino reset
#define ANALOG_IN 0 // for cds light sensor
#define ANALOG_IN 1 // for temperature sensor
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>
#include <Brain.h>
Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, mosi, sclk, rst);
// Set up the brain parser, pass it the hardware serial object you want to listen on.
Brain brain(Serial);
void setup(void) {
http://www.instructables.com/id/Mini-Arduino-Portable-EEG-Brain-Wave-Monitor-/
tft.drawLine(0, 110, tft.width()-1, 110, ST7735_WHITE);
}
void loop() {
// tft.fillScreen(ST7735_BLACK); // clear screen
//delay(2000);
//tft.setTextColor(ST7735_GREEN, ST7735_BLACK);
//tft.println((float)DHT11.temperature,1);
//tft.setTextColor(ST7735_GREEN, ST7735_BLACK);
//tft.println((float)DHT11.humidity,1);
//tft.setTextColor(ST7735_GREEN, ST7735_BLACK);
// tft.println(DHT11.fahrenheit(), 1);
// tft.print(" ");
//tft.setTextColor(ST7735_GREEN, ST7735_BLACK);
// tft.println(DHT11.kelvin(), 1);
//tft.setTextColor(ST7735_GREEN, ST7735_BLACK);
//tft.println(DHT11.dewPoint(), 1);
//tft.setTextColor(ST7735_GREEN, ST7735_BLACK);
//tft.println(DHT11.dewPointFast(), 1);
// tft.setCursor(0,115);
// tft.print("Light intensity ");
//int val = analogRead(ANALOG_IN); // READ LIGHT SENSOR VALUE
//tft.setCursor(60, 130);
// tft.setTextColor(ST7735_YELLOW, ST7735_BLACK);
// tft.println(val, 1); // PRINT LIGHT SENSOR VALUE
//delay(2000);
tft.setCursor(0, 115);
tft.setTextSize(1);
tft.setTextColor(ST7735_YELLOW,ST7735_BLACK );
// Expect packets about once per second.
// The .readCSV() function returns a string (well, char*) listing the most recent brain data, in the following format:
// "signal strength, attention, meditation, delta, theta, low alpha, high alpha, low beta, high beta, low gamma, high gamma"
if (brain.update()) {
//tft.println(brain.readErrors());
tft.println(brain.readCSV());
}}
Image Notes
1. Space reserved for RTC data:
Date, Time, elapsed time, etc..
2. Sensor data display area
3. Data coming from MindFlex EEG headband-For test purposes
4. Arduino
5. Mini Arduino monitor
http://www.instructables.com/id/Mini-Arduino-Portable-EEG-Brain-Wave-Monitor-/
Step 4: Phase 1: EEG Monitor (Hardware)
As I mentioned before,I will be Developing this project in various phases because I'm not quite sure how it will all come together yet, and whether the Arduino will be able
to handle it all.
Before attempting to start this phase, I recommend you visit the Frontier Nerds web site , Where they do a better job than I could, of explaining how to mod the MindFlex
headset so you can interface it with the arduino.
For Purposes of completeness, I will quickly go through the steps I took to hack my headset. Please review the pictures and comments for more detail. (a picture is worth
1000 words).
1.- Remove the 4 screws from the back cover of the left pod of the Mind Flex headset.(The right pod holds the batteries.)
3.- Identify the NeuroSky Board.It is the small daughterboard towards the bottom of the left pod.
4.- If you look closely, you will see pins that are labeled T and R — these are the pins the EEG board uses to communicate serially to the microcontroller on the main
circuit board.
5.- Solder a length of wire (carefully) to the “T” pin. I used a pair of wires that came from an old PC. Be careful not to short the neighboring pins.
6.- Solder another length of wire to ground using the large solder pad where the battery’s ground connection is.
7. - Drill a hole in the case for the two wires to poke through after the case was closed.
8 .- Guide the wires through the hole, and recheck your soldering. I recommend putting a dab of glue in the hole to secure the wires in place ( I used my hot glue gun to
do this).
9.- Carefully put the back case back on and re secure the screws.
10.- Connect the Mind Flex to the Arduino; Connect the Wire coming from the T pin to the Arduino rx pin, Connect the other wire to an arduino GND pin.
Note:
I have Included the Neurosky Datasheet in case you need more clarity. For those folks that live overseas you may need to change the 60 hz filter to 50 hz, as described
in the datasheet to avoid powerline interference.
http://www.instructables.com/id/Mini-Arduino-Portable-EEG-Brain-Wave-Monitor-/
Image Notes Image Notes
1. Closer view of back of left pod 1. The ends of the wire go to the Mind flex
2. Closer view of back of left pod showing the 4 screws that need to be 2. Handy connector I left on the wires to connect to Arduino with jumper wires.
removed 3. I got this from an old PC, I think it connected to an LED in front of the PC case
HD led.
http://www.instructables.com/id/Mini-Arduino-Portable-EEG-Brain-Wave-Monitor-/
Image Notes Image Notes
1. Wire Soldered to T pin 1. Wire Soldered to TX pin
2. Green wire used for GND
3. NeuroSky Board
Image Notes
1. Mind Flex Headset Hacked!
File Downloads
neurosky_eeg_brainwave_chip_and_board_tgam1.pdf (1 MB)
[NOTE: When saving, if you see .tmp as the file ext, rename it to 'neurosky_eeg_brainwave_chip_and_board_tgam1.pdf']
Step 5: Phase 1: EEG Monitor (Software)
As I mentioned before, the guys at frontiernerds have done an excellent job at explaining how to perform this hack and of how to interface the Mind flex headset to the
Arduino and graphing the output using Processing (which I did and worked fantastically!), so I will only go through the steps of getting the data to display on the mini
monitor. (If you are familiar with processing, I recommend you try their project. It's really interesting!)
Initial software test to make sure your mind Flex is talking to the Arduino: Run the example BrainSerialOut sketch.
Note: You will not need the Mini display for this test, and if you have it connected nothing will display on it yet.
1.- You will need to download and install the Brain Library from the frontiernerds web site.Decompress the zip file and drag the "Brain" folder to the Arduino's "libraries"
folder inside your sketch folder. Restart the Arduino IDE.
http://www.instructables.com/id/Mini-Arduino-Portable-EEG-Brain-Wave-Monitor-/
You should now be able to see the library and examples in select File > Examples > Brain > BrainSerialOut sketch.
If you were successful at installing the libraries, and loading the BrainSerialOut sketch, Click on the verify button to compile the sketch and make sure there are no errors.
It's time to connect your Arduino to your PC using the USB cable, and click on the upload button to upload the sketch to the Arduino.
Plug the two wires that you put in the Mind flex headset to the Arduino: the T signal wire from the mind flex to the rx pin in the Arduino; The ground wire from the Mind flex
headset to the Arduino gnd pin.
Once the sketch is uploaded to the Arduino, make sure your Mind flex headset is connected to the Arduino, and turn it on. Open the serial monitor.You should see a
stream of coma separated numbers scrolling by.
NOTE:
If the sketch doesn't upload and you get a message like the one below,
Disconnect the wire from the arduino rx pin, it sometimes interferes with the upload process.
Note that the connection to the Neurosky headset is half-duplex — it will use up the rx pin on your Arduino, but you will still be able to send data back to a PC via USB.
(Although in this case you won't be able to send data to the Arduino from the PC.)
once disconnected click on the upload button again and, if successful, reconnect the wire to the rx pin.
If you got the serial data stream showing up an the serial monitor, you are ready to go to the next step.
Image Notes
1. data stream from Mind Flex
http://www.instructables.com/id/Mini-Arduino-Portable-EEG-Brain-Wave-Monitor-/
Step 6: Phase 1: EEG Monitor (Data explanation) Continued....
Here's a Brief explanation of the data you are seeing: ('cause I thought you'd ask). Comes directly from the Brain library documentation.
The getCSV() function returns a string (well, char*) listing the most recent brain data, in the following format: "signal strength, attention, meditation, delta, theta, low
alpha, high alpha, low beta, high beta, low gamma, high gamma"
Signal strength ranges from 0 - 200. 0 means the unit has connected successfully, and 200 means there is no signal.
The attention and meditation values both run from 0 - 100. Higher numbers represent more attention or meditation.
The EEG power values — delta, theta, etc...- are a heavily filtered representation of the relative activity in different brain wavelengths. These values can not be mapped
directly to physical values (e.g. volts), but are still of use when considered over time or relative to each other.
Brain(HardwareSerial &_brainSerial)
Instantiates the brain library on a hardware serial port.
boolean update();
Call this in your main loop to read data from the headset. Returns true if there is a fresh packet.
char* readErrors();
Character string containing the most recent errors. Worth printing this out over serial if you're having trouble.
char* readCSV();
Character string with all of the latest brain values in a comma-delimited format. Intended to be printed over serial. The data is returned in this order: signal strength,
attention, meditation, delta, theta, low alpha, high alpha, low beta, high beta, low gamma, high gamma
byte readSignalQuality();
Returns the latest signal quality reading. 200 is no signal , 0 is high (good connection) . This (and the remainder of the functions) are mainly intended for use when you
want the Arduino to use the brain data internally. (Saves you the hassle / memory expenditure of parsing the CSV.)
byte readAttention();
Returns the NeuroSky "eSense" attention value.
byte readMeditation();
Returns the NeuroSky "eSense" meditation value.
http://www.instructables.com/id/Mini-Arduino-Portable-EEG-Brain-Wave-Monitor-/
Image Notes
1. Data displayed in TFT display,wait 'till next step
Brain brain(Serial);
void setup(void) {
Serial.begin(9600);
}
void loop() {
if (brain.update()) {
if (brain.readSignalQuality() > 100) {
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0,30);
tft.setTextColor(ST7735_RED,ST7735_BLACK);
tft.println("signal quality low");
}
else {
tft.setCursor(30,0);
tft.println("EEG Monitor");
http://www.instructables.com/id/Mini-Arduino-Portable-EEG-Brain-Wave-Monitor-/
tft.drawLine(0, 20, tft.width()-1, 20, ST7735_WHITE);
tft.drawLine(0, 130, tft.width()-1, 130, ST7735_WHITE);
tft.setCursor(0, 30);
tft.setTextColor(ST7735_YELLOW,ST7735_BLACK);
tft.print("signal quality :");
tft.print(brain.readSignalQuality());
tft.println(" ");
tft.setTextColor(ST7735_RED,ST7735_BLACK);
tft.print("Attention :");
tft.print(brain.readAttention());
tft.println(" ");
tft.setTextColor(ST7735_WHITE,ST7735_BLACK);
tft.print("Meditation :");
tft.print(brain.readMeditation());
tft.println(" ");
tft.setTextColor(ST7735_GREEN,ST7735_BLACK);
tft.print("Delta : ");
tft.print(brain.readDelta());
tft.println(" ");
tft.print("Theta : ");
tft.print(brain.readTheta());
tft.println(" ");
tft.print("Low Alpha : ");
tft.print(brain.readLowAlpha());
tft.println(" ");
tft.print("High Alpha : ");
tft.print(brain.readHighAlpha());
tft.println(" ");
tft.print("Low Beta : ");
tft.print(brain.readLowBeta());
tft.println(" ");
tft.print("High Beta : ");
tft.println(brain.readHighBeta());
tft.print("Low Gamma : ");
tft.print(brain.readLowGamma());
tft.println(" ");
tft.print("Mid Gamma : ");
tft.print(brain.readMidGamma());
tft.println(" ");
}}
}
void tftPrintTest() {
tft.setTextWrap(false);
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0, 10);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
tft.println("INSTRUCTABLES.COM");
delay(500);
tft.setCursor(40, 60);
tft.setTextColor(ST7735_RED);
tft.setTextSize(2);
tft.println("EEG");
tft.setTextColor(ST7735_YELLOW);
tft.setCursor(20, 80);
tft.println("Monitor");
tft.setTextColor(ST7735_BLUE);
delay(50);
}
http://www.instructables.com/id/Mini-Arduino-Portable-EEG-Brain-Wave-Monitor-/
Image Notes Image Notes
1. Mind flex headset 1. screen with data coming from headset
2. Sketch start up screen
Image Notes
1. My smoke extractor.. in use
http://www.instructables.com/id/Mini-Arduino-Portable-EEG-Brain-Wave-Monitor-/
Related Instructables
http://www.instructables.com/id/Mini-Arduino-Portable-EEG-Brain-Wave-Monitor-/
Advertisements
http://www.instructables.com/id/Mini-Arduino-Portable-EEG-Brain-Wave-Monitor-/