Wake Up Gently in the Morning with an IoT Artificial Sunrise

Jan 30, 2016

Waking up in the morning can be tough, especially before the sun rises outside. In the wintertime, it can become increasingly difficult to push aside the warm bed comforter as it gets colder and colder in your house. Also, waking up to a blaring alarm clock in total darkness can put your body in a state of "fight-or-flight", where adrenaline is secreted in great amounts in response to the sudden unexpected sound. #FirstWorldProblems, anyone?

I am therefore faced with three challenges to overcome, in order to wake up feeling more energized, motivated and ready to start the day:

  • It's hard to get out of bed when it's cold outside the comforter
  • A blaring alarm clock is shocking to the body
  • Waking up in total darkness is unnatural and hard

The first two challenges can be overcome quite easily:

  • Turn on the A/C, either before you go to sleep, or program it to turn itself on before you wake up
  • Set a more relaxing alarm clock sound that fades in gradually

However, the third challenge, waking up in total darkness, is a little more difficult to solve. And it is definitely worth solving, because research shows that the healthiest way to wake up is along with the sun rising and the world gradually becoming lighter:

The gradual increase in light intensity perceived through your eyes (even when closed) tells your body the sun is coming up. As a result, the pineal gland reduces the hormone melatonin that makes you sleepy and secretes the hormones cortisol and serotonin into your bloodstream. These play an essential role in waking you up. http://www.hobbr.com/wake-up-light-alarm-clocks/

This alone gave me enough incentive to find a way to create an artificial sunrise to wake me up in the morning.

Challenge accepted.

Building an Artificial Sunrise

In the past few years, the Internet of Things has been gaining popularity and expanding its reach to all sorts of dumb devices, light bulbs included. The most popular smart light bulb seems to be the Philips Hue, but is a little bit expensive for the average consumer. Some manufacturers even sell their own Wake Up Light Clocks. However, there are Chinese knock-offs that work pretty much the same, connecting to your Wi-Fi network in some way and listening for light commands, for much less dough.

One of the cheapest options is the Milight RGBW smart light bulb. It supports all RGB colors along with warm white light. The bulb is dimmable and comes with an official app that lets you seamlessly control it from the comfort of your smartphone. It costs around $10 on AliExpress, and the Wi-Fi box is another $10. Me and my roommate, Ziv, ordered 2 bulbs and the Wi-Fi box, and within a month the package arrived at our local post office.

Milight RGBW

One of the greatest things about this bulb is that it requires no configuration in order to control it -- the Wi-Fi box listens for UDP broadcasts on 255.255.255.255 by default, so there's no need to manually configure a dynamic DHCP-assigned IP address to communicate with it. Also, it screws into the most popular international light bulb socket, which almost every home already has.

Once we received the bulbs, it was all a matter of writing some code that will gradually increase the bulb's brightness before the smartphone's alarm clock sounds, so that we'd wake up to a lighted room.

Sunriser

And so I built Sunriser. It's an Android app that starts emitting these brightness commands 30 minutes before your scheduled alarm, causing your body to release hormones that will help you wake up easily, feeling refreshed and ready to go.

Main

The biggest challenge with this app was to send the right commands to the light bulb. But luckily, all of the commands are documented in some form or another on this page and in various other places on the Internet. It was all a matter of experimentation and reading other people's code to get it working the way we intended.

It's also very configurable -- you can set the time it starts emitting the light commands, how fast the brightness should increment, and how long the light should be left on after 100% brightness.

Settings

We gave it a shot and immediately noticed the difference -- waking up was immediately much easier and we definitely felt an energy boost. One thing's for sure, we'll never go back to waking up in pitch black darkness!

Check out the source code, it's open-source and hosted with love on GitHub.