Sunday, July 27, 2014

Wordclock based on Arduino Yun

Introduction

This year, as every year, I did not have the faintest idea what to give my brother to his birthday, I decided, quite boldly, to build a birthday present with my bare hands. I figured out that everybody needs a clock, and that building a WordClock would be a funny challenge for myself.

The purpose of a WordClock is to present the time of the day using letters instead of numbers. I believe that the idea stems from the ClockTwo from Biegert & Funk (http://www.qlocktwo.com).
There are also other versions available for purchase (for example dougswordclocks.com.) as well as a myriad of DIY-designs. For example, this one, this one and this one, all on Instructables.

My DIY WordClock


















Although the DIY-designs are fine, they are certainly not as sexy as the original ClockTwo, (and neither is mine). My design differs from the other alternatives (at least the ones I have found) in the following ways:

  1. It presents the time in Norwegian
  2. It has the possibility to show minute-precision time using the letters.
  3. The time sets itself automatically using NTP (including daylight savings time).
  4. It has a web-interface, so the user can use his smart-phone to adjust some clock settings.
  5. It has a light sensor so the intensity of the LEDs can be automatically adjusted to the light in the room. (I know, other clocks has this as well)
To accommodate automatic adjustable time, I based the clock on the Arduino Yun, which besides being a standard Arduino with an Atmel AVR, runs Linux on a separate processor and can connect to WiFi and the Internet. The parts needed for this build is:
  • Arduino Yun ($75 at Adafruit)
  • 100 RGB LED-strips ($29.95 for 32 (1m) at Adafruit)
  • A light-sensitive resistor (negligible cost)
  • A resistor to match the above as a voltage divider.
  • A micro USB connector
  • A 2A 5V powersupply
  • A acrylic front plate
  • A frame, or something to hold the electronics and the acrylic front 
As the astute reader will notice, this is not the cheapest of the builds (although cheaper than the ClockTwo). However, thanks to the RGB-led strips it is relatively easy to build, compared to soldering and mounting 100 LEDs, and it also provides the unique ability to address every LED individually, and control their color.

The build


The first I did was to connect the light strip to the Arduino to check that all LEDs worked. All the strip needs is 5V, GND and two pins on the arduino.


The LED-strip connected to the Arduino


After verifying that the strip worked with some code provided from adafruit, I divided the strip in ten sections of ten LEDs, glued them to a 35cm x 35cm plate and soldered them together in a back-and-forth pattern.

The 100 LEDs glued to a plate, showing off with a rainbow pattern.

Since all the letters must be able to light individually, we do not want the light from one letter influence the neighbor letters. Hence some sort of frame must be built around each LED. I created a simple 2x4 design in OpenSCAD and let my 3D-printer do the job. Unfortunately, I only had black PLA, and since white is preferred to increase reflection from the LED, I spray-painted the frames. The result is shown below.


3D-printed frames fixed to the backplate with sugru.

The complete grid layout consists of ten 2x4 frames and five 2x2 frames. Obviously, I could have printed a 10x10 frame to cover the entire clock but that would have required a 3D-printer with approximately 35x35cm build areal.


The light sensor

To be able to fit the light sensor, a custom 2x2 frame was printed. On the top you can see the IKEA-frame which holds everything.

The 100 LEDs now have one little compartment each

With all the small 3D-printed frames glued to the back-plate with Sugru, it was time to figure out  a way to create the front-plate. This was by far the most difficult part of the project.

Front plate made in acrylic

The front plate is a 40x40cm acrylic photo print from http://www.idekor.no/. I made the lettering layout using a monospace font in inkscape, converted it to pdf, and then png, uploaded it to the online photo-service and hoped for the best. Frankly, even if the letters and the spacing between them was excellent, the result was a disaster, since the black was not entirely black. It was more grayish, and partly transparent.

Modifying the acrylic plate with some transparent plastic printouts

Since the sole purpose of the acrylic print was to isolate letters from background, I had to modify the acrylic by adding two layers of transparent plastic printed with the same pattern. Obviously I could have printed a new acrylic plate (maybe using a different online service), but sine I had already spent a small fortune on this one, and I was running out of time (this was a birthday present remember) I had to deal with what I had. To diffuse the light i used a layer of greaseproof paper.

The back of the clock with the nice IKEA painting

In the above picture you can see the back of the clock with 5V power at the bottom (white USB-cable taken from a Kindle), four wires to the LED-strip (top left) and two wires to the light sensor. The wires are connected to a custom Arduino-shield, which also powers the Yun. I used the original IKEA-picture since it was sturdy and perfectly fits the frame.

Old clock and new clock

I wondered for a while on how to fasten the acrylic front plate to the wooden frame. First I planned to drill holes in the acrylic plate and screw it using 75mm M3 bolts. Then, for some reason I read about fractured acrylic and did not dare to drill holes in my precious plate. Hence I decided to glue it in place. Using glue also had the benefit of allowing micro adjustment of the position of the acrylic plate over the 10x10 frame.


Well, the decision to use glue turned out to be fatal. Somehow I forgot that the acrylic plate was semi-transparent even in the black areas, and some of the glue can be shown from the front side of the clock. Typical DIYcrap mistake. Other than that, it was excellent.

How it works

Since this was a birthday present, I wanted an individual touch of the clock. Hence, while the clock boots, it shows the name of the owner of the clock. The letters in the name is used to indicate the progress in booting as well as outputting some status information. Even if the clock will probably boot very seldom (if ever) it is great for debugging purposes, so lets follow the process.


First the clock says that Arduino is working by showing a green "A". You may say it is sort of superfluous, since the LED-strip will not work without the AVR, but thats missing the point (and the fun).


After about a minute, Linux is running, (L is green). We can also see that we got Wireless connection (signal strength 5/7, since L,F,O,R,D is green), and we got an IP-address from a DHCP server (D is green).


Now, we have a connection to the internet (I is green). A connection to the Internet is simply verified by pinging google.com. If this address somehow dies (if google goes bankrupt), the letter "I" turns blue, but the clock will still operate.


Now, the letter "N" shows that we have received the time from a minimum number of four NTP-servers and we therefore believe that the time is set correctly in Linux.


At last, the letter "E" indicates the ambient light in the room as perceived by the light sensor at boot time. Red indicates low light, green indicates medium, while blue (as in the picture) means that there is a lot of (sun)light in the room, and the LEDs are set to maximum intensity for the time being.  (The intensity-adjustment is of course performed continuously as the clock operates, regardless of the amount of light during boot time). 



Using a simple web-interface, the user can select some additional features using his smartphone. A rainbow pattern for example, is always supercool. Since the Yun uses Bonjour and UPnP and all that stuff, the web-page can easily be found on the local WiFi using the arduino.local address.


A standard WordClock can only show the time in five-minute intervals. An additional feature that can be enabled using the web-interface is the ability to show minutes. This is performed by letting the letters K,L,O,K presented a different color. In the above picture, the three letters K,L and O means that we should add three minutes to the time showed. Thus the time is not five minutes to (fem på) "something", but rather two minutes to "something".

The verdict


I am quite satisfied with the build. Obviously, I did not choose the cheapest method, but the combination of the RGB LED strip and the Arduino Yun turned out to be a very fun and rewarding combination. I am certainly going to use the Yun in other projects as well. Had it only been a bit more affordable.

Another downside with the Yun is the limited codespace on the 32U4 microprocessor. With the bridge library, the LED-strip library and all the other stuff I almost hit the ceiling in code space. I even had to omit some super cool features that simply did not fit the 32Kb space on the controller.

Update! Download code





10 comments:

  1. Great!
    I have been looking for a way to make the same clock but in Spanish.
    Unfortunately the acrylic photo print is on Norwegian and I can't understand it.
    Could you please explain it a bit more this part?
    Some time ago I programmed a "simulation" on clock.rosety.com
    Congratulations
    luis(at)rosety.com

    ReplyDelete
  2. Your simulator is excellent. There is not much to explain about the norwegian lettering. The principle is precisely the same as on other english word-clock and I guess your spanish simulator. All the LEDs are controlled individually, so in theory, I can just switch the acryllic part with a spanish part and do some reprogramming.

    ReplyDelete
  3. This is awesome.

    Any chance you could post the code you used?

    Thanks

    ReplyDelete
    Replies
    1. Yup. You can download the code here. I have updated the post now, so everybody can get the code if they wish.

      Delete
  4. Dude this is crazy sick!

    What projects are you working on now?

    ReplyDelete
    Replies
    1. Hi, at the moment I'm working on some analog synths and an audio-mixer. I will create a blog-post about this project in the near future :-)

      Delete
  5. Really AWESOME work.
    Any chance you would be willing to sell one? Just with Danish instead of norwegian.

    ReplyDelete
    Replies
    1. I rather recommend you buy Biegert & Funks clocktwo. It can be purchased in Danish and can be yours for 995 Euros: Clocktwo

      Although my clock is only about 100-200 Euros in parts, and has some additional features, I do not think I am willing to sell one for less than 995 :-)

      Delete
    2. it's ok, I will make it myself or get someone to do it. 1k euroes is plain stupid for a watch :) Thank you for your reply and I must say I loved your watch.
      any chance I can email you, I have a few questions that I think you can answer easily

      Delete
    3. You're welcome. flathagen @ gmail. com

      Delete