Sunday, May 26, 2024

Brain Controlled IoT EEG

Have you ever wondered about controlling things using your thoughts? If you concentrate on lights or TV and think of triggering them ON or OFF with just your thoughts, will you be able to do so? The answer is YES. 

To achieve this, the brain data corresponding to the level of mental attention needs to be obtained using an EEG sensor. This level is then given a threshold value. When the attention level goes above this threshold value, then lights or other IoT connected appliances (that were thought of) switch on. 

This IoT project doesn’t end here. The journey of discovery will continue, which will later evolve into a brain-computer interface (BCI) and become the world’s first thought translator.

- Advertisement -

Sounds highly interesting and quite futuristic as well? So let’s start the project by shopping for the following components.

brain controlled
Brain controlled device

Bill Of Material  


There are various EEG sensors such as OpenBCI, NeuroSky MindWave etc, available in the market. For this project, the Neurosky MindWave Mobile 2 EEG sensor is being used. So install the Bluez driver into the Raspberry Pi. If you have the latest version of the Raspbian OS, then there is no need to do so as the driver and relevant software is pre-installed. 

- Advertisement -

Now open the Bluetooth devices in the settings and pair the EEG sensor via Bluetooth with the Raspberry Pi. On successful connection with serial ports, a message with the serial port name will be displayed. Note it down. 

Fig 1. Bluetooth setting
Fig 2. Serial port name

Next, retrieve the EEG sensor data over Bluetooth using Python. Note here that different sensors have different Python modules and libraries that read EEG sensor data. Since we have used MidWave 2 here, install its Python module named NeuroPy. Open the terminal and install this module using pip.

sudo pip3 install NeuroPy (for Python 3).

Because the library faces some problems with Python 3, Python 2 has been used instead.

sudo pip install NeroPy (for python 2)

Because the EEG sensor is already paired with the Raspberry Pi, you can read the connected EEG sensor data. Now wear the EEG sensor on your head. To test the EEG sensor data, clone the library and then run the test example code using following

sudo git clone:

cd NeuroPY/NeuroPy  


The library will help you obtain the following EEG sensor data: 

  • Low theta waves
  • High theta waves 
  • Low beta waves 
  • High beta waves 
  • High gamma waves 
  • Low gamma waves
  • Attention 
  • Meditation 
  • Waves 
  • Eyeblink

To control the connected IoT devices such as electric lights, fans, etc, use the Attention, Meditation and Eyeblink data.


First, include the NeuroPy and gpiozero Python modules in the code. Then set the COM port name for the EEG sensor.

After doing so, set the pin number for controlling the electric lights, fans, etc.

Fig 3.

Next, create a function that checks the brain signals/waves like alpha waves, beta waves, gamma waves and so on, so that your attention value can be determined. If it exceeds the pre-set threshold value of 80 while thinking of switching ON/OFF the desired electric device (in this case electric lights), then it will occur automatically – like magic.

Fig 4. Code processing EEG brain signals


Fig 5. Connection with Relay and Rpi


Fig 6.Connection with relay and bulb


After making the appropriate connections, run the code in an IDE or terminal and concentrate on switching a light bulb ON/OFF with your thoughts. When they meet or exceed the set threshold value, the light bulb will glow instantly.

 Congrats !!!! You have just controlled an electric device using your thoughts

Download Source Code

This article is a part of the Top 30+ IoT Projects | IoT Project Ideas for Enthusiasts. If you want to read more interesting IoT Projects can go through this article.
Ashwini Sinha
Ashwini Sinha
A tech journalist at EFY, with hands-on expertise in electronics DIY. He has an extraordinary passion for AI, IoT, and electronics. Holder of two design records and two times winner of US-China Makers Award.



Unique DIY Projects

Electronics News

Truly Innovative Tech

MOst Popular Videos

Electronics Components