A Low-Cost EEG Sleep Monitoring System with YASA-Based Classification and LLM-Assisted Analysis
Keywords:
EEG, sleep monitoring, low-cost, YASA, NeuroNap, signal processing, large language modelAbstract
Electroencephalography provides valuable information on sleep dynamics, but conventional polysomnography systems are still costly and difficult to access. This paper presents the design and evaluation of a low-cost, portable EEG sleep monitoring system priced under sixty dollars, using an ESP32 microcontroller, SD card, and AD8232 with MCP602 operational amplifier for additional signal filtering and amplification as the analog front-end. The device samples and records data at a frequency of 256 hertz to an SD card for offline processing, enabling reproducibility in research and educational settings. Data analysis is performed through NeuroNap, a Gradio-based interface that visualizes EEG waveforms, filtered signals, frequency spectra, and hypnograms, with downloadable graphs for each frequency band. Sleep staging is performed using the Yet Another Spindle Algorithm (YASA) toolbox, which automatically classifies five standard stages: Wake, Non-Rapid Eye Movement (NREM) Stage 1, Stage 2, Stage 3, and Rapid Eye Movement (REM). To improve usability, an integrated large language model with retrieval- augmented generation allows users to query their results and receive explanations of the recorded data and derived sleep statistics for better understanding. The system incorporates simple feedback indicators and initialization controls to support reliable operation, demonstrating feasibility for and research use. Future work will explore multichannel EEG recording, supervised machine learning approaches, extended Wi-Fi or cloud-based functionality, improved electrode stability, and automated motion artifact removal.