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. I tried your code with my mindwave but it didn’t connect with my device while I changed the code to my mindwave device but still didn’t work, any suggestion why?

  2. I am using raspberry Pi 3 and nuerosky mindwave mobile 2 how I can I install mindwave package

    • I’m sorry but i do not have a MindWave Mobile 2 so i can’t test this. But the API is quite open so prolly someone other has what you need.

  3. Good day! I would just like to ask how to interface the mindwave mobile to raspberry pi 3 model B? thank you!

    • Hi,

      this tutorial is just for the old Neurosky Mindwave, not the mobile edition. But if you search for mindwave mobile python interface you’ll find some GitHub repositories which might work for your version.

      Good luck!

  4. Hi!

    This setup is closest to what I need but since I actually never done any RaspberryPi or Python or EEG or any equivalents for that matter, I’m real need for precise directions… :D :/

    I need RaspberryPi camera to shoot every time I blink (not intentionally but literally every time I do a blink, yes, that’s about 28,000 blinks per day…)

    As far as I understand:
    – option 1: NeuroSky got a blink camera for Android phone – https://store.neurosky.com/products/blink-camera-android. If I change its setting to recognise not a 3 sec long blink but literally every (0.3-0.4 sec long) blink and also send this not to phone camera but to a RaspberryPi camera or a mini spy camera https://www.amazon.co.uk/gp/product/B06WLMGJV5/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1
    – option 2: Python mediates between Neurosky and RaspberryPi camera: headset detects blinks – Python colour codes them and sets RaspberryPi to react by making a shot each time

    In both cases Bluetooth is easier.

    Once again, I really have no understanding of what I’m talknig about, so I would so appreciate a desription of what and how to do in this case…

    Thank you so much in advance!


    • Hi Zhenya,
      i do not think the Neurosky Mindwave will suit your needs. Will the camera and the eye always have the same position to each other? If so, it might be possible to catch blinks with pixel changes from frame to frame with MotionPie for example. If the camera is fixed, but you move, you’d probably need face detection and then mimic recognition, which will be difficult to build.

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

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

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

      • I think you can get a bit more out of the headset.
        Alpha, theta, blinking appear to be available at some level if you can get into the code.
        It must also have custom software supplied with it? Proabably runs as a stand alone program in windows?

        • Hi,

          good to see that it’s on pypi! If you look for reviews of the old Neurosky Mindwave on Amazon, there’s a lengthy discussion with an advanced user and a sales rep. The user has some good points why the device can’t give alpha and theta reliably. The windows software only uses general attention and relaxation levels for its brain training/meditation.
          Newer devices might have a more advanced design, but the one the tutorial describes uses an ear clip, which means they’re factoring in pulse for estimating attention and relaxation.

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


Time limit is exhausted. Please reload CAPTCHA.