What is it

Somnia is a mobile-focused web app that uses a highly effective, yet obscure technique called cardiac coherence to help its users fall asleep faster.

It works by projecting onto the ceiling a soft blue circle in a sci-fi-esque manner turning the phone’s display into a projector, that gently expands and contracts, prompting the user to follow it and synchronize their breathing with it. The frequency of breathing slowly decreases from 11RPM to 6RPM at the end of the 8-minute session. Then the app automatically switches off, turning off fullscreen, wake lock and the binaural sleep-inducing music in addition to the projector.

Inspiration

With my grandfather suffering from chronic insomnia, taking him 1-2 hours to fall asleep, if at all, I was struck to research more on sleep, and more specifically, the causes for the lack of it. In my research, I came across an article describing how US military pilots were trained to fall asleep in less than 2 minutes. How?! The answer was cardiac coherence, a meditation-esque technique to control and bring down one's rate of breathing until he/she falls asleep.

How I built it

I used Javascript to build the site which is now both converted to apple and android applications. I have published the app on the android Play Store, and I am awaiting approval for my Apple Developer account (As a minor I had to use my mom's apple ID, which is very frustrating)

Challenges I ran into

It was quite challenging implementing the slowly increasing duration of the breath cycle on javascript, and above that to make it modular to work with 2 different durations (8-minute and 20-minute sessions), and I spent a couple of days stuck on that part.

Accomplishments that I am proud of

The aforementioned algorithm gradually increases the duration of a breath cycle from 5.45 seconds (6RPM) to 10 seconds (11RPM) a cycle. I used programming techniques completely new to me, based on adaptations from various blog articles and Stackoverflow pages.

After installing this app on my grandfather's phone, I am proud to say he has been sleeping much faster now, fulfilling my initial goal of helping with his chronic insomnia

What I learned

My first project with a heavy focus on javascript (I have only built dynamic Flask/Django based web-apps before), has given me insights into the clever features of the language, ranging from promises to async functions.

What's next for Somnia

I intend to user test with more people (I have currently tested with my family members), and improve the functionality of the app. If the app gains enough traction, I will monetise it (with ads on the homepage, or a small monthly subscription fee), and connect the app with Apple Healthkit to gain more user data on sleep to optimize the program.

Share this project:

Updates