Tag Archives: smart home

LED bed light

I have been working on my own custom wakeup-light on and off for several years (part 1, part 2, part 3). After getting Philips Hue lights, however, I have not gotten around to setting it up in my new apartment. So recently, when the need came along, I figured the quarter round rod I used for that project might also make a pretty nice looking bed light.

Version 1

I cut one of the old rods to length and taped it to the headboard to see how it would look:

This could work! I borrowed the old driver board from the wakeup light and hooked up a couple of potentiometers to an Arduino to try the whole thing out:

Version 2

After convincing myself (and subsequently the significant other) that this was a good idea, I went at designing and 3D-printing some mounting brackets to replace the silver tape that held the v1 in place.

Prototype 1
Prototype 2
Final version

The last version was long enough to hold the rod and had holes to let the cable escape invisibly out the back of the headboard:

Looking way better already!

Version 3

The next thing to work on was the electronics. Using potentiometers and analog inputs was not really ideal as the light would flicker and change even by just touching the knobs or the cables and required frequent polling of the inputs in the code. Also, the potentiometers I had were only single-turn.

To make a more reliable control, I ordered some EC11 and EC12 “coded switches” or rotary encoders from Aliexpress. These turn just like potentiometers, but are really acting like switches, opening and closing in a sequence that lets you decide which way they are rotating. The main advantage of this is that there is no need to sacrifice an entire analog input channel just for the sake of having a rotary knob and furthermore, the pins can be hooked up to pin interrupts, removing the need for polling altogether. The ones I got could also be pushed like a button, which I could use to switch between brightness and color mode instead of having two separate knobs like before.

After getting the  encoders in the mail, I designed yet another version of the holder that would also house the control knob:

The knob looks a bit out of place and is bigger than is really needed. I will probably try making a smaller one that fits the style of the whole thing a bit better for version 4. And then it would also be neat if the light could be controlled over wifi of course… But first I will figure out a way to hide the electronics so that they are not on top of the headboard!

The  3D-printed parts I made fit the bed IKEA Malm really well but are fairly simple in design. If you still would like me to share them for your own project, drop a comment below!

Alarm Clock v0.1.0

Alarm clock prototype

We wanted to try banning phones from the bedroom (you should try, I recommend it!). Clearly, a suitable hardware replacing the alarm clock app was needed. Having thought about building my own alarm clock for a while, I quickly determined it was not a viable option to just go buy one – there simply did not exist a model with all the features I had thought of and now needed to have, like for example:

  • Weekly schedule (no alarm on weekends)
  • Smarter snooze (configurable and longer)
  • Integrated with wakeup-lights and the rest of the appartment
  • Configurable from other devices
  • Programmable/extendable with future ideas

Alarm clock prototype parts

For the first prototype, I used some parts I had laying around:

  • Raspberry Pi A+ with USB wifi dongle
  • 1.8″ TFT display (check Ebay for “HY-1.8 SPI”)
  • Some prototyping board, connectors and pushbuttons
  • Small speakers with 3.5 mm jack

The firstAlarmclock wiring step was to connect the display. The one at hand communicated over SPI, which all Pi’s support, and hooking it up was not too difficult. Then, however, I spend quite some time trying to make the Pi recognize it as a screen rather than handling the SPI commands to it directly in my code. (Doing that would mean the interface could be a webpage for example, which would make it easier to develop.)

Using an SPI TFT as a monitor had been achieved already and made quite a buzz on Hackaday back in 2012 or so, but unfortunately it was not so easy to reproduce. At the time of building this in late 2016, most documentation I could find was still from 2012-2013 and talked about compiling the kernel from scratch and a frame buffer driver called fbtft. But, once I found its official Github repository, the first thing in the readme was (and still is) a message from early 2015 saying the driver has moved into Linux staging and that development there has ceased:

2015-01-19
The FBTFT drivers are now in the Linux kernel staging tree [...]
Development in this github repo has ceased.

I could not find any signs if fbtft is now actually part of Raspbian nor any comprehensible documentation on how to set it up so I ran out of patience and decided to go with direct SPI control for the first version, meaning less fancy graphics for now. For direct SPI, finding examples was a little easier and by learning from the code on w8bh.net, I finally got something working.

The Pi now runs a fairly simple Python script, listening to the buttons and updating the display every minute, playing an mp3 file at increasing volume if it is wakeup time. The display shows current time and the time of the alarm (which only runs monday – friday). Two of the buttons are used to move the alarm time back or forth in 15 minute intervals. This can be used to change the alarm, snooze or skip it in the morning. The third button stops the alarm and the fourth toggles the Philips Hue lights in the bedroom on/off. The Hue lights are actually controlled via MQTT, from a Node Red server running on a separate Raspberry Pi,  acting as a hub for this and some other “smart home” features which might be a topic for a future post.

Alarm clock interface

All-in-all we are pretty happy with this first version, it has been in live use for four months now without any major malfunctions and basically it just needs an enclosure. It does lack some obvious features, like adding an alarm on the weekend and actually moving the time the wakeup-light starts along with the alarm time. Also, when I make a new version, probably I will add another button for starting the coffee maker as well. 😁