Building a Brain-Computer Interface From Scratch
A hardware hacker built an open source, eight-channel brain-computer interface headset for under $350 using an ESP32 and a custom PCB.
Brain-computer interfaces may sound like the kind of hardware that requires a university lab and a massive budget to build, but Carlos Lorenzo-Zúñiga Marí managed to build one for less than $350. His custom eight-channel EEG headset combines a purpose-built biopotential acquisition board, an ESP32, dry electrodes, motion sensing, and 3D-printed hardware into a system capable of measuring electrical signals from the brain.
That is a difficult thing to do because EEG signals are typically only around 10 to 100 microvolts by the time they reach the scalp. Electrical noise from mains wiring, chargers, lights, and other electronics can easily overwhelm them, as can the much stronger electrical signals produced by muscles.
Carlos designed the acquisition board around an ADS1299, an eight-channel, 24-bit ADC made for measuring biopotential signals such as EEG. The circuit measures differences between electrodes rather than voltages relative to ground, helping reject noise appearing on both inputs. An active bias-drive circuit connected through ear-clip electrodes further reduces common-mode interference.
An ESP32 microcontroller shares the four-layer PCB with the analog front end, providing processing and Wi-Fi connectivity. Keeping its high-frequency digital and RF signals away from the extremely sensitive EEG circuitry required careful PCB layout, including a dedicated internal ground plane and separation between analog and digital sections.
There is also a six-axis IMU for identifying movement that could corrupt EEG measurements. A lightweight decision tree model monitors its data and generates hardware interrupts when it recognizes head movement, allowing affected portions of the EEG stream to be flagged as motion artifacts.
The headset is based partly on OpenBCI's open source headwear design, with electrodes positioned according to the International 10-20 system. Spring-loaded dry electrodes eliminate conductive gel while helping maintain pressure against the scalp and through hair. Medical touchproof connectors carry the signals to a custom breakout PCB, which then connects to the acquisition board.
Carlos also built the software needed to make the hardware useful. With no suitable ADS1299 driver available, he wrote his own implementation using SPI, DMA, and double buffering. That lets samples move into memory without tying up the ESP32's CPU during continuous acquisition.
For safety purposes, the headset runs from a LiPo battery instead of mains power, and a galvanic isolator provides additional protection while connected to development equipment. When debugging uncovered a problem where USB power back-fed the 3.3 V rail, Carlos avoided another PCB revision by making a USB adapter that disconnects the 5 V line while leaving the data lines intact.
Testing the finished board with its ADC inputs shorted produced a noise floor around one microvolt, close to the ADS1299's expected performance. The system then successfully recorded EMG and ECG signals before moving on to EEG, where it captured recognizable alpha-wave activity.
Carlos' DIY hardware isn't going to perform as well as pricey commercial solutions. But for the home hobbyist, his system is pretty hard to beat.
Please log in or sign up to comment.