Inspiration

Tuna, one of our Team members, is someone who suffers from chronic bruxism, a condition of continuous teeth clenching during the day and night, that causes extreme jaw pain, and sleep inconveniences. This firsthand experience of a real problem formed the basis of our project SleepSense, to solve this broader pain point of lack of good sleep, which is especially common amongst people from all groups these days. We found the sentiment of lack of good sleep was repeatedly echoed throughout the hackathon, be it amongst the engineers, or the founder and the VCs, all of them emphasized the less sleep all these people get. So we were driven by this mission to build a project that caters to these amazing people, and make their every hour of sleep count, by helping them have a restful sleep.

What it does

Our project is an end-to-end solution that uses real-time sensing on patients to obtain their vital health parameters, such as cardiac and breathing, along with specific health data, like muscular activity, acquired using our custom-developed device that clips easily onto people's night masks and helps them improve their sleep. The device is not only able to acquire high-frequency data and transmit it securely to the cloud, but it is also of a very small form factor, which is ergonomically convenient for a user to put on during their sleep and monitor any form of abnormalities that disrupt their sleep. This multimodal data is then used by our model, which uses existing clinical data to accurately diagnose the root cause of their sleep disruptions, like bruxism, chronic stress, genetic factors like hormone imbalance, etc. Based on the preliminary diagnosis, our agentic platform can then generate reports about their sleep patterns, acute and chronic conditions, and then recommend specific suggestions about the nearest healthcare specialists relating to the problem, and also provide them with detailed reports of the patient's health data to consult and advise them proper plan of action.

How we built it

Hardware:

We designed a compact clip-on module built around an ESP32 microcontroller and an EMG muscle sensor that attaches to a standard sleep mask. The ESP32 reads raw 12-bit ADC values from the EMG sensor at high frequency, capturing jaw muscle activity in real time. For heart rate, we use an off-the-shelf wearable monitor that communicates over Wi-Fi. The ESP32 handles data capture and streams readings wirelessly to the cloud. We 3D-printed a custom enclosure (designed in CAD) to keep the electronics small and comfortable enough to wear during sleep. We also initially faced hiccups in sourcing the hardware and sensors we needed. While we were limited by our access to hardware, we tried to make the best use of what we had available to design this.

Software:

Data Pipeline: The wearable POSTs heart rate to a Flask server, while the ESP32 writes EMG data to Google Sheets (easiest way to bridge the hardware to our backend). Flask polls both sources, combines them at 10 Hz, and streams the result to the frontend over Server-Sent Events.

Dashboard: A Next.js 14 app connects to that SSE stream and renders live Recharts visualizations, heart rate, jaw activity level, and raw EMG, updating at 5 Hz. NextAuth handles login with Google OAuth or a zero-config demo mode.

Report Engine: reportLogic.ts classifies jaw activity from EMG thresholds, detects clenching events, and checks whether each one was preceded by a heart-rate spike. If yes → arousal-linked (stress response). If no → isolated (habitual bruxism). These feed into a sleep quality score.

AI Chatbot: GPT-4o gets the full sensor dump and event log as context, so it can reason over the actual session data. We gave it two function-calling tools: search_clinics (Google Places API) and confirm_booking, so users can go from data analysis to booking a specialist without leaving the chat.

Challenges we ran into

Hardware:

Getting reliable EMG readings from a sensor mounted on a sleep mask was tricky; small shifts in placement caused big swings in signal quality. We also ran into power and heat issues with the ESP32 running continuous high-frequency ADC reads over Wi-Fi, and had to tune the sampling rate to balance data quality with battery life, latency, and stability.

Software:

Syncing two async data sources: Heart rate arrives via HTTP POST and EMG comes from polling Google Sheets, two completely different timing models. Getting them aligned into a single 10 Hz stream without drift or stale readings took a lot of trial and error with Flask's threading.

SSE connection drops: The browser's EventSource would silently disconnect after a few minutes of inactivity or on network hiccups. We had to add reconnection logic and buffer management on the frontend to avoid gaps in the chart data.

Accomplishments that we're proud of

We had a lot of fun in the process of making this, and we are really proud of all the friends we made along the way.

We were also really happy that we were able to consult real patients through our interactions with other hackers, mentors, judges, and involved parties, like dentists, for understanding the needs of the market space, and we are shocked to realize that this was a far more common issue than we initially thought it to be.

Finally, we built something that is a genuinely hard engineering problem, to acquire critical data, and then leverage agentic AI tools that can use existing and new clinical data, and improve people's sleep, and that's what makes us really proud and happy.

What we learned

Working across hardware and software taught us how messy real-time sensor data really is - what looks clean on a breadboard behaves very differently when someone's actually wearing it. We learned how to stitch together multiple async data sources into a reliable streaming pipeline, and how much SSE simplifies things when you only need one-way data flow. On the AI side, function calling turned out to be the unlock - it's what took our chatbot from "here's some generic advice" to actually finding clinics and booking appointments. Talking to dentists and fellow hackers also opened our eyes to how widespread and underserved sleep disruption problems really are.

What's next for SleepSense

One of the key improvements that we would like to incorporate into SleepSense is adding real-time biofeedback to the users, which can help patients suffering from bruxism, which is one of the major sleep disruptors for many people today. We would like to incorporate other important health parameters using our device and leverage on exisitng unpublished clinical data through partnerships to help both doctors, healthcare specialists, and patients. We would like to possibly explore how this project could be taken beyond the hackathon to build a genuinely impactful product.

Built With

Share this project:

Updates