This time I had the idea of creating a sunrise alarm clock. I know they are available for buying, but still I wanted to create my very own version.
My idea was to use an Arduino microcontroller and some RGB LEDs. The sunrise alarm clock should work without a display. A smartphone app should be used to connect via bluetooth to the alarm clock. The smartphone app should be able to set the time, the alarm, steer the LEDs, etc. .
make it happen
With an example I figured out how to create a ’normal‘ Arduino alarm clock using an RTC. This example was easily adapted to steer the RGB LEDs and to integrate the HC-06 bluetooth controller.
principal scheme of hardware setup + working mode
I left out the on/off switch and the battery in the basic scheme. It is obvious.
It is definitely recommended to change the name and the PIN of the bluetooth module as described in the bluetooth cookbook.
Switching the alarm on at the time desired was easy. But how to turn the alarm (light) off again? Using the smartphone might be tricky in the morning. I was also thinking of a proximity or a light sensor but this could be error-prone. The next best thing I thought of was a capacitative touch sensor instead of a switch. In the end I realized three possibilities to turn the alarm off:
- using a simple capacitative touch sensor
- using the iRise app to send the off command
- an automatic timeout
The bluetooth controller is connceted to the Arduino as a serial device. A simple Serial.read() does the trick and reads the characters sent via bluetooth. Sending data back is possible using the Serial.write() function.
Before creating a dedicated smartphone app the bluetooth connection can be tested with a bluetooth terminal app from the play store.
I invented some codes for communication via bluetooth to steer the basic functionality of the alarm clock such as
- setting the actual time: i12:34z
- setting the alarm time: s07:30z
- stopping the alarm: tz
- turning the RGB LEDs on: c0..9z
- sending back the current time of the clock: bz
The character ‚z‘ marks the end of a command.
Since I do not want to give anyone the possibility to launch „Denial-of-Sleep“-attacks I will not publish the codes I really use. 🙂
To avoid a long and confusing Arduino program it is possible to create C++ libraries. For the alarm clock functionality and driving the RGB LEDs I created two simple Arduino libraries.
In the end I transferred the project to a clone of an Arduino Pro Mini. This small plate has all the required connections and has a minimal size for a reasonable prize.
iRise smartphone app
The smartphone app ‚iRise‘ is pretty straightforward. I decided to go for plain Material design. On http://www.androidhive.info/2015/04/android-getting-started-with-material-design/ I found a good example to start with.
Numerous examples explain how to find and pair a bluetooth device. E.g. http://www.tutorialspoint.com/android/android_bluetooth.htm or http://examples.javacodegeeks.com/android/core/bluetooth/bluetoothadapter/android-bluetooth-example/ explain everything.
rainbow and mood light
The bluetooth sunrise alarm clock can do some more: it also serves as a mood light. Several single colors can be selected in the app. Alternatively a rainbow color change or blueish night mode can be switched on.
The bluetooth state is displayed on another fragment of the app.
Another idea for extension is to capture smartphone notifications such as calendar reminders or incoming messages. Such notifications could trigger the sunrise alarm clock to blink in a dedicated color. This could be solved using a service and a user activated listener as well as the smartphone to be near the alarm clock for a working bluetooth connection.
Another possible extension is to measure the battery voltage to estimate the remaining battery time.
Clone of Arduino Pro Mini
Lilypad RGB LEDs
RTC – real time clock module
HC-06 bluetooth module
capacitative touch sensor
rechargeable 3.7 V battery
for development and testing: Arduino Uno
a box for the clock
For simplicity I used the Lilypad RGB LEDs. They bring the required resistance along. But any other RGB LED or even a RGB LED strip (5V!) will do as well.
good to know
Whenever the Arduino sketch is transferred to the board the bluetooth adapter may not be running because it is using the serial connections. Simply remove the power of the HC-06 before the software upload starts and put it back afterwards if required. A reversible connection between the VCC input of the bluetooth module and the power source is a good solution for software updates.
During development it might help a lot to attach an LDC display the the Arduino to display the current settings of the alarm clock.
some pictures and a screenshot
source code examples
construction of a box
This was not simple. One of the first ideas was to construct a paper box. But this is not a durable solution. So the box will be -under construction- for a while! Maybe it will be a wooden box with an acrylic glas top in the end.