May 8, 2015

LunRise Artificial Sunrise in Action

Finished Product First:

LunRise Artificial Sunrise Alarm Clock

I've been side tracked from my original alarm clock project, LunzPi, and focused on my latest obsession: the LunRise Artificial Sunrise Alarm Clock.

It is a database driven alarm clock that controls a 60 LED strip as well as Bluetooth light bulb.

The bluetooth light bulb idea was started by this Adafruit guide. Using a Bluetooth LE Sniffer, I was able to extract the unique identifier code that was embedded by the manufacturer. This code opens up communication between a device (a raspberry pi) and the bulb. The playbulb's secret code happens to be: **0x001b. **The code 0x001b was the necessary piece missing to write a hex color to the bulb. Using the code on my github page (adapted from Tony Dicola's code in the adafruit tutorial) I was able to get full control of my playbulb.

Since the bulb has essentially 2 lights (one "normal"/florescent and the other is RGB) It also had a interesting format so the bulb knows which light to turn on. Here is a brief explanation:

  • FF000000 --> this would turn on the normal light

  • 00000000 --> this would turn off all light

  • 00FF0000 --> produces a Red color

  • 0000FF00 --> produces a Green color

  • 000000FF --> produces a Blue color


So, this seems like a bit overkill to run a database driven LED Strip, but it was a good opportunity to tie some of my skills together. I've found one of the best way to learn how to do something is using my desire to create something as fuel to learn what I need to accomplish my goals.

This is a first gen Raspberry Pi hosting an LAMP [Linux, Apache, MySQL, PHP/Python] stack (well, it's using lighttp instead of Apache) connected to a 60 LED light strip. It runs very well, considering that the Pi only has 256mb of memory and 700MHz processor (not overclocked at the moment).

I've been captivated by this because of a few reasons:

  1. jQuery Mobile is easy to pick up and quickly produces something that works.

  2. It was a good way to learn AJAX database inserts using PHP.

  3. I'm feeling comfortable enough to build a python script and work reasonably well

The user goes to the IP address of the Pi, adds an alarm of when they would like the LED strip to light up.


Meanwhile, on the Pi, there is a python script querying the database and waiting for the right day and time the user desired to occur.

When it does, the script continues with a predefined LED light show for the desired duration inputted by the user. From there, it waits until the desired duration has finished before looking once again for the next time to run.

Lighting Options:

  • Change the color of the bulb

  • Turn the LED strip on/off


Permanent Proto-Board:


Turning off my PC remotely:

I found out that if the Pi is running a Samba service and so is your windows machine, you can send it a short command to shut down the PC.

This is helpful when you are watching some movie in bed off of your PC running a Plex server and don't want to get up.

This is how I shutdown my PC from across the room

I created a button which sends this command via PHP:

net rpc SHUTDOWN -C "Goodbye from Lunrise Pi" -f -I Computer.IP.address -U Username%Password

Yes, the password is stored in plain text, so this probably isn't very secure. But, since it is all on my local network it will be OK.

Also, I needed edit a file the the registry. How-To Geek provides a good walk-through here.


Windows Shutdown Prompt: "Goodbye from Lunrise Pi"

Work In Progress:

Integrate with Apple Homekit so Siri can control my light.

I have basic light control (on/off) via Siri working.

You can say, "Hey Siri, "make my light red" (and the lights turn red) or "Netflix and Chill" and having the lights dim low and the rainbow LED strip turn on!