Preprint
Article

This version is not peer-reviewed.

PiEEG Server: An Open-Source Real-Time EEG Streaming Platform for AI-Driven Brain-Computer Interfaces

Submitted:

29 June 2026

Posted:

02 July 2026

You are already at the latest version

Abstract
We present PiEEG Server, an open-source Python-based streaming platform that bridges low-cost PiEEG electroencephalography (EEG) hardware with modern artificial intelligence (AI) and brain-computer interface (BCI) pipelines. Running on a Raspberry Pi or any Bluetooth-enabled machine, PiEEG Server acquires neural signals at 250/500 Hz from 8- or 16-channel ADS1299-based shields (PiEEG-8, PiEEG-16), a 32-channel serial device (IronBCI-32), and Bluetooth LE headsets (IronBCI). It exposes the stream over a language-agnostic WebSocket API with plain JSON frames. The platform integrates a real-time React dashboard featuring spectral analysis, topographic maps, and an experiences gallery; built-in cognitive-state detectors for focus, relaxation, and ocular blinks; Lab Streaming Layer (LSL) compatibility with OpenViBE, MNE-Python, and BCI2000; webhook automation via IFTTT and Zapier; VRChat OSC for embodied virtual-reality applications; and an optional Rust-based native DSP accelerator (pieeg-core) delivering up to ~1057× speed-up on the Butterworth bandpass hot path. By unifying acquisition, signal processing, visualization, and integration into a single pip-installable package, PiEEG Server dramatically lowers the barrier to entry for EEG-based AI research, neuroadaptive gaming, affective computing, and open neuroscience.
Keywords: 
;  ;  ;  ;  
Subject: 
Engineering  -   Bioengineering

1. Introduction

Electroencephalography remains the most widely accessible non-invasive modality for measuring human brain activity in real time. The sub-millisecond temporal resolution of EEG makes it uniquely suited for event-related potential (ERP) studies, oscillatory band-power analysis, and closed-loop neurofeedback—all of which are essential primitives in modern AI-driven BCI research. Yet despite a rich ecosystem of commercial headsets, the gap between raw hardware and production-ready AI pipelines remains wide: proprietary SDKs impose platform lock-in, data formats vary, and streaming middleware is either unavailable or expensive.
PiEEG shields address the hardware cost barrier by combining a Texas Instruments ADS1299 analog front-end with the ubiquitous Raspberry Pi single-board computer. The ADS1299 is a purpose-built, 24-bit, simultaneous-sampling ADC used in many clinical EEG amplifiers [1]. The PiEEG-16 variant chains two such chips for 16 channels; the IronBCI-32 extends coverage to 32 channels over a serial interface; and the IronBCI wireless headsets provide 8-channel acquisition over Bluetooth Low Energy, enabling completely untethered recording (Figure 1).
PiEEG Server is the software counterpart of this hardware family. It transforms PiEEG devices into a turnkey EEG streaming node—and, with the --mock flag, allows any developer to build and test AI EEG applications without any physical hardware at all. This paper describes the architecture, capabilities, and AI integration opportunities of PiEEG Server, and argues that its combination of zero-config streaming, built-in signal processing, broad ecosystem compatibility, and open licensing makes it the optimal middleware layer for EEG-based AI research and development in 2026.

2. Supported Hardware

PiEEG Server natively supports PiEEG devices [2], each leveraging the ADS1299 analog front-end (Table 1). All devices deliver data at 250/500 Hz—the standard clinical EEG acquisition rate that satisfies the Nyquist criterion for all five canonical EEG bands (Delta 0.5–4 Hz, Theta 4–8 Hz, Alpha 8–13 Hz, Beta 13–30 Hz, Gamma 30–100 Hz). The 24-bit ADC resolution translates to sub-microvolt sensitivity, sufficient for detecting single-trial ERPs and cortical oscillations.

3. System Architecture

PiEEG Server is structured as a layered publish-subscribe pipeline implemented in Python 3.10+ with asyncio. The overall data flow moves from hardware through signal conditioning into a fan-out distribution layer that feeds multiple concurrent subscribers, as described in the subsections below.
  • Acquisition Layer
The hardware.py module initialises the SPI bus and configures the ADS1299 registers; ironbci.py performs BLE scanning, GATT notification subscription, and EEG packet parsing for wireless devices. Both converge on acquisition.py, which runs a background thread at 250 Hz, reads raw 24-bit ADC codes, converts them to microvolts (µV), and publishes each sample to an internal pub/sub queue.
  • b. Signal Processing Layer
Two signal conditioning stages operate on every sample before downstream consumers receive it:
  • Spike rejection (Special developed Filter): A two-layer spike rejection approach combining a hardware delta-threshold filter (for SPI glitches) with a per-channel Hampel median-absolute-deviation (MAD) filter applicable to all device types. The Hampel filter is configurable at runtime via WebSocket (window size, n_sigma).
  • Butterworth bandpass: A cascaded second-order section (SOS) IIR Butterworth bandpass filter implemented via scipy, with per-channel state memory and configurable cut-off frequencies (default 1–40 Hz). The optional pieeg-core Rust accelerator raises throughput of this hot path from ~992 samples/s to over 1,000,000 samples/s—a ~1057× speedup enabling server-side filtering on 16-channel rigs.
c.
Distribution Layer
Processed samples are broadcast simultaneously to five independent subscriber modules via asyncio queues:
  • server.py — WebSocket broadcast on ws://0.0.0.0:1616
  • recorder.py — Timestamped CSV writer with optional duration limit and session annotations
  • monitor.py — Rich terminal TUI with per-channel sparklines and µV readout
  • osc_vrchat.py — VRChat OSC bridge over UDP
  • lsl.py — Lab Streaming Layer outlet (float32, 250 Hz)
d.
Dashboard Layer
A React 19 / Vite 6 single-page application served on port 1617 provides browser-based interaction. Figure 2 shows the main dashboard view featuring 16-channel live waveforms, real-time FFT power spectrum with band annotations, topographic scalp map, and a live filter-response curve. The dashboard also provides an ADS1299 register editor, webhook rule management, recording controls, and a self-update mechanism.
Figure 3 illustrates the extended analysis view including the time-frequency spectrogram, per-channel signal statistics, and the Mental State panel displaying real-time focus and relaxation scores derived from the built-in cognitive-state detectors.

4. Websocket API and Data Format

The WebSocket interface is the primary integration point for AI applications. It requires no SDK—any language with a WebSocket library can connect to ws://<host>:1616 and receive plain UTF-8 JSON frames.
  • EEG Frame
Each sample is broadcast as a compact JSON object at 250 Hz:
{“t”: 1711234567.123, “n”: 42, “channels”: [12.34, -5.67, 8.90, ...]}
where t is a Unix timestamp (seconds), n is a monotonic sample counter for gap detection, and channels is an array of floating-point values in µV (8, 16, or 32 elements depending on device).
  • b. Commands
Clients send JSON commands to configure the server in real time. Key commands include:
  • set_filter (enable/disable and tune the bandpass filter)
  • start_record
  • stop_record, lsl_start
  • lsl_stop, osc_start
  • osc_configure, webhook_create
  • webhook_update
  • webhook_delete
  • hampel_config, reg_write (ADS1299 register programming),
  • noise_test.
All commands return acknowledgement messages with the updated server state.
  • c. Authentication
When launched with --auth, the server issues a 6-digit code for session-based authentication. WebSocket connections require a short-lived HMAC-validated token obtained via a REST endpoint, protecting the data stream from unauthorised access on shared networks. Rate limiting and HttpOnly cookies are applied automatically.

5. AI and BCI Capabilities

PiEEG Server is purpose-built to serve as the data acquisition front-end for AI and BCI applications. This section enumerates the capabilities that make it particularly well-suited for this role.
  • Real-Time Cognitive State Detectors
The browser-side React SDK ships four production-ready EEG processing hooks operating on ref-based state to avoid React re-renders, enabling high-frequency polling in animation loops (Table 2). All four detectors include calibration support, configurable update rates, and exponential smoothing, integrating directly into real-time game loops, Three.js scenes, and WebXR experiences.
  • b. Single-Channel Deep Inspection
For debugging and per-electrode validation, the dashboard provides a dedicated single-channel analysis panel (Figure 4). The panel displays a 256-point Hanning-windowed FFT power spectrum, a relative band-power distribution bar chart, an amplitude histogram, and a real-time signal metrics table (RMS, peak-to-peak, mean, zero-crossing rate) alongside the raw time-domain waveform.
  • c. Experiences Gallery and Neurofeedback Applications
PiEEG Server ships an experiences gallery—a curated set of interactive BCI demonstrations accessible directly from the dashboard (Figure 5). Each experience is a self-contained neurofeedback or BCI application built on the detector hooks described above. The gallery spans VR/3D visualisation, gaze estimation, neural sonification, focus-driven games, and webhook-powered automation.
  • d. Lab Streaming Layer Integration
LSL has become the de facto standard for synchronised multi-modal data acquisition in neuroscience and BCI research. PiEEG Server exposes a native LSL outlet (name: PiEEG, type: EEG, float32, 250 Hz) discoverable by the full LSL ecosystem: OpenViBE [3], MNE-Python [4], BCI2000, NeuroPype, and LabRecorder. This single integration unlocks the entire scientific EEG toolchain for PiEEG data, including MNE’s extensive preprocessing, source localisation, and machine learning pipelines.
  • e. Jupyter Notebook Integration
For exploratory AI development, PiEEG Server connects directly to Jupyter notebooks via WebSocket. Researchers can stream live EEG data into pandas DataFrames, NumPy arrays, or MNE RawArray objects, apply custom signal processing, train classifiers, and close the loop back to the device—all from a single notebook without any additional driver or SDK installation.
  • f. Webhook Automation and Event-Driven AI
The webhook engine allows researchers and developers to define event rules based on band-power thresholds (e.g., fire when alpha power exceeds 20 µV²/Hz) and route HTTP POST requests to any endpoint with configurable headers, methods, and per-rule cooldowns. Native presets for IFTTT and Zapier mean that EEG events can trigger actions in thousands of connected services—smart home devices, notification systems, cloud AI workflows—without any custom server code.
  • g. VRChat and Extended Reality
The VRChat [5] OSC bridge transmits rolling-normalised band powers as avatar parameters over UDP. This enables direct neural control of avatar expressions, environment shaders, and interactive elements in VRChat worlds, opening a research pathway for embodied BCI in social virtual reality that was previously inaccessible with consumer-grade hardware.
  • h. Mock Mode for Algorithm Development
The --mock flag generates synthetic EEG with realistic alpha rhythm bursts, broadband noise, drift, and ocular blink artefacts. This allows AI researchers to develop, debug, and validate data pipelines, classifiers, and BCI interfaces on any machine without purchasing hardware, then deploy to physical devices with zero code changes.
  • e. Built-In Documentation
PiEEG Server embeds a full copy of its documentation directly within the dashboard interface (Figure 6), enabling offline reference without leaving the application. The documentation panel covers installation, API reference, integration guides, and troubleshooting—reducing the context-switching overhead for researchers working in the field.
Figure 7. Built-in documentation panel accessible directly from the PiEEG Server dashboard, providing offline access to the full API reference, integration guides, and getting-started documentation without requiring an external browser connection.
Figure 7. Built-in documentation panel accessible directly from the PiEEG Server dashboard, providing offline access to the full API reference, integration guides, and getting-started documentation without requiring an external browser connection.
Preprints 220846 g007

6. Signal Processing Performance

A critical design requirement for real-time BCI is that the DSP pipeline must keep pace with acquisition. At 250 Hz with 16 channels, the server must process 4,000 samples per second. Table 3 reports benchmark results for the pure-Python and pieeg-core Rust implementations on a Windows host (5 s @ 250 Hz × 16 ch):
The pure-Python MultichannelFilter throughput of 992 samples/s falls below the 4,000 samples/s real-time requirement for 16-channel server-side filtering. Installation of pieeg-core (pip install ‘pieeg-server[fast]’) resolves this transparently via a Rust extension wheel with no configuration changes required. The server auto-detects the active engine at startup and reports it in the WebSocket connected message and pieeg-server doctor output. For 8-channel rigs or deployments where server-side filtering is disabled, the pure-Python implementation is fully sufficient.

7. Research and Development Workflow

For users application need just launch pieeg server.
For researchers: typical AI/BCI research workflow with PiEEG Server proceeds in five stages:
Step 1 — Install and launch:
           Preprints 220846 i001
Step 2 — Stream to Jupyter for exploratory analysis:
           Preprints 220846 i002
Step 3 — Label and record training data:
Use the dashboard or CLI to start timestamped CSV recordings with session annotation markers, then load them directly into MNE or scikit-learn for feature extraction and classifier training.
Step 4 — Close the loop:
Trigger webhooks or OSC messages based on classifier predictions, driving external actuators, applications, or virtual environments in real time.
Step 5 — Collaborate and archive:
Export LSL streams for multi-site recordings synchronised with stimuli, eyetracking, EMG, or other physiological channels via LabRecorder, producing interoperable XDF archives.

8. Security and Deployment Considerations

For laboratory deployments on isolated networks, the default unauthenticated mode is sufficient. For public-facing or shared-network deployments, the --auth flag enables session-based authentication with a 6-digit code, HMAC timing-safe token verification, rate limiting, and HttpOnly cookies.
For cloud-hosted mock-mode demonstrations, a Dockerfile and Fly.io configuration are included in the repository, enabling zero-infrastructure live demos accessible from any browser. The platform includes a self-diagnostic command (pieeg-server doctor) that checks Raspberry Pi model compatibility, SPI and GPIO availability, port conflicts, dependency versions, and systemd service status—reducing deployment friction for non-expert users.
A systemd service unit is generated automatically during installation, enabling pieeg-server to start at boot and be managed with standard systemctl commands, making it suitable for always-on laboratory recording nodes. The zero-dependency GPIO implementation uses direct Linux chardev v1 ioctl calls—a stable ABI since Linux 4.8—eliminating fragile third-party GPIO library dependencies.

9. Discussion

The democratisation of EEG hardware through devices like PiEEG and IronBCI creates a significant opportunity for AI-driven neuroscience outside well-funded laboratory settings. However, hardware accessibility alone is insufficient; researchers and developers also need accessible, well-documented software middleware that handles the full stack from acquisition to AI integration.
PiEEG Server addresses this gap by providing a production-ready platform that scales from rapid prototyping (mock mode, Jupyter integration) to production BCI deployments (systemd service, authentication, LSL). The optional pieeg-core Rust accelerator ensures that computational constraints do not become a bottleneck even on resource-constrained single-board computers.
The webhook and IFTTT/Zapier integrations enable a new class of neuroadaptive applications that require no custom server infrastructure. A developer can define an alpha-band relaxation threshold rule and trigger a smart home scene change, a Spotify playlist switch, or a Slack notification entirely from the dashboard—in minutes. The experiences gallery (Figure 5) demonstrates the breadth of application domains already accessible with the current platform, from embodied VR control to adaptive podcast playback.
The VRChat OSC bridge represents a particularly novel contribution: it opens a direct pathway from sub-
$100 EEG hardware to social virtual reality, enabling research on embodied neural interfaces at a scale and cost previously inaccessible to the research community.
Future development directions include multi-device synchronised acquisition, on-device model inference via TensorFlow Lite or ONNX Runtime, adaptive artefact rejection using independent component analysis (ICA), and deeper integration with cloud AI platforms for real-time neural decoding at scale.

10. Conclusions

PiEEG Server is a comprehensive, open-source EEG streaming platform that addresses the full pipeline from ADS1299-based hardware acquisition to AI and BCI application integration. Its language-agnostic WebSocket API with plain JSON frames enables connection from Python, JavaScript, Julia, MATLAB, or any other language in a few lines of code. Its built-in cognitive state detectors, single-channel deep inspection, experiences gallery, LSL compatibility, webhook automation, VRChat OSC bridge, embedded documentation, and native Rust DSP accelerator collectively make it the most feature-complete open-source EEG middleware available for the PiEEG hardware family.
By lowering the barrier to entry for EEG-based AI research—through zero-config streaming, mock-mode hardware simulation, pip-based installation, and extensive embedded documentation—PiEEG Server enables researchers, students, makers, and entrepreneurs to focus on neuroscience and AI innovation rather than infrastructure engineering.
Contributions, issue reports, and feature requests are welcomed at https://github.com/pieeg-club/PiEEG-server.

References

  1. Texas Instruments. ADS1299-x low-noise, 4-, 6-, 8-channel, 24-bit, analog-to-digital converter for EEG and biopotential measurements (Rev. C) [Datasheet]. 2017. Available online: https://www.ti.com/lit/gpn/ADS1299.
  2. PiEEG. PiEEG: Open-source Raspberry Pi shield for biosignals. n.d. Available online: https://pieeg.com/.
  3. Renard, Y.; Lotte, F.; Gibert, G.; Congedo, M.; Maby, E.; Delannoy, V.; Arrouët, B.; Lécuyer, A. OpenViBE: An open-source software platform to design, test, and use brain–computer interfaces in real and virtual environments. Presence Teleoperators Virtual Environ. 2010, 19(1), 35–53. [Google Scholar] [CrossRef]
  4. Gramfort, A.; Luessi, M.; Larson, E.; Engemann, D. A.; Strohmeier, D.; Brodbeck, C.; Goj, R.; Jas, M.; Brooks, T.; Parkkonen, L.; Hämäläinen, M. S. MEG and EEG data analysis with MNE-Python. Front. Neurosci. 2013, 7(267), 1–13. [Google Scholar] [CrossRef] [PubMed]
  5. VRChat Inc. VRChat (Version 2026.1.2). [Social virtual reality software]. 2026. Available online: https://vrchat.com/.
Figure 1. Supported PiEEG hardware family. Left: IronBCI-32 (32-channel, serial interface); ironbci (8-channel, Bluetooth LE); Right: PiEEG-16 HAT shield (16-channel, dual ADS1299, SPI).
Figure 1. Supported PiEEG hardware family. Left: IronBCI-32 (32-channel, serial interface); ironbci (8-channel, Bluetooth LE); Right: PiEEG-16 HAT shield (16-channel, dual ADS1299, SPI).
Preprints 220846 g001
Figure 2. PiEEG Server main dashboard showing 16-channel live EEG waveforms (top), real-time FFT power spectrum with band annotations (lower left), topographic alpha-band scalp map (lower right), and Butterworth filter response curve. Dominant frequency: 9.8 Hz (alpha band).
Figure 2. PiEEG Server main dashboard showing 16-channel live EEG waveforms (top), real-time FFT power spectrum with band annotations (lower left), topographic alpha-band scalp map (lower right), and Butterworth filter response curve. Dominant frequency: 9.8 Hz (alpha band).
Preprints 220846 g002
Figure 3. Extended dashboard view showing the time-frequency spectrogram (bottom left), per-channel signal statistics table with RMS, peak-to-peak, skewness, and kurtosis (centre), and the Mental State panel with live Focus (12) and Relax (56) indices (right).
Figure 3. Extended dashboard view showing the time-frequency spectrogram (bottom left), per-channel signal statistics table with RMS, peak-to-peak, skewness, and kurtosis (centre), and the Mental State panel with live Focus (12) and Relax (56) indices (right).
Preprints 220846 g003
Figure 4. Single-channel deep-inspection panel for Channel 10. Displays time-domain waveform (left), 256-pt FFT power spectrum (top right), relative band-power distribution showing 82.5% alpha dominance (centre right), amplitude histogram (bottom right), and signal metrics table.
Figure 4. Single-channel deep-inspection panel for Channel 10. Displays time-domain waveform (left), 256-pt FFT power spectrum (top right), relative band-power distribution showing 82.5% alpha dominance (centre right), amplitude histogram (bottom right), and signal metrics table.
Preprints 220846 g004
Figure 5. The PiEEG Server experiences gallery, showing nine ready-to-run BCI applications including Neural Wave Space (immersive 3D EEG visualisation with VR support), Blink Browser (eye-blink-driven web scrolling), Neural Sonification (brainwave-to-music mapping), VRChat OSC Bridge, Spoon Bend (focus-driven virtual telekinesis), Webhook Wizard, Eye Track (EOG gaze estimation), Northern Lights (VR/audio aurora), and MindCast (adaptive podcast playback) – up, One of the mini games for practicing focus - bottom.
Figure 5. The PiEEG Server experiences gallery, showing nine ready-to-run BCI applications including Neural Wave Space (immersive 3D EEG visualisation with VR support), Blink Browser (eye-blink-driven web scrolling), Neural Sonification (brainwave-to-music mapping), VRChat OSC Bridge, Spoon Bend (focus-driven virtual telekinesis), Webhook Wizard, Eye Track (EOG gaze estimation), Northern Lights (VR/audio aurora), and MindCast (adaptive podcast playback) – up, One of the mini games for practicing focus - bottom.
Preprints 220846 g005
Figure 6. Measuring EEG data and monitoring them in Virtual reality.
Figure 6. Measuring EEG data and monitoring them in Virtual reality.
Preprints 220846 g006
Table 1. Supported device summary.
Table 1. Supported device summary.
Device Channels Interface Form Factor
PiEEG-8 8 SPI (Raspberry Pi) HAT Shield
PiEEG-16 16 SPI (dual ADS1299) HAT Shield
IronBCI-32 32 Serial Standalone Board
IronBCI 8 Bluetooth LE (GATT) Wireless Headset
Table 2. Built-in cognitive-state detector hooks.
Table 2. Built-in cognitive-state detector hooks.
Hook Algorithm Output
useBandPowers Single FFT, averaged spectral bands Absolute & relative power, dominant frequency
useFocus (Beta + Gamma) / (Alpha + Theta + Delta) cortical engagement index focus: 0–1, calibrated flag
useRelax Alpha-dominance + theta-beta ratio composite relaxation: 0–1, alphaRelative, thetaBetaRatio
useBlink Amplitude-threshold state machine on Fp1/Fp2 blinked, count, amplitude, lastBlinkTime
Table 3. DSP benchmark: pure-Python vs. pieeg-core Rust accelerator.
Table 3. DSP benchmark: pure-Python vs. pieeg-core Rust accelerator.
DSP Hot Path Python (samples/s) pieeg-core (samples/s) Speedup
MultichannelFilter (1–40 Hz bandpass) 992 1,048,658 ~1057×
HampelFilter (spike rejection) 24,619 358,361 ~15×
decode_channels (24-bit SPI → µV) 121,352 1,134,301 ~9×
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.
Copyright: This open access article is published under a Creative Commons CC BY 4.0 license, which permit the free download, distribution, and reuse, provided that the author and preprint are cited in any reuse.
Prerpints.org logo

Preprints.org is a free preprint server supported by MDPI in Basel, Switzerland.

Subscribe

© 2026 MDPI (Basel, Switzerland) unless otherwise stated

Accessibility

Disclaimer

Terms of Use

Privacy Policy

Privacy Settings