Skip to content

Commit 683502b

Browse files
authored
Merge pull request #3 from yelabb/dev
Add PiEEG device support
2 parents 3e1656c + ef04795 commit 683502b

9 files changed

Lines changed: 1135 additions & 14 deletions

File tree

README.md

Lines changed: 88 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ PhantomLoop is one component of the **Phantom Stack**, an integrated ecosystem f
3636
## ✨ Key Features
3737

3838
- **🔌 Universal Stream Architecture** – Connect to any multichannel data source (EEG, spikes, simulated)
39-
- **🧠 10+ Device Support** – OpenBCI, Muse, Emotiv, NeuroSky, Cerelog ESP-EEG, and more
39+
- **🧠 15+ Device Support** – OpenBCI, Muse, Emotiv, NeuroSky, PiEEG, Cerelog ESP-EEG, and more
4040
- **⚡ Real-Time Performance** – 40Hz streaming with <50ms end-to-end latency
4141
- **🤖 AI-Powered Decoders** – TensorFlow.js models with WebGPU/WebGL acceleration
4242
- **📝 Monaco Code Editor** – Write custom decoders with VS Code-quality IntelliSense
@@ -61,11 +61,41 @@ PhantomLoop supports **any multichannel time-series source** through a unified a
6161
| **Emotiv** | Insight | 5 | 128 Hz | BLE |
6262
| **Emotiv** | EPOC X | 14 | 128/256 Hz | BLE |
6363
| **NeuroSky** | MindWave | 1 | 512 Hz | Bluetooth |
64+
| **PiEEG** | PiEEG | 8 | 250-16000 Hz | SPI (Raspberry Pi) |
65+
| **PiEEG** | PiEEG-16 | 16 | 250-8000 Hz | SPI (Raspberry Pi) |
66+
| **PiEEG** | IronBCI | 8 | 250 Hz | BLE/WiFi |
67+
| **PiEEG** | IronBCI-32 | 32 | 250 Hz | WiFi |
68+
| **PiEEG** | JNEEG | 8 | 250-2000 Hz | SPI (Jetson Nano) |
69+
| **PiEEG** | ardEEG | 8 | 250 Hz | Serial (Arduino) |
70+
| **PiEEG** | MicroBCI | 8 | 250 Hz | BLE (STM32) |
6471
| **Cerelog** | ESP-EEG | 8 | 250 Hz | WiFi (TCP) |
6572
| **Brainflow** | Synthetic | 8 | 250 Hz | Virtual |
6673

6774
> ⚠️ **Note:** Browsers cannot connect directly to TCP/Serial/BLE. Hardware devices require a WebSocket bridge (Python scripts included).
6875
76+
### 🥧 PiEEG Integration
77+
78+
[PiEEG](https://pieeg.com) is a low-cost, open-source EEG shield for Raspberry Pi using the ADS1299 ADC. PhantomLoop provides full support for the PiEEG device family:
79+
80+
| Device | Channels | Use Case | Link |
81+
|--------|----------|----------|------|
82+
| **PiEEG** | 8 | Raspberry Pi 3/4/5, research & learning | [pieeg.com/pieeg](https://pieeg.com/pieeg/) |
83+
| **PiEEG-16** | 16 | Extended coverage, dual ADS1299 | [pieeg.com/pieeg-16](https://pieeg.com/pieeg-16/) |
84+
| **IronBCI** | 8 | Wearable, BLE, mobile SDK | [pieeg.com/ironbci](https://pieeg.com/ironbci/) |
85+
| **IronBCI-32** | 32 | High-density research | [pieeg.com/ironbci-32](https://pieeg.com/ironbci-32/) |
86+
| **JNEEG** | 8 | Jetson Nano, GPU-accelerated DL | [pieeg.com/jneeg](https://pieeg.com/jneeg/) |
87+
| **ardEEG** | 8 | Arduino shield, beginner-friendly | [pieeg.com/ardeeg](https://pieeg.com/ardeeg/) |
88+
| **MicroBCI** | 8 | STM32 NUCLEO-WB55, ultra-compact | [pieeg.com/microbci](https://pieeg.com/microbci/) |
89+
90+
**Key Specs:**
91+
- 24-bit resolution (ADS1299)
92+
- Programmable gain: 1, 2, 4, 6, 8, 12, 24
93+
- Configurable sample rates: 250-16000 SPS
94+
- Supports EEG, EMG, and ECG signals
95+
- BrainFlow compatible (board ID: 46)
96+
97+
⚠️ **Safety:** PiEEG must be powered by battery only (5V). Never connect to mains power!
98+
6999
---
70100

71101
PhantomLoop streams neural data from PhantomLink (MC_Maze dataset, 142 channels @ 40Hz) and visualizes **ground truth cursor movements** alongside **your decoder's predictions**. Built for BCI researchers who need to rapidly prototype, test, and compare decoding algorithms.
@@ -98,7 +128,19 @@ npm run dev
98128
# wss://phantomlink.fly.dev
99129
```
100130

101-
**Option 2: Hardware EEG (e.g., Cerelog ESP-EEG)**
131+
**Option 2: PiEEG (Raspberry Pi)**
132+
```bash
133+
# 1. Connect PiEEG shield to Raspberry Pi GPIO
134+
# 2. Enable SPI: sudo raspi-config → Interface Options → SPI
135+
# 3. Run the WebSocket bridge on the Pi
136+
pip install websockets spidev RPi.GPIO numpy
137+
python scripts/pieeg_ws_bridge.py --rate 250 --gain 24
138+
139+
# 4. In PhantomLoop, connect to ws://<raspberry-pi-ip>:8766
140+
# 5. Select "PiEEG" in the device selector
141+
```
142+
143+
**Option 3: Cerelog ESP-EEG (WiFi)**
102144
```bash
103145
# 1. Connect to ESP-EEG WiFi: SSID: CERELOG_EEG, Password: cerelog123
104146
# 2. Run the WebSocket bridge
@@ -110,7 +152,50 @@ python scripts/cerelog_ws_bridge.py
110152

111153
---
112154

113-
## 🏗 Architecture
155+
## � WebSocket Bridges
156+
157+
Since browsers cannot directly access hardware (SPI, Serial, BLE, TCP), PhantomLoop includes Python bridge scripts that expose devices via WebSocket:
158+
159+
| Script | Device | Port | Mode |
160+
|--------|--------|------|------|
161+
| `pieeg_ws_bridge.py` | PiEEG (Raspberry Pi) | 8766 | SPI / BrainFlow / Simulation |
162+
| `cerelog_ws_bridge.py` | Cerelog ESP-EEG | 8765 | TCP-to-WebSocket |
163+
164+
### PiEEG Bridge
165+
166+
```bash
167+
# Basic usage (on Raspberry Pi)
168+
python scripts/pieeg_ws_bridge.py
169+
170+
# With options
171+
python scripts/pieeg_ws_bridge.py \
172+
--rate 500 \ # Sample rate: 250, 500, 1000, 2000, 4000, 8000, 16000
173+
--gain 24 \ # PGA gain: 1, 2, 4, 6, 8, 12, 24
174+
--channels 16 \ # 8 or 16 (PiEEG-16)
175+
--port 8766 \ # WebSocket port
176+
--brainflow # Use BrainFlow instead of direct SPI
177+
178+
# Development mode (no hardware - generates synthetic alpha waves)
179+
python scripts/pieeg_ws_bridge.py # Auto-detects non-Pi systems
180+
```
181+
182+
**WebSocket Commands:**
183+
```json
184+
{"command": "connect"}
185+
{"command": "disconnect"}
186+
{"command": "set_gain", "gain": 24}
187+
{"command": "set_sample_rate", "rate": 500}
188+
```
189+
190+
### Cerelog Bridge
191+
192+
```bash
193+
python scripts/cerelog_ws_bridge.py --esp-ip 192.168.4.1 --esp-port 1112
194+
```
195+
196+
---
197+
198+
## �🏗 Architecture
114199

115200
PhantomLoop is a single-page React application with modular state management:
116201

package-lock.json

Lines changed: 41 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "frontend",
2+
"name": "phantomloop",
33
"private": true,
44
"version": "0.0.0",
55
"type": "module",
@@ -27,6 +27,7 @@
2727
"@tensorflow/tfjs": "^4.22.0",
2828
"@tensorflow/tfjs-backend-webgl": "^4.22.0",
2929
"@tensorflow/tfjs-backend-webgpu": "^4.22.0",
30+
"@vercel/analytics": "^1.6.1",
3031
"buffer": "^6.0.3",
3132
"framer-motion": "^12.26.2",
3233
"msgpack-lite": "^0.1.26",

0 commit comments

Comments
 (0)