loading
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,

The Vital signs we will eventually, be monitoring are:

Heart Rate
Body Temperature
GSR

But in Phase 1 we will be Monitoring.

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...

Step 1: Parts List / Tools Needed

PARTS
1 Arduino Uno R3
1 SainSmart 1.8 " Color TFT Display
1 Mini Breadboard
1 Mind Flex  EEG Headband -To monitor Brain Wave signals as described Here I recomend you review this project before starting to build this instructable. You will need to download the brain library found in the website
3 x AAA Batteries (for Mind flex headband)
1 x 9v battery +  (9v to Arduino power adapter cable, for portability) - optional, but needed to enter the battery operated contest! (if you like this instrucable , please vote for me :)
Jumper Wires
Scrap wire /  cable from your Junk Box about 12" long
TOOLS
Soldering Iron
Wire Cutter /  Stripper
Screwdriver ,small Phillips head
Magnifying Glass

Step 2: Setup Arduino and TFT Color Display

Go to my Mini Arduino enviroment monitor instructable and follow steps 1 though 3 to get the LCD color display working.

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) {

  tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab
 
  // Start the hardware serial.
  Serial.begin(9600);
//  tft.setCursor(0, 30);
// tft.setTextColor(ST7735_RED);
tft.fillScreen(ST7735_BLACK);
tft.drawLine(0, 50, tft.width()-1, 50, ST7735_WHITE);
  tft.setCursor(0, 60);
  tft.setTextColor(ST7735_YELLOW);
  tft.println("Body Temp : ");
  tft.setTextColor(ST7735_RED);
  tft.println("Heart Rate: ");
  tft.setTextColor(ST7735_GREEN);
  tft.println("GSR VAL   : ");
  tft.setTextColor(ST7735_YELLOW);
  tft.println("EEG signal: ");
  tft.setTextColor(ST7735_WHITE);
  tft.println("Attention : ");
  tft.setTextColor(ST7735_WHITE);
  tft.println("Meditation: ");
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());
}}

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.

So lets start with the EEG Monitor:

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.

You will need to have the Mind Flex headset.

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.)

2.- Open the case to expose the electronics.

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.

We are done with the hardware part of the Hack.

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.

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!)

OK. Lets Start:

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.

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,

avrdude: stk500_getsync(): not in sync: resp=0x00

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.


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.

FUNCTION OVERVIEW - A list of functions available in the Brain Library

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.

unsigned long* readPowerArray();
Returns an array of the eight power-band (FFT) values, in the same order as the CSV.

unsigned long readDelta();
Returns the delta (1-3Hz) power value, often associated with sleep.

unsigned long readTheta();
Returns the theta (4-7Hz) power value, associated with a relaxed, meditative state.

unsigned long readLowAlpha();
Returns the low alpha (8-9Hz) power value, higher when eyes are closed or you're relaxed/

unsigned long readHighAlpha();
Returns the high alpha (10-12Hz) power value.

unsigned long readLowBeta();
Returns the low beta (13-17Hz) power value, higher when you're alert and focused.

unsigned long readHighBeta();
Returns the high beta (18-30Hz) power value.

unsigned long readLowGamma();
Returns the low gamma (31-40Hz) power value, associated with multi-sensory processing.

unsigned long readMidGamma();
Returns the high gamma (41-50Hz) power value.

Step 7: Phase 1: EEG Monitor (Displaying Data in TFT Display) Continued....

Before we proceed to the sketch, I want to share some  notes with you.
1.- If the signalquality is anything but 0, you will not get a meditation or attention value.
2.-  The values for the brain waves( Alpha, Beta, Gamma, etc... ) are kind of nonsensical. They still change value even if the signal quality is greater than zero! Also  if you place any finger on the forehead sensor  and another one on the ear sensor on the left pad, you still get readings for all the brain wave functions. I mention this because I'm not quite sure whether the values are actually very reliable. In any case, the only values that are usable, if you want to control something with your brain are the  Attention and meditation.

Alright, so here's the code:

// Copy and Paste the sketch below to your ardunio IDE .
#define sclk 4
#define mosi 5
#define cs   6
#define dc   7
#define rst  8


#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);

Brain brain(Serial);

void setup(void) {

  tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab



tftPrintTest(); //Initial introduction text,
 delay(1000);

  tft.fillScreen(ST7735_BLACK); //  clear screen
  tft.setTextColor(ST7735_WHITE);
  tft.setTextSize(1);
  tft.setCursor(30,0);
  tft.println("EEG Monitor");
    
      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");
   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);
  }

Step 8: Final Thoughts and Going Forward..

I will be updating this instructable as i continue to develop the project. for now I'll leave you with some pictures and a video.. If you have any questions, suggestions, and / or comments, please  use the comment. option, I will try to answer and use your suggestions.  If this instructable qualifies for a contest, and you enjoyed it please vote for me. Thanks for your time and support.

Step 9: Video

<p>halo sir johnag..after i read about your explanation im very interested to delevop project regarding the EEG headset..can you share your full report with me at email address (onezelan5259@gmail.com)</p>
can you run the without the monitor. just using the computer to as the monitor <br>
<p>i had tried and it really works!!but the data is obtained only at noise level is equal to zero!!!and i failed to keep that value zero always.how can i keep that noise=0???</p><p>help me please!!!</p>
<p>Would it be possible to take the readings and insert them into a formulation of lights.</p>
Great project! Is it possible to plot the waveforms in realtime? I would love to do that!
<p>exactly how much is the eeg reading accurate?? can it precisely tell about the sleep status of the person under testing??</p>
<p>Is there a way of connecting it to a computer and making a program so the computer can collect, covert and use the information? oh and can it read your Nervus system messages?</p>
Would it be possible to get the baseline reading from anywhere else other than the ears? Those ear clips do look kind of dorky. <br>My idea is to 3D print a cooler looking headset for the Mindflex pcb and sensors. More like the Force Trainer headset (which I couldn't get my hands on so I went for the Mindflex instead). <br> <br>The Force Trainer seems to get the baseline readings from behind the ears. The Mindwave seems to omit one of the ear clips at least.
I've tried it by using one earclip,( the one connected to the pod with the electronics) and it seems to work just fine. As long as the signal quality is 0 you're ok or else you wont get attention. Or meditation signals.
Thanks for sharing! Will this work with the force trainer toy?
I haven't tried It, but there's a fair amount of info that says it does. Check the frontier nerds web site..they both use the same nerosky chip.
In addition to the really useful information on the Frontier Nerds site, I have some details about getting the full raw EEG data from the headsets (which Frontier Nerds said is not possible). You have to remove the 10K resistor that connects B1 (small port on the TGAM1 board) to GND and replace with a 10K resistor from B1 to VCC.
it does
That's awesome! I just joined, I have a few really cool arduino projects I'm going to be putting up
Thanks!. By The way Great job on your &quot;spider bot &quot;
Very Cool!!
Tks

About This Instructable

123,203views

223favorites

License:

More by johnag:Arduino Color LCD Message Clock  Arduino  DEMO series  Make an Oscilloscope Using the SainSmart Mega2560 with the TFT LCD shield and the 3.5 "color touch screen 
Add instructable to: