Arduino Brain Library has blank output from serial monitor

I have done the brain hack here frontiernerds.com/brain-hack with a mindflex. The problem is I have a blank serial monitor with no numbers. Does anyone with brain library experience know why this might be? The code is as follows:

#include <Brain.h>

// Set up the brain parser, pass it the hardware serial object you want to listen on.
Brain brain(Serial);

void setup() {
    // Start the hardware serial.
    Serial.begin(9600);
  
}

void loop() {
    // 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()){
         
        Serial.println(brain.readCSV());
  }
 
}

Mecatronicsstudent: I have a blank serial monitor with no numbers.

Do you have the menu in the bottom right hand corner of the Serial Monitor window set to 9600 baud?

@Mecatronicsstudent, by now after 17 posts you should be aware that you need to place your code between code tags, and not inline. Code tags are the </> button in the “Reply” window. (Not necessarily visible in the “Quick Reply” window, depending on your forum settings. In “Profile” >Settings >Look and Layout, if you check “Use full editor in Quick Reply”, you’ll get those buttons in a “Quick Reply” window.)

As for your problem, did pert’s suggestion help? I’ve done a lot of playing with a ‘Mindflex’ headset and the “Brain” library. Your code should work OK. (It’s straight from the “BrainSerialTest” example, which worked fine for me.)

Fixed the code(It has been awhile since I used this forum). Yes do have the serial set to 9600 baud as will and the serial.begin in the code. Also, if it matters the com 3 port is also set to that. Still a blank monitor.

Is there a way I could test that the headset is sending out anything, or is the program not working an indication that it is not sending out anything. My connections inside look good. Connected to the t pin and square ground pad.

Here’s what I’d do just as a basic sanity check:

#include <Brain.h>

// Set up the brain parser, pass it the hardware serial object you want to listen on.
Brain brain(Serial);

void setup() {
    // Start the hardware serial.
    Serial.begin(9600);
    Serial.println("setup");
}

void loop() {
    // 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()){
        Serial.println("brain.update()");
        Serial.println(brain.readCSV());
  }
  Serial.println("loop"); 
}

That will confirm that the Serial communication is working correctly, that the program isn’t hanging up somewhere, and whether brain.update() is ever returning true.

Never mind it is working. Thanks for the help.

Mecatronicsstudent: Never mind it is working. Thanks for the help.

Excellent - now the fun starts.

Are you getting good readings? "poor_signal" needs to be at 0 before the 'Attention' and 'Meditation' values are valid, otherwise they just freeze at a set value.

I hope you have better luck than me, I didn't manage to get any control over the values, no matter how much I concentrated or relaxed. They seemed to have a mind of their own.

It was working for a little bit but is now blank again. When it does work it jumps from 50 to 20 to 0 at times for connection. Maybe I will put salt water on my ears. I am excited to make things that connect with this. I was thinking of finding a cheap way of making this wireless like a transmitter/receiver pair or something.

Mecatronicsstudent: It was working for a little bit but is now blank again. When it does work it jumps from 50 to 20 to 0 at times for connection. Maybe I will put salt water on my ears.

You need to get the headset sensor in exactly the right position to work reliably. I also found that tightening the headset strap helps, (but it gets painful after a while). I bought some EEG/ECG gel to improve the connection, too.

I am excited to make things that connect with this.

See if you can get reliable, controllable results from the 'Attention' and 'Meditation' values first. If you can't, there's no point in going ahead and building anything. I had no trouble getting a good signal, with it staying at 0 for long periods, but could never get real control over the values. As mentioned in my earlier post, it appeared to have a mind of it's own, and no amount of concentration/relaxation on my part made any real difference.

I was thinking of finding a cheap way of making this wireless like a transmitter/receiver pair or something.

You need something like that if you're using a PC. It's not at all recommended to connect the headset directly to a computer or to an Arduino that's connected to a computer. A laptop is OK, but not a PC that connects to mains power.

I used an APC220 433MHz transceiver attached to my headset, and powered by the headset batteries, with another connected to the Arduino or PC, but many people use Bluetooth modules, or even ZigBee.

Alright, so this is weird. If I plug the ground wire into the 5v pin on arduino I get readings but when it is plugged into ground I don't. I am sure that I soldered the ground to the right spot on the mind flex. If it works, is it a problem to have the mindflex's ground hooked to arduino 5v? I also had to replace the chip a while back for arduino and got one with uno bootloader. It has since thought it was an uno according to the ide. I looked to see if that would be a problem but I don't think so.

Also, with regards to the transceiver, I will need an arduino in the headset with the transceiver right? I though I would so I have a small one along with the bigger one I am using now.

"See if you can get reliable, controllable results from the 'Attention' and 'Meditation' values first. If you can't, there's no point in going ahead and building anything."

Do the other values prove to be more accurate. Or are all the values pretty much the same.

Mecatronicsstudent:
Alright, so this is weird. If I plug the ground wire into the 5v pin on arduino I get readings but when it is plugged into ground I don’t. I am sure that I soldered the ground to the right spot on the mind flex. If it works, is it a problem to have the mindflex’s ground hooked to arduino 5v?

I think you’d better double-check your connections. You definitely can’t connect the MindFlex ground to the Arduino 5V. It sounds to me like you’ve connected your ground wire to the wrong spot in the headset. I attached mine where the headset’s battery negative is soldered to it’s main board. Then, like you, I attached my serial comms wire to the “T” connection on the board.

I hope you’re not using a PC that is powered from the mains. You must use a laptop, (without plugging in the charger), to do this stuff with a direct-connection from computer to headset.

I didn’t take any photos of my ground and battery positive connections, but here’s one of the headset with the regulator board and APC220 attached to the outside:-
(The regulator’s on top, and the APC220 is underneath, mounted upside down.
Blu-Tack and hot-melt glue can work wonders. :smiley: )
MindFlex Headset Setup.JPG

I also had to replace the chip a while back for arduino and got one with uno bootloader. It has since thought it was an uno according to the ide. I looked to see if that would be a problem but I don’t think so.

You haven’t mentioned which board you’re using, but I’d imagine if you now just treat it as a UNO it’ll be fine. If you get a second Arduino, you could set it up as an ISP programmer and burn the correct bootloader to your chip.
Edit: I just realised that you already have a second Arduino, so you could already burn a new bootloader yourself if you wanted.

Also, with regards to the transceiver, I will need an arduino in the headset with the transceiver right? I though I would so I have a small one along with the bigger one I am using now.

I didn’t put an Arduino in the headset. There isn’t room inside anyway. I made a tiny 3.5V low-dropout regulator board using an LP2951 to power the APC220 module, then tapped into the headset’s battery voltage at the centre pin of the power switch. I connected the “T” pin of the headset to the APC220’s “RX” pin and configured it for 9600 baud. (The APC220 takes standard serial input.)

Do the other values prove to be more accurate. Or are all the values pretty much the same.

The raw data values are very hard to use, without advanced processing. You’d need to use a “Fast Fourier Transform” or similar to make use of them. It’s better to allow the TGAM1 chip to do the processing, and just use the “Attention” and “Meditation” values, at least for now.

Edit: It might be a good idea to delete one of your two identical posts above, too. :slight_smile:

Alright. I will recheck my connections. I can't think of why arduino 5v connected to mindflex ground would make it work. Very odd. Thanks for the tips on wireless connection. The second arduino I have is a solarbotics ardweeny so it may be small enough to fit inside.

Mecatronicsstudent: The second arduino I have is a solarbotics ardweeny so it may be small enough to fit inside.

But you don't need an Arduino inside the headset, if you use an RF module that accepts standard serial at 9600 baud. You shouldn't even need a regulator. I added one for a different reason.

Oh okay. Thanks for your help. Also, an update on the ground situation. The program also works with the ground wire stuck in tx pin, which is what sends data out. What ever I have it connected to(and I could not see much else to connect that wire to) requires power in order for the mindflex circuit to work. And if I connect the ground wire to arduino ground with it on before turning on the mindflex headset, the headset won't turn on until it is removed from arduino's ground, but will stay on after it is reinserted(Although with still no date appearing in serial). As before, the only time data will come in from the headset is when ground(or what I think is ground) is supplied with power. The batteries in the headset are fine.

Mecatronicsstudent: Oh okay. Thanks for your help. Also, an update on the ground situation. The program also works with the ground wire stuck in tx pin, which is what sends data out. What ever I have it connected to(and I could not see much else to connect that wire to) requires power in order for the mindflex circuit to work. And if I connect the ground wire to arduino ground with it on before turning on the mindflex headset, the headset won't turn on until it is removed from arduino's ground, but will stay on after it is reinserted(Although with still no date appearing in serial). As before, the only time data will come in from the headset is when ground(or what I think is ground) is supplied with power. The batteries in the headset are fine.

If I were you, I'd stop poking wires into random places before either the headset or Arduino are killed. Use your mutimeter, or trace the battery wires, to ensure that you connect the Arduino ground to the headset ground, (Where the battery negative attaches to the headset main PCB), then connect the headset's "T" connection to the arduino serial input pin. You just need those two wires. You shouldn't need to connect "power" between the Arduino and the headset's TGAM1 board. It's not rocket science, and works well when it's connected that way. (Just like my setup and the one in the "frontiernerds" article.)

I removed the board from the headset to connect the ground wire to the back, if that helps. Just trace that battery neg wire as mentioned - it's easy.

Hey,

I know it has been a while but I finally got my mindflex up and working properly. I simply wired up the ground and power wires directly from the battery. I also acquired an apc220 like you have been using. I am wondering if you could share your setup for connecting the module to the headset and the other one to the arduino? Do I have to use a special code for the arduino or would the main brain library code below work?

#include <Brain.h>
// Set up the brain parser, pass it the hardware serial object you want to listen on.
Brain brain(Serial);

void setup(){

   Serial.begin(9600);
}
void loop(){
  if (brain.update()) {
        Serial.println(brain.readErrors());
        Serial.println(brain.readCSV());
 
    }
    
   }

Thanks

Do I have to use a special code for the arduino or would the main brain library code below work?

If you have the hardware connected correctly, and are bothering to think, then there is no reason that the code that works for everyone else wouldn't work for you.

I know it works for the mindflex connected directly to arduino. I am wondering about using 2 220apc's with one connected to the headset and one connected to arduino. I have never used them before and would like to know if there is additional code on the arduino side I need.

Thanks

I am wondering about using 2 220apc’s with one connected to the headset and one connected to arduino.

A link to this 220apc would be useful.

The only thing I see that might be remotely related is a Mercedes, but I can’t imagine connecting a Mercedes to a Mindflex, or to an Arduino. I can’t imagine how the Mercedes are supposed to communicate wirelessly.