Story
Sleep is a critical component of human health. Poor sleep quality, often due to sleep disorders like snoring and sleep apnea, can negatively impact daily life and long-term well-being. Traditional sleep studies are expensive, invasive, and require clinical settings.
SnoreSense aims to provide an affordable, portable, and AI-powered solution to monitor snoring activity, analyze sleep quality, and provide actionable insights to users.
Components Used
Hardware
-
Seeed Studio MG24 Sense
Software & Tools
-
Simplicity Studio IDE (for firmware development)
- Edge Impulse Studio (for model Training)
-
TensorFlow Lite Micro (for running AI model inference on MCU)
-
C/C++ programming
-
Custom Snore Detection ML Model (trained on snore vs. non-snore audio samples)
-
Android/iOS App (future expansion) for displaying sleep score & history
Implementation Steps
Step 1: Dataset Preparation
-
The dataset for snoring vs. non-snoring audio can be sourced from Kaggle (public audio datasets).
-
Alternatively, you can record your own dataset using a microphone in different conditions (quiet background, fan noise, conversations, actual snores).
-
Make sure you label the dataset into two classes: Snore and Non-Snore.
Step 2: Model Training using Edge Impulse Studio
-
Go to Edge Impulse Studio.
-
Create a new project (e.g., SnoreSense AI).
-
Select Audio Classification project type.
-
Upload your datasets (Snore / Non-Snore audio samples).
-
Use MFCC (Mel Frequency Cepstral Coefficients) feature extraction for audio preprocessing.
-
Add a Neural Network (Keras) block for classification.
-
Train the model and validate accuracy.
-
Once trained, go to Deployment → TensorFlow Lite for Microcontrollers.
-
Download the generated
.tflite
model file from Dashboard.
Step 3: Converting Model in Simplicity Studio
-
Open Simplicity Studio IDE.
-
Create a new empty C++ project for your target device (e.g., EFR32xG24).
-
Copy the
.tflite
file into the config folder of your project. -
Enable AI/ML SDK in the project settings.
-
Go to Project → Properties → SDKs and enable AI/ML SDK.
-
-
Build the project.
-
The
.tflite
file will be automatically converted into.c
and.h
array files, which will appear inside the autogen folder of your project.
You check the other information on the silicon lab website
Step 4: System Description
-
Data Flow:
Microphone → MCU (Noise Filtering + AI Inference) → Snore Events → Sleep Score → Bluetooth → Smartphone App -
Key Algorithms:
-
Adaptive silence threshold
-
RMS-based amplitude filtering
-
TensorFlow Lite Micro inference
-
Snore probability margin filtering
-
Sleep score calculation
-
-
User Experience:
-
Place SnoreSense device near bed.
-
Device listens and detects snores overnight.
-
Sleep score & snore insights are available on smartphone app.
-
Step 5: Arduino IDE Integration
-
Install the Silicon Labs Arduino Core and required libraries:
-
Add this in Arduino IDE Preferences: https://siliconlabs.github.io/arduino/package_arduinosilabs_index.json
-
- Install the Silicon Labs board files from board manager.
-
Create a new Arduino sketch.
-
Include the necessary headers:
-
Copy the
.c
and.h
files (generated from Simplicity Studio) into your Arduino project folder. -
In your Arduino code, configure the microphone and inference logic (as in your final working snore detection sketch). Check the steps given on the Github page.
-
Sleep Quality Monitoring
-
-
Count snore events per hour.
-
Track intensity, frequency, and duration of snoring.
-
Compute Sleep Score using formula:
-
Classify sleep into categories: Excellent, Good, Fair, Poor.
-
You can find the full working code on this github link.
-
Compile and upload the sketch to your development board.
Step 5: Testing and Verification
-
Place the device near the bed while sleeping.
-
Open Serial Monitor to view:
-
Snore detected / No snore detected
-
Sleep score update
-
-
Verify that the inference results match real-world audio input.
Bluetooth Communication (Future Integration)
-
-
Transmit snore events, sleep score, and timeline to smartphone.
-
Display results in a mobile app with daily/weekly/monthly trend.
-
Results
- Successfully detects snores in real-time.
- Adaptive threshold reduces false positives from fan noise and speech.
- System computes sleep score based on snore patterns.
- Basic results displayed via Serial Monitor, with planned mobile integration.
Uses / Applications
- Personal sleep monitoring at home.
- Early detection of potential sleep apnea or breathing disorders.
- Non-invasive sleep quality assessment.
- Integration with smart home/IoT devices for health tracking.
Future Expansion
- Android/iOS Mobile App for:
- Sleep score dashboard
- Snore pattern visualization
- Long-term trends & cloud sync
- Integration with Wearables (heart rate, SpO2) for comprehensive sleep monitoring.
- Machine Learning Improvements – refine model with more diverse datasets to distinguish snore vs. speech more accurately.
- Alerts & Smart Actions – vibrate a smart band or adjust smart home devices (e.g., increase room airflow) when excessive snoring is detected.
Conclusion
SnoreSense demonstrates how AI at the edge can enable affordable and effective sleep monitoring. By combining low-power hardware, real-time snore detection, and AI inference, it provides valuable insights into sleep quality. With future Bluetooth app integration, SnoreSense has the potential to become a powerful personal health companion for millions of users struggling with sleep disorders.