bluetooth sunrise alarm clock + iRise smartphone app


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 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 I found a good example to start with.
Numerous examples explain how to find and pair a bluetooth device. E.g. or 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.

extending iRise

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.

components used

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
slide switch
FTDI cable
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.

software development

Arduino IDE from
Android Studio from

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.




android cardboard app using camera and OpenGL ES

Some time ago I started to program Android apps for my smartphone. This year I got my hands on a cardboard. My first idea was to use the smartphones camera. Stereo vision with a single camera is a fake, but still it was tempting.

I was searching for examples of cardboard apps and stumbled across this example. For a start this was very useful. The example app shows how to create a stereo view and how to display a live camera image. The app is using Open GL ES which won’t work on all smartphones.

After having played around a little with the app I realized that if I want to change the live image only the fragment shader has to be replaced. This can happen  while clicking on the display (difficult when the smartphone is in the cardboard) or when using the magnet switch.

cardboardView.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {

public void onCardboardTrigger() {

Excerpt of switchShader():

private void switchShader() {
    if (shader_selection > 31)
        shader_selection = 0;

    if (shader_selection == ORIG)
        overlayView.show3DToast("Shader: original. " +     shader_selection);
    else if (shader_selection == NEG)
        overlayView.show3DToast("Shader: negative. " +     shader_selection);

To display a negative image the fragment shader looks like this:

#extension GL_OES_EGL_image_external : require
precision mediump float;
varying vec2 textureCoordinate;
uniform samplerExternalOES s_texture;
void main() {
    vec4 color = texture2D( s_texture, textureCoordinate );
    float inverted = 1.0 - color.r;
    vec4 inverted_vec = vec4( vec3(inverted), 1.0);
    gl_FragColor = clamp(inverted_vec, 0.0, 1.0);

To invert RGB images:

#extension GL_OES_EGL_image_external : require
precision mediump float;
varying vec2 textureCoordinate;
uniform samplerExternalOES s_texture;
void main() {
	vec4 color = texture2D( s_texture, textureCoordinate );
    float invertedr = 1.0 - color.r;
    float invertedg = 1.0 - color.g;
    float invertedb = 1.0 - color.b;
    vec4 inverted_vec = vec4( vec3(invertedr, invertedg, invertedb), 1.0);
    gl_FragColor = clamp(inverted_vec, 0.0, 1.0);

A nice sepia effect:

#extension GL_OES_EGL_image_external : require
#ifdef GL_ES
precision mediump float;

varying vec2 textureCoordinate;
uniform samplerExternalOES s_texture;

void main()
    vec4 color = texture2D( s_texture, textureCoordinate );
    vec4 sepia = texture2D( s_texture, textureCoordinate );
    sepia.r = (color.r * .393) + (color.g *.769) + (color.b * .189);
    sepia.g = (color.r * .349) + (color.g *.686) + (color.b * .168);
    sepia.b = (color.r * .272) + (color.g *.534) + (color.b * .131);
    gl_FragColor = vec4(sepia.rgb, 1);

Several good examples for shaders which can be adapted I found here:

It is quite important to stop the camera when the app is paused. Otherwise other apps could not use the camera in the meantime.

    public void onPause() {

    private void stopCamera() {
        if( camera!=null ) {

The result looks like this (computer mouse in negative mode):


The smartphone gets pretty warm while using the app…