Tested on:RPi 3; Raspbian Jessie; Python 2.7
Prerequisites:Raspberry Pi with Raspbian Jessie and internet connection (see steps 1-7 in the Introduction)
Hardware:Neurosky Mindwave EEG (wifi, not the bluetooth one)
LED and a fitting resistor
2 Jumper cables male to female

Raspberry Pi mindcontrol! Neurosky mindwave as simple EEG interface

An electroencephalogram (EEG) measures brain activity with electrodes directly attached to the head. Nowadays, EEGs are very affordable- the one used in this tutorial, the Neurosky Mindwave, costs around 100€. Luckily, Moonshot Barkley already built a Python framework for accessing the Neurosky EEG. A big “thank you” to the developers!
In this tutorial, the Neurosky Mindwave will be used to display brain activity by controlling an LEDs intensity with a Raspberry Pi. Measuring brain activity allows developing a fast range of interesting devices, ranging from fun applications to scientific experiments.

Demo Video

Thousand thanks to Alex, Thesi, Alex and Tim for making this amazing demo video! For one of us, we measured absolutely zero brain activity- they are among us!

Neurosky Mindwave models
There are different product lines of Neurosky EEG sets. Some of them connect over Wifi and others use Bluetooth. This tutorial is for the Neurosky Mindwave (not Mindwave mobile!) which connects over Wifi. The bluetooth ones should run on the Raspberry Pi as well, but not with the framework in this tutorial. This is what a Neurosky Mindwave looks like:

Neurosky Mindwave EEG

Neurosky Mindwave EEG

Assemble this circuit on a breadboard:

LED circuit

LED circuit

The LED is connected to pin 11 of the Raspberry Pi in BOARD-numbering and to ground (pin 6). Make sure the resistor fits the LED; ask your vendor for an LED with resistor for 3.3V and 20mA if unsure.

Software installation
Boot the Raspberry Pi, then plug the Mindwave USB dongle into it. Enter

in the terminal and find the device identifier. Without other USB devices attached, it is ttyUSB0 like in

Also, write down the headset identifier. It is a code of four letters and located inside the battery case.
Turn on the Mindwave headset- both the headset and the dongle should show a red light for not being connected.
Type the following in the terminal:

The script needs to be configured. In the line

enter the USB identifier and headset identifier noted earlier. Save and exit nano, attach the headset to your head and start the script by typing

in the terminal.
This should print connected and the light of both the headset and the dongle should turn blue.
The current attention level is printed to the terminal and controls the intensity of the LED. The more focused you are, the brighter it will glow and it will go off if a certain level of relaxation is reached.

Code explained
The hard work of building the wifi interface is done by the great mindwave-python framework from Moonshot Barkley. The script mindwave_LED.py simply configures the LED pin for pulse-width-modulation with

Then, the attention level is being scaled in the main loop for improved visibility:

This only displays an attention level above 30 and restricts the pwm signal to a max of 100.

Click on Full Script to show all of the code.

Sample Video

Software PWM tutorial: http://www.knight-of-pi.org/simple-dc-motor-board-for-the-raspberry-pi-with-ic-l293-and-software-pulse-width-modulation/
Moonshot Barkley Neurosky Mindwave Python interface: https://github.com/BarkleyUS/mindwave-python

Knight of Pi

Johannes Bergs aka Knight of Pi. Diploma in Bioinformatics, some Webdesign and Python coding then. Living in the beautiful city of Vienna.


  1. thank you so much for useful article , i work on simillar project but with arduino usb host shield can you help me what libraries to use ?

    • I don’t know, but you could google “arduino robot mind control”. There’s a book ect. how to hack the Mindwave for an Arduino, if that’s an option.

  2. Is there any intuituve way for vizualing all of data? Something like a bar graph or linear graph. I would like to view alpha, theta…

    • I’d strongly recommend Numpy, Pandas and Mathplotlib for data visualisation. I’m planning tutorial on that, but it’ll take some time.
      For Alpha and Theta: The Python interface
      only gives “attention” and “meditation”.
      I remember an Amazon customer review discussing the accuracy of the Neurosky Mindwave for scientific experiments. The point is, this model uses an ear clip for measuring the pulse. The output combines that and the front sensor reading, so no Alpha and Theta.
      That might be different for newer models. If you experiment into that direction and find a better EEG interface, please let me know!

      EDIT: Clarity

  3. My neurosky has only a bluetooth connectivity. I have a raspberry pi3 . How can i connect the headset to my raspberry pi and how to do the above stuff.pls help

    • I don’t know the bluetooth models, but Neurosky supplies open interfaces for their headsets generally, so chances are good. Just google your specific model number plus “Python interface” and look around.

  4. Hi!
    I am working on same issue, but instead of neurosky. I was wondring if I can build my own EEG electrodes at cheap cost. I am getting problem with the Amplifiers, if you have any suggestions for me then please reply to my email.
    My project: EEG Game Simulator using BCI. I completed Hand Gesture Game Simulator & trying to create at different level: https://www.youtube.com/watch?v=4pJtTksczvs

  5. This is a subject close to my heart cheers.

  6. I was waiting for this form of issue. Thank you very much for
    the place.


Time limit is exhausted. Please reload CAPTCHA.