EEG
We build an EEG headset which allows the user to send morse code to a computer using their brain wave activity.
Install / Use
/learn @ryanlopezzzz/EEGREADME
Project Description
This project builds an EEG device that measures brain waves to determine if the user is concentrating or relaxed. An EEG uses electrodes placed on the user's scalp to measure the voltage difference between brain regions. These voltage differences oscillate and represent synchronized activity over a network of neurons. Depending on the electrode placements, brain waves have different characteristic frequency, magnitude, and are related to different brain activities. In our project, we measure alpha waves originating from the occipital lobe because they are one of the strongest EEG signals. Alpha waves have a signature frequency in the range of 8-12 HZ. It reflects activities of the visual cortex: their magnitude is increased with closed eyes and relaxation, and decreased with open eyes and concentration.
In our project, we use a circuit to amplify the electrode signals from the brain, and uses a number of high pass, low pass, and notch filters to filter out frequencies outside of 8-12 HZ. Then, we take data with a raspberry pi 4 and post-process the data using digital filters and analyze it with statistical methods. In the end, we successfully captured alpha waves and observed that its magnitude varies significantly between a concentrated and relaxed state. Furthermore, we came up with three applications that utilize our EEG device:
1st application: use EEG to play "EEG bird" (modeled after flappy bird).
- https://youtu.be/KFIHE_fInmM
2nd application: use EEG to monitor child attention level. We had fun making this video!!
- https://youtu.be/HQ8krHOXocc
3rd application: brain-to-text communication, in hope to help paralyzed people communicate.
- https://youtu.be/74iM_w6vFuU
We based our project on the guidance of an amazing article instructables.com/DIY-EEG-and-ECG-Circuit/. However, we created our own circuit design, wrote our own code for data-taking and analysis, and included unique and fun applications. We hope this Github Repository can help people implement and debug their own EEG circuit. Make sure to check out the circuit debugging tips section if you are working on a similar project and your circuit doesn't work!
Our project presentation: https://docs.google.com/presentation/d/12gxBqD7eJtzKXW-NE2dzhQD0BcE0SRJ6LncpbzUi6I8/edit?usp=sharing
Methods
List of Components
- Raspberry Pi 4
- TDE-2143-C EEG Gold Cup Electrodes
- Electrode gel, tape
- Instrumental Amplifier AD622ANZ
- Quad Operational Amplifier TL084x
- Potentiometer CT6EW102-ND, 1kOhm
- Capacitors and Resistors
- Two 9V batteries and battery cases
- Bread board and wires
- ADC Chip (We used ADS 1015)
- Multimeter (for testing circuit)
- Open Scope MZ (Used as oscilloscope and wave generator for testing circuit only due to covid, if you have access to a real oscilloscope and wave generator, lucky you and go for those)
Wiring

The above diagram describes the complete EEG setup. The user tapes 3 electrodes to their scalp at various locations to measure the brain's electrical signals. These electrodes are attached to the circuit, which serves to amplify alpha waves and filter out other signals. The voltage output of the circuit is measured with the ADC and the data is sent to the Rpi. The Rpi applies further digital filtering and outputs the voltage of the user's alpha waves.
Note that we have two different grounds; the ADC and Rpi ground (black) at 0V, and the circuit ground (pink) at 3.3V. This design choice is due to ADC input voltage limitations and is explained in detail later. To get the -9V to 9V of power with respect to the 3.3V ground, connect one 9V battery the correct way, and the other one backwards.
Here is a picture of the physical setup:
<img src="images/physical_setup.png" width=500>Electrode Placement for Alpha Waves Measurements
There are many possible electrode placements depending on what wave one chooses to measure. In our project, we measure alpha waves. We need to use three electrodes: one at the left mastoid (the bone at the back of the left ear) which is connected to the ground of the circuit. This electrode helps with noise cancelling; one located one inch above and one inch to the right of the nasion (the midline bony depression between the eyes where the frontal and two nasal bones meet); the last one located one inch above and one inch right of the inion (the projecting part of the occipital bone at the base of the skull). The 2nd and 3rd electrode placements are approximately in O2 and Fp2 regions in the below diagram:
<img src="images/head.png" width=400>The voltage difference oscillations between the 2nd and 3rd electrodes are the target alpha waves, which is then fed to the circuit to be amplified and filtered.
Circuit Schematic

The circuit consist of the following sections:
- Instrumental Amplifier (gain ~91)
- Notch Filter (60 Hz, gain = 1)
- High Pass Filter (Fc = 7.2 Hz, gain = 1)
- Low Pass Filter (Fc = 32.9 Hz, gain = 1)
- Instrumental Amplifier with variable gain (gain ~90-460)
- Notch Filter (60 Hz, gain = 1)
The total filter responses without gain are shown below:
<img src="testing_circuit/figures/circuit_VG.png" width=600><img src="testing_circuit/figures/circuit_dB.png" width=600>
Individual Section are discussed further below.
Instrumental Amplifier (gain ~91)
<img src="images/circuit1.png" width=400>Alpha wave signals are 15-50 uV so we need a lot of amplification in the circuit. An instrumentation amplifier takes as its inputs 2 voltages, and outputs the difference between the two multiplied by some gain given by: G = 1 + (50.5 kOhm)/R, where R is the total resistance between pin 1 and 8. Note it is possible to make a home-made instrumentation amplifier with 3 op-amps. However, it suffers from a low CMRR unless precision resitors are used (info from Instructable).
1st Notch Filter (60 HZ, gain = 1)
<img src="images/circuit2.png" width=475> <img src="testing_circuit/figures/notch1_dB.png" width=475>
The biggest source of noise in our system is centered at 60 Hz due to power line interference. This noise is present even though we use batteries to power the circuit. Thus we have 2 notch filters in the circuit (filters that have a severe reduction of gain around 1 particular frequency). The first notch filter intends to filter out interference before more gains are applied.
The notch frequency is given by f = 1/(2 PI R C) where R = R3 = R5. The other two resistor values are related to the quality factor of the filter, which determines how sharp the attenuation is.
High Pass Filter (Fc = 7.2 Hz)
<img src="images/circuit3.png" width=475> <img src="testing_circuit/figures/hp_dB.png" width=475>
The high pass filter intends to filter out frequencies corresponding to galvanic skin response across our head. This interference is primarily low frequency. A second order active filter design is used here and is shown to be necessary for noise reduction.
Low Pass Filter (Fc = 32.9 Hz)
<img src="images/circuit4.png" width=475> <img src="testing_circuit/figures/lp_dB.png" width=475>
The EEG waves of interest to our project are alpha (8-12 HZ) and beta waves (12-30 HZ). Thus, we are not interested in frequency > 30HZ and filter them out. A second order filter design is used.
Instrumental Amplifier with variable gain (gain ~ 90-460)
<img src="images/circuit5.png" width=400>This 90-460 gain is on top of the 90x gain from the first instrumentation amplifier. Alpha wave amplitude varies from person to person, from about 15 to 50 uV. Using a middle value of 30 uV, this means the ending voltage reading could range from 909030e-6 = 0.243V to 4609030e-6 = 1.242V. The variable gain is achieved by putting resitors in series and in parallel. The gain is roughly in the range of 90-460, which corresponds to potentiometer value 1k (maximum) to 0 (minimum).
To adjust the potentiometer, start taking readings and make sure one is not moving at all. Make sure voltages don't fluctuate offscreen, but avoid making it too small because then the errors incurred from digitally reading the data into the Rpi would be relatively increased.
2nd Notch Filter (60 HZ, gain = 1)
<img src="images/circuit6.png" width=475> <img src="testing_circuit/figures/notch2_dB.png" width=475>
Another 60 HZ is necessary at the end of the circuit since the power line interference seeps into the circuit through prior steps. This is the exact copy of the 1st notch filter
Connecting ADC to Rpi
Supply the ADC chip with 5V from Rpi to ensure the maximum input voltage range possible. The pin configuration and connection in the image above is correct, but it is recommended to double check the connection, because wiring mistakes can lead to damaging the chip and/or the Rpi.
Circuit Debugging Tips
If the circuit doesn't work:
- Check every individual section and make sure it is doing its job
- Read data sheet and make sure nothing is over-strained
- Use multimeter and oscilloscope to check everything!
- Listen to the circuit pros: h
