EntrainOS: Custom Real-Time Operating System for the Mesh Network
ENTRAINOS — CUSTOM OPERATING SYSTEM
A real-time operating system purpose-built for collective brainwave synchronization across a decentralized mesh.
ARCHITECTURE: Two-Layer OS
LAYER 1: NODE OS (runs on each ESP32 headband) Based on FreeRTOS — proven RTOS with <1μs task switching
Four real-time tasks:
TASK 1: EEG_ACQUIRE (Priority: HIGHEST)
- SPI read from ADS1299 at 250Hz
- 4-channel data into ring buffer
- Hardware interrupt driven — never misses a sample
- Artifact rejection (blink/jaw clench detection)
- Execution time: <100 μs per sample
TASK 2: SIGNAL_PROCESS (Priority: HIGH)
- Sliding-window FFT: 256-point, every 100ms
- Band power extraction:
Beta (13-30Hz), Gamma (30-100Hz)
- Phase extraction at dominant frequency
- Coherence calculation vs. network reference
- Execution time: ~2ms per window
TASK 3: ENTRAIN_CONTROL (Priority: MEDIUM)
- Receives target frequency from network
- Generates entrainment waveform:
PEMF: square pulse at target freq
- Adaptive intensity based on EEG response:
If coherence falling → increase gently
If user discomfort (high beta) → reduce
- Never exceeds safety limits
- Execution time: <500 μs per update
TASK 4: MESH_COMM (Priority: MEDIUM)
- BLE mesh: broadcast phase packet every 50ms
- WiFi: send summary to relay every 500ms
- Receive group phase from mesh/relay
- Execute Kuramoto coupling algorithm
- Update target frequency for ENTRAIN_CONTROL
- Execution time: ~1ms per cycle
Memory usage: ~180 KB of 512 KB SRAM CPU usage: ~35% of dual-core capacity Leaves headroom for OTA updates and diagnostics.
LAYER 2: RELAY OS (runs on relay servers)
Based on Alpine Linux (~50 MB image) Custom name: EntrainRelay
Runs on ANY hardware:
- Raspberry Pi 4/5 ($35-80)
- Old laptop / desktop
- Cloud VM ($5/month DigitalOcean)
- Even a smartphone (Termux + Alpine)
Three services:
SERVICE 1: MESH BRIDGE
- Connects local BLE meshes to the internet
- WiFi access point for local nodes
- Aggregates phase data from local nodes
- Computes local group coherence
SERVICE 2: P2P RELAY (libp2p)
- Connects to other relays worldwide
- GossipSub protocol for phase propagation
- Kademlia DHT for peer discovery
- NO central server required
- Any relay can join/leave without disruption
- NAT traversal for home networks
SERVICE 3: ANALYTICS ENGINE
- Real-time coherence dashboard
- Network topology visualization
- Historical sync data (local only, privacy)
- Web UI accessible from any browser
Data sovereignty: ALL brainwave data stays local. Only phase angles and coherence scores cross the wire. Phase angles alone cannot reconstruct thoughts. This is privacy-by-design at the protocol level.
Related claims
No claims cite this entry yet.
More in Engineering
Entrain Network: Scientific Foundation and Real-World Use Cases
Every component of this system is backed by published, peer-reviewed research. 1. EEG can measure brainwave phase in real-time → Proven:...
Entrain Network: Complete Software Stack — Firmware, Relay OS, Companion App
FIRMWARE: EntrainOS Node (ESP32-S3, FreeRTOS) Language: C/C++ (ESP-IDF framework) RTOS: FreeRTOS (bundled with ESP-IDF) Build: CMake +...
Entrain Network: Three-Tier Decentralized Architecture — Local, Regional, Global
The network scales from a pair of headbands in a room to millions of nodes worldwide, using three nested communication tiers. No tier...
The Kuramoto Protocol: Mathematical Foundation for Collective Brain Synchronization
The mathematical heart of the Entrain Network is the Kuramoto model — a proven framework for describing how coupled oscillators...