LedClock

From Randomdata
Jump to: navigation, search

= Inspiration

original post on hack-a-day: http://hackaday.com/2014/05/16/led-clock-looks-cool-and-tells-time/ an inwards shining led clock. looks good but probably hard to make: http://www.themost10.com/wp-content/uploads/2012/12/MILEs-LED-clock.jpg?cd5e0d article on hack-a-day about efficiently controlling these leds: http://hackaday.com/2014/02/02/rewriting-ws2812-driver-libraries-for-optimization/

Background, sources, etc

https://bitbucket.org/sjoerdtimmer/ledclock

Build instructions

This project has been under quite heavy development lately (at the time of writing). The wiki (http://randomdata.nl/wiki/index.php?title=LedClock) contains details about the design and the development process but I thought it would be a great idea to have some final build instructions. Here they are:

Requirements/parts:

These are the parts for a completely redesigned version of the clock. The appearance is still exactly the same but the controller is now an esp8266 wifi module that fits inside the ring of the clock. (the old version used an arduino and an ethernet module). There are a few links to eBay on the wiki but they tend to change. Give it a quick search and you'll probably find similar items for similar prices. Leds. This is probably the most expensive part. My designs are all built around 50 cm @ 144 leds/m = 72 leds. These are relatively expensive since the leds are really close together but it does give very nice results. Mine cost about $21 when I started this project, but nowadays they sell for as little as $13. Most are advertised as ws2812 but are actually ws2811. 5V power supply. This needs to be rather hefty. I used a 5A version because I wanted to be really sure that even if I accidentally turned all leds full white it wouldn't break. If you are feeling brave you could probably calculate the maximum number of leds that can be on at a time and choose a slightly smaller supply but that's up to you. a small pcb (see pcb folder for design). Can be ordered at oshpark for slightly over $5. esp8266 (v1 module) (~$3) power cord (my supply didn't come with one) 1000uF capacitor to smooth the 5v line (the ledstrip can create big fluctuations that the esp really doesn't like). 22uF capacitor 100 ohm resistor AMS1117 3v3 regulator a cable (white looks good) I re-purposed a 5ft usb cable. 3D printed frame. Look in the 3D design section of this repo and you'll find freecad designs as well as the corresponding stl and gcode. Make sure to print the latest version (v6 at the time of writing). In White PLA it looks quite good because the light shines through.

BOM

This is the minimum for a simple clock:

what details status on ebay? dollar euro Digital Leds 50cm for a 16cm diameter, ws2811 with 144 leds/m ebay 20.88 15.34 controller arduino pro mini ebay 2.54 1.87 power supply the leds are 35Watts/meter so we need at least 17.5 watts(=3.5A @5V) ebay 6.99 5.13 RTC module ebay 0.99 0.73 cable abuse a usb cable because we have exactly 4 strands to power ebay 3.25 2.39 Total 34.65 25.44 Leds 72 led addressable led string like this (or similar).

Controller For simple tasks an arduino pro mini might be enough, but to display cool statistics requires something network attached. Maybe someone has a sugestion for a very small usb arm dev board with ethernet/wifi?

Power supply The leds draw 35Watts per meter. so for 50cm they will draw 17.5 watts when the leds are full on. At 5V this means we will need a power supply that can handle 3.5A. This is quite a lot and we may need something like this: [1] (Note: 3.5A is peek current if all leds are full white. In the case of the clock some leds will be off altogether or only one of the colors will be on. Nevertheless it would be bad design not to account for the maximum current)

RTC module A digital timer to keep track of time accurately and also when the clock is off. (it should be off when the space is closed to save power)

Other stuff A nice looking cable is required to power the ledstrip. My idea is to put all electronics externally somewhere on the floor/ceiling. The ledstrips have exactly 4 wires so we can abuse a white usb cable for maximum stylishness.

Small supplies like connectors and a power supply for the controller are excluded from the BOM because I think we have them lying around in space.

3D printed parts The ring that holds the leds will be 3d printed. Furthermore I intend to design a small housing for the controller and the power supply.

Assembly:

There is a cavity in the underside of the frame. This can be used to accommodate all electronics. The pcb has too many components. At first I thought a logic level shifter would be required but it turns out the 3v3 signal is okay for the ledstrip. Also, adafruit recommends the use of a protection resistor. I mistakenly added one to the pcb (470 ohm) but it later turned out that to be effective it needs to be placed at the ledstrip side of the transmission line. Also, in combination with the logic level converter it is redundant and degrades the signal quality (to an unreliable level that sometimes does and sometimes doesn't work) because it is supposed to compensate for the low-impedance output signal of the controller, but the logic level converter has a relatively high-impedance output... File:TODO: add pictures

firmware

This repo contains my code to control the clock. The firmware is flashed in two stages: at the hardware level, we use nodemcu(written in plain c, compiled against headers for the chip on the esp) nodemcu executes lua code which is stored in a simple filesystem on the system flash esptool.py write_flash 0x00000 <nodemcu bin file> At this point you may want to fire up your favourite serial console application to check that you can get a terminal: screen /dev/ttyUSB0 9600 > python2 nodemcu-uploader.py --port /dev/ttyUSB0 --baud 9600 node format python2 nodemcu-uploader.py --port /dev/ttyUSB0 --baud 9600 upload clock.lua python2 nodemcu-uploader.py --port /dev/ttyUSB0 --baud 9600 upload hsv.lua python2 nodemcu-uploader.py --port /dev/ttyUSB0 --baud 9600 upload response.lua python2 nodemcu-uploader.py --port /dev/ttyUSB0 --baud 9600 upload utils.lua python2 nodemcu-uploader.py --port /dev/ttyUSB0 --baud 9600 upload weather.lua python2 nodemcu-uploader.py --port /dev/ttyUSB0 --baud 9600 upload web.lua python2 nodemcu-uploader.py --port /dev/ttyUSB0 --baud 9600 upload ini.lua:init.lua --restart

Using the clock

When the clock boots up it shows a rotating rainbow until is has successfully connected to the wifi AP and obtained a timestamp through NTP. If you see the rainbow at any other time, it means the firmware has crashed and the clock is rebooting.

Configuration

If this is the first time you use the clock it will not know which AP to connect to and the rainbow will keep showing untill you configure the wifi settings. To do so, connect to the LedClock wifi with password NaeVaep3fu, and visit http://192.168.4.1 in your browser. For some reason, visiting this with my desktop made the clock crash but I can successfully configure the clock using my android phone. (I presume that my desktop chrome is sending too much metadata with the request that is buffered in ram in the module, resulting in a ram overflow issue of some kind.) Although the webinterface suggests that you can set the timezone and location, this is not actually true. This needs to be done in the lua code!

Reading the time

The clock uses only two colors: red and green. When mixed, they form yellow. The hours are shown in green by means of a green arc that starts at 12 o'clock and ends at the current location of the hours-arm. The minutes and seconds are indicated using red pixels. To know what time it is you have to find the crossovers black/red or yellow/green. One of these is moving, so that is the seconds-arm. The remaining black/red or yellow/green crossing is the minutes-arm.

Reading the weather

Once every 5 minutes the clock will fetch a weather update for the hardcoded location. This is from a service for dutch weather forecasts. To get weather updates for other countries, you're on your own for now. To warn you of a weather forecast a red led will blink 5 times, after which the forecast for the next 60 minutes is plotted along the perimeter of the clock (just right of the red led is the forecast for a few minutes from now and just left of it is the forecast for 59 minutes from now). If the forecast contains no >0 values the display routine is skipped.