Thursday, September 17, 2015

Configuring and Connecting HC-05 Bluetooth to Mindwave edited by coty



Here's a selfie of me and the mindwave. LOL

I realised that there are no proper tutorials that address the 100000000000 problems I had with the module. People actually took weeks to make this work. (they said so in their blogs and in forums)




Get that thang into AT MODE first

BASIC CONFIG
///HOW TO CONNECT HC-05 TO AT MODE///
//STATE and EN(KEY, on some boards) not necessary to hook them up//

1º Connect TX with 10,RX with 11,VCC(3.3v) (I used 5v also ok) and GND
2º Load the program in Arduino

Model ZS-040
1º Push button in bluetooth module and hold (DO NOT LET GO)
2º Disconnect VCC of bluetooth module and pluck it back in
3º Release button (OK LET GO) - Led must flash very slow. about 2 secs interval Now you are in AT MODE
4º Reset Arduino with reset button
5º Start the Monitor Serial, select "Both NL & CR"
6º Enter command "AT" and Enter. You must receive OK.

MINDWAVE configuration

Get the unique identifier from the Bluetooth devices: 74e5,43,9c5fe8

Problems I encountered
//make sure its at 3.3V instead of 5V, the hc05 can't handle it.

//RX-RX, TX-TX for configuring (in this case its pin 10 & 11)
//RX-TX, TX-RX only if looking out for output
Honestly, just switch it around until you get something out of the serial monitor. Different sites and trial and errors are telling me different things.

//mindwave ID - remove semicolons and replace with commas. make sure its 4,2,6 digits

//To pair with Mindwave, press reset button on board then switch on Mindwave after like 4 secs. Push the knob on the mindwave up to pair it. You don't need to push up the knob the second time you pair it, it would connect automatically. BUT, if you reboot everything (ie. plug out the USB and plug it back in, the connection is automatically severed and you have to pair it again. Like push the knob.)

The led should turn solid blue and shouldn't blink. Check your Serial monitor and make sure its set at 57600 baud rate, Both NL & CR//

//Once connected, if you switch between baud rates in the serial monitor your connection will be cut off.
Solution: restart it again.//

//If you cannot pair the mindwave automatically, it is probably the password problem.
Solution: Try configuring it to either 1234 or 0000. I changed mine to 0000 and it worked.//

//IF YOU GET THIS ERROR:
Basically you have trouble uploading the new sketch(it takes forever) unto the board and you get this error at the console.
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

Solution: Unplug the VCC power wire Hc-05 from the board and upload the sketch. Once the upload is done, plug it back in. voila.//


CURRENT PROBLEM
//COM PORT ERROR IN USE although there's totally nothing using it here's a link to a forum that explained my problem but never really solved it.
http://forum.arduino.cc/index.php?topic=134039.0


I got this problem because my PC automatically shuts down the port after awhile, stopping the board from receiving any data from the mindwave. It would only send about like 6 lines of information then just completely shuts off the port. 

Solution: not yet found but a lot of them are blaming something in the PC or the USB for shutting it down. I tried to do this:

Write "regedit" to start/run and open it.
At opening window you will see a group of folders left side.
Choose   HKEY_LOCAL_MACHINE \ SYSTEM \ Curr entControlSet \ Control \ Windows \ ErrorMode

Right click to ErrorMode and open.
Than change the number (0) to (2)

(If its already (2) dont make any change, this means
your problem is not an USB connection problem so
my method will not help you to fix this problem)

Restart the computer.

First connect your Arduino to USB, than open the IDE software.
Load your sketch.

But it still doesn't work. My com keeps shutting off the port.//
_______________________________________________________________________________
EXTRA NOTES


POOR_SIGNAL Quality:
this unsigned one-byte integer value describes how poor the signal measured by the
thinkGear is. It ranges in value from 0 to 200. Any non-zero value indicates that some sort
of noise contamination is detected. the higher the number, the more noise is detected.

Basically, the lower the number , the better.

Attention:
Determines the case in the code based on what is received

Time since last packet:
Millis (how much time has lapsed since last reading.

Info from: http://www.uninettunouniversity.net/allegati/1/CommonFiles/Eventi/it/30/705/Brain%20Computer%20Interface%20System.pdf
_______________________________________________________________________________

//Sketch to upload to MEGA for Bluetooth//

//hit Enter after typing AT

#include <SoftwareSerial.h>
#define rxPin 10
#define txPin 11
SoftwareSerial mySerial(rxPin, txPin); // RX, TX
char myChar ;
void setup() {
  Serial.begin(9600);
  Serial.println("AT");
  mySerial.begin(38400);
  mySerial.println("AT");
}
void loop() {
  while (mySerial.available()) {
    myChar = mySerial.read();
    Serial.print(myChar);
  }
 while (Serial.available()) {
    myChar = Serial.read();
    Serial.print(myChar); //echo
    mySerial.print(myChar);
  }
}

https://www.pantechsolutions.net/interfacing-mindwave-mobile-with-arduino
http://blog.theinventorhouse.org/como-conectar-bluetooth-hc-05-arduino-y-diadema-mindwave-neurosky/

my brain. is a hurting.

10 comments:

  1. Please help me in obtaining the attention value on serial monitor.I am using bluetooth module HC-05 for connecting my neurosky mindwave mobile starter kit.
    Thank You

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Hi,
    I bought a new MindWave mobile, its working properly with the software provided. I tried to connect Arduino with the mind wave mobile. I configured and connected the bluetooth module as provided in the links below,
    1. http://developer.neurosky.com/docs/doku.php?id=mindwave_mobile_and_arduino
    2. https://www.pantechsolutions.net/interfacing-mindwave-mobile-with-arduino
    but getting irregular symbol not a single value
    please provide needful suggestions.

    Thank You.

    ReplyDelete
  4. hello charissa, i have solved all my problems by following your instructions but mostly getting attention level is zero and poor quality 120 (in 90% cases). only sometimes i can get the attention which is above 50.. and only sometimes i get the values in just 1 second otherwise it takes 4-5 seconds and sometimes more than it... please help me. i used code available for only showing attention level. here i mention its link.... http://www.cs.csub.edu/~is-green/files/REVsUP15P2.pdf

    ReplyDelete
    Replies
    1. did u get all the data ??
      attention and meditation . i cant get those data.only poorquality data is working.. help me if u find those data

      Delete
  5. Thank you so much, we solved our problems thanks to your post !
    There was two of us and we spent hours trying to figure out why we couldn't get the mindwave to pair with the HC-05... turns out it was only because of the password (changing it to 0000 as you recommended did the trick).

    ReplyDelete
    Replies
    1. did u get all the data ??
      attention and meditation . i cant get those data.only poorquality data is working.. help me if u find those data.

      Delete
  6. i cant get the attention level its always remain 0 . bt poorquality works good.what to do. help me out please
    i used https://www.pantechsolutions.net/interfacing-mindwave-mobile-with-arduino
    code.

    ReplyDelete
    Replies
    1. There could be a few things going on. If PoorQuality isn't 0, the headset can't calculate attention / meditation values and they will be 0. So you need to make sure that value is 0 (the headset is on your head well).

      Other possible problems are SoftwareSerial. I've been trying to read mindwave -> hc-05 -> arduino for quite a few months, and finally I was like "Well fine, I'l try hooking up to a secondary hardware serial port that this board has" and yep, all of a sudden all of my checksums were calculating out just fine. SoftwareSerial can't process the data coming in from the HC05 reliably.

      Delete
  7. I did all the procedure as mentioned in the above article. But couldnot pair HC-05 with neurosky headband. You guys said about changing the password to "0000", is it of HC-05 or neurosky headband? Please help me...

    ReplyDelete