Project Overview
This guide provides a complete roadmap for building a personal, research-grade Brain-Computer Interface (BCI) using OpenBCI hardware, a Raspberry Pi, and your Mac. We'll follow a hybrid "buy and create" model: purchasing the core electronics and 3D printing the headset chassis. This approach offers the best balance of cost, capability, and hands-on creation.
System Architecture
The system is composed of three main parts that work together to capture, process, and stream brainwave data. The headset acquires the raw EEG signals, a Raspberry Pi acts as a dedicated data hub, and your Mac serves as the development and analysis workstation. This dual-platform design provides both portability and power.
Acquisition Headset
3D-Printed Ultracortex with OpenBCI Cyton board captures raw EEG signals.
Headless Hub
Raspberry Pi runs a Python script to manage and stream data wirelessly.
Development Workstation
Your Mac receives the data stream for analysis, visualization, and app development.
Important Disclaimer: This project is for educational and development purposes only. The resulting device is not a medical device and should not be used for diagnosis or treatment.
Interactive Shopping List
This section provides a complete, interactive checklist of all components required for the project. Check off items as you acquire them to track your progress and budget. The list is broken down into categories: the core BCI system you'll purchase from OpenBCI, the Raspberry Pi control hub, and the materials and tools you'll need for 3D printing and assembly.
Cost Breakdown
Estimated Total:
$0.00
Fabrication & Assembly
This is the hands-on part of the project. Here, you'll find instructions for 3D printing the Ultracortex headset components and a step-by-step guide to assemble the entire device, from bonding the frame to wiring the electrodes. Precision and patience are key to building a functional and reliable headset.
1. 3D Printing the Ultracortex
The first step is to fabricate the headset's chassis. You must download the official STL files from the OpenBCI GitHub repository to ensure compatibility with the purchased kit components.
Crucial Tip: Print the two large frame halves with their flat, bisected side directly on the build plate. This minimizes the need for supports and reduces warping. Use PLA filament and consider slowing your print speed for better detail.
| Part Name | Material | Layer Height | Infill | Supports |
|---|---|---|---|---|
| FRAME_FRONT & BACK | PLA | 0.2 mm | 20% | YES |
| MECH_PARTS (INSERTS) | PLA | 0.2 mm | 20% | NO |
| BOARD_MOUNT & COVER | PLA | 0.2 mm | 20% | NO |
2. Step-by-Step Assembly
Step 1: Frame Assembly
Carefully align the two 3D-printed frame halves. Apply a thin layer of cyanoacrylate super glue to the mating edges, press firmly together on a flat surface, and hold until the bond is set.
Step 2: Install Mechanical Inserts
Press-fit and glue the 35 small, 3D-printed `INSERT` pieces into the octagonal nodes from the inside of the frame. They should sit flush with the inner surface.
Step 3: Mount the Cyton Board
Secure the `BOARD_MOUNT` to the back of the frame. Connect the battery to the Cyton board, then carefully fold the battery and wires behind it before snapping the whole assembly into the mount.
Step 4: Install Electrodes
Screw the electrode units (spikey for hair, flat for bare skin) into the `INSERT`s. A good starting 8-channel layout is Fp1, Fp2, C3, C4, P7, P8, O1, O2. Use the comfort units on unused top nodes to distribute weight.
Step 5: Wire the Electrodes
This is the most critical step. Connect the ribbon cables from the electrodes to the correct input pins on the Cyton board. The ear clips connect to the `SRB2` (Reference) and `BIAS` (Ground) pins for noise cancellation.
| Channel | 10-20 Location | Cyton Pin |
|---|---|---|
| 1-8 | Fp1, Fp2, C3, C4, P7, P8, O1, O2 | N1P - N8P (Top Row) |
| REF | Left Ear Lobe | SRB2 (Bottom Row) |
| BIAS | Right Ear Lobe | BIAS (Bottom Row) |
Critical Warning: Before twisting an electrode to adjust its height, ALWAYS disconnect its wire from the board. Twisting while connected will break the internal wire and is not covered by warranty.
Software Configuration
With the hardware built, it's time to bring it to life with software. This section guides you through setting up your development environment on both macOS and the Raspberry Pi. We'll use the OpenBCI GUI for initial hardware checks and the powerful BrainFlow library for writing custom applications. The most challenging part is compiling BrainFlow from source on the Pi, a necessary step for its ARM processor.
macOS: Your Development Workstation
1. Install OpenBCI GUI: Download from the OpenBCI website. On first launch, you may need to right-click and select "Open" to bypass security warnings.
2. First Connection: Plug in the USB dongle (switch on `GPIO6`), power on the Cyton, and launch the GUI. Select the correct serial port (e.g., `/dev/tty.usbserial-DN00nnnn`) and click `Start Data Stream` to verify you are receiving data.
3. Setup Python Environment: Use a virtual environment and install BrainFlow.
python3 -m venv bci-env
source bci-env/bin/activate
pip install brainflow numpy pandas matplotlib
4. Test Script: Run this script to confirm your BrainFlow setup can connect to the board directly from your Mac.
import time
from brainflow.board_shim import BoardShim, BrainFlowInputParams, BoardIds
params = BrainFlowInputParams()
# IMPORTANT: Replace with your serial port
params.serial_port = '/dev/tty.usbserial-DN00nnnn'
board_id = BoardIds.CYTON_BOARD.value
board = BoardShim(board_id, params)
board.prepare_session()
board.start_stream()
time.sleep(5)
data = board.get_board_data()
board.stop_stream()
board.release_session()
print(f"Data acquired! Shape: {data.shape}")
Raspberry Pi: Your Headless BCI Hub
1. Prepare Pi: Flash Raspberry Pi OS Lite (64-bit) to a microSD card, enable SSH, and connect to it from your Mac.
2. Compile BrainFlow from Source: This is a mandatory and time-consuming step. Run these commands on the Pi.
# Install dependencies
sudo apt update && sudo apt install -y build-essential git cmake python3-pip
# Clone and build BrainFlow
git clone --recursive https://github.com/brainflow-dev/brainflow.git
cd brainflow
python3 tools/build.py
# Install Python bindings
cd python-package
pip install .
Running the Full System
The final step is to connect the two systems, creating a wireless data pipeline from your BCI headset to your Mac. The Raspberry Pi will act as a server, capturing data from the Cyton board and streaming it over your local network using the Open Sound Control (OSC) protocol. A corresponding script on your Mac will listen for this data, making it available for your applications.
1. Pi Hub Streamer Script
Create this file (`pi_hub_streamer.py`) on your Raspberry Pi. It connects to the Cyton and sends EEG data to your Mac's IP address. First run `pip install python-osc`.
import time, argparse
from brainflow.board_shim import BoardShim, BrainFlowInputParams, BoardIds
from pythonosc import udp_client
parser = argparse.ArgumentParser()
parser.add_argument("--ip", default="192.168.1.100", help="Mac's IP")
args = parser.parse_args()
client = udp_client.SimpleUDPClient(args.ip, 5005)
params = BrainFlowInputParams()
params.serial_port = '/dev/ttyUSB0'
board = BoardShim(BoardIds.CYTON_BOARD.value, params)
eeg_channels = BoardShim.get_eeg_channels(BoardIds.CYTON_BOARD.value)
board.prepare_session()
board.start_stream()
print("Pi Hub streaming started...")
while True:
data = board.get_current_board_data(25)
if data.shape[1] > 0:
for sample in data[eeg_channels].T:
client.send_message("/eeg", sample.tolist())
time.sleep(0.02)
2. Mac Receiver Script
Create this file (`mac_receiver.py`) on your Mac. It starts a server that listens for and prints the EEG data coming from the Pi. First run `pip install python-osc`.
import argparse
from pythonosc import dispatcher, osc_server
def eeg_handler(address, *args):
print(f"EEG Data Received: {args}")
parser = argparse.ArgumentParser()
parser.add_argument("--ip", default="0.0.0.0")
parser.add_argument("--port", type=int, default=5005)
args = parser.parse_args()
disp = dispatcher.Dispatcher()
disp.map("/eeg", eeg_handler)
server = osc_server.ThreadingOSCUDPServer((args.ip, args.port), disp)
print(f"Serving on {server.server_address}")
server.serve_forever()
To Launch:
- Find your Mac's local IP address.
- On the Pi, run: `python pi_hub_streamer.py --ip
` - On the Mac, run: `python mac_receiver.py`
- You should see EEG data printing in your Mac's terminal!
Conclusion & Next Steps
Congratulations! You have successfully built a research-grade BCI and established a data pipeline. This is not an end, but a beginning. Your robust and flexible platform is now ready for you to explore the vast world of neurotechnology. The journey into personal BCI development is challenging but rewarding, and you are now equipped to start creating your own applications.
Simple I/O
Use brain states (like relaxation) to control the Raspberry Pi's GPIO pins, lighting an LED or driving a small robot.
Neurofeedback
Create applications that provide real-time audio or visual feedback on brain activity to train focus or relaxation.
Motor Imagery
Train a machine learning model to recognize the neural signals of imagined movements (e.g., left vs. right hand) to control a cursor.
Advanced DSP
Dive deeper into digital signal processing to filter noise and extract features like alpha, beta, and gamma waves from the raw EEG signal.
Don't forget to join the OpenBCI Community Forum to share your progress and get help.