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.
Sounds highly interesting and quite futuristic as well? So let’s start the project by shopping for the following components.
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.
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.
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: https://github.com/lihas/NeuroPy cd NeuroPY/NeuroPy Python test.py
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
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.
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.
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