Transforming Sphere Lamp

The Death Star inspired IKEA PS 2014 Pendant Lamp is a great platform for a connected home hack. Mine is shown in the video below.

Out of the box, the lamp uses a string and pulley system to open and close the spherical shell. It is a relatively simple mechanism where two strings pull a platform up and down a central spine. Ten scissoring arms attach to this moving platform and to a fixed platform near the top of the lamp. Moving the bottom platform up the spine spreads the outer ends of the arms, opening the lamp’s outer shell (see diagram below from the lamp’s assembly manual).

open_close

There is a void where the lightbulb normally sits between the top-most position of the moving platform and the upper platform. This provides the space for the stepper motor and LEDs needed for my modifications. The upper portion of the spine which splits in two to accommodates this space also offers a convenient platform to attach these new bits to.

Lastly, there is cap used to cover the wiring where the lamp anchors to the ceiling. This provides a convenient space for electronics. In my case, I’m using an Arduino Uno, an Arduino Motor Shield and a SmartThings Shield.

I replaced the standard wiring with a Cat5 ethernet cable to connect my electronics in that cap to the motor and LEDs in the body of the lamp. Four of the Cat5 wires are used to control the motor and three for the LEDs, leaving one unused wire.

bits

Stepper Motor

Given the design of the lamp, it seemed easier to directly drive the lamp’s lower platform rather than try to pull the strings that the lamp ships with. I first thought I would attach a threaded rod to a standard stepper motor, but then I found this motor with a lead screw that is long enough to cover the entire length of the lamp’s spine.

I attached the motor using a standard mounting plate and a fiberboard bridge attached to the central spine of the lamp.

sphere lamp inside

Driving the motor was simple once I found a motor shield that could power it. I first tried Adafruit’s Motor Shield, but it does not provide enough power. After realizing this, I did a bit more research and determined that the Arduino Motor Shield should be able to drive the motor. And it is.

The video above shows the motor moving the platform and opening two of the ten arms. When the lamp was finally assembled, I cut off the last few inches of the screw so that it was just a little longer than the spine.

NeoPixel LEDs

For the lights, I wanted the flexibility to individually control an array of RGB LEDs. I’ve used the NeoPixel rings before in another project and really like how simple they are to use and how the ring format provides very nice visual effects with relatively simple animations.

Given the design of the lamp and the need to work around the motor’s position, I wanted to use the larger 60 LED ring configuration. Unfortunately, the rings could not fit in any one location when the lamp’s arms were both extended and contracted. Luckily, each 60 LED rings is actually made of four 1/4 circle arcs. I ended up using two sets of three arcs in triangular configurations (one triangle facing down and one facing up).

I then added a 24 LED ring to the top of the lamp to add a bit more brightness. This also works to fill some of the shadows cast on the ceiling by the internal LEDs. The results are great, especially when the lights are animating.

animate

SmartThings

I’m using the SmartThings platform to control the lamp. I went this route for two reasons: it is relatively easy to build a controller UI to use within the SmartThings app and I can integrate it with other things in my house connected to the SmartThings platform.

I created the UI by writing a device handler. The handler sends commands as strings to the SmartThings Shield which are then passed as a parameter to a designated handler function running on the Arduino.

I have not yet connected the lamp to other things but this can be done by writing a SmartThings app.

Memory

Very early on in the project, it was clear that constrained RAM on the Uno would be an issue. The first indication was that the board kept restarting with all three components integrated (while any two components worked well).

The first step was to do some simple optimizations to the types of variables I use (e.g. uint8_t in place of int). With this I was able to could get the three components working together; however, memory was still maxing out when I sent long strings from SmartThings. “SetColor: 255,255,0” would work but, “SetColor: 255,255,255” would cause problems. Simply shortening these to “sc:255,255,255” did the trick.

Then something quite surprising happened. The .toInt() function that I use to convert the strings to integers would periodically stop working and convert any three color values to 0,0,0 until I restarted the Arduino board.

I tracked this down to what I believe to be another memory issue, but one more complicated than simply running out of memory. Removing the motor code from the project (and freeing a good deal of memory) was not fixing the issue. On the other hand, removing some of the strings from the sketch that were used to parse the commands sent from SmartThings (freeing up very little memory) did fix this new problem.

In the end, the fix was to further shorten all command strings and to reduce the overall number of commands by consolidating related commands into individual commands with enums.

Persistance

The lamp can be turned on and off from a standard wall switch so it was important to me that I persist some of the settings while the power was off.

Retaining the position of the moving platform is most important since doing so frees me from adding sensors to know when the lamp is fully open or closed (and thus keep the motor from grinding away once it reaches one extreme or the other).

I also save the NeoPixel RGB and brightness values.

I originally planned to use an FRAM memory module but my previously mentioned memory constraints as well as some pin constraints imposed by the motor shield forced me to reconsider. I decided instead to take a shortcut and use the Arduino’s built in EEPROM memory. This is volatile memory rated for 100,000+ writes, but I’m ok with that trade-off for now.

Power

During development I powered the motor and lights through the Arduino with the lights hooked up to VIN. This worked fine as long as I dimmed the LEDs before running the motor.

However, when run at any significant brightness for moderate periods of time, the power would cut off. This is because the 114 NeoPixels pull about 3 amps at full brightness and my 2 amp power source shuts itself off before damage is done (there is a thermal switch that is thrown as it overheats). Using the recommended calculations it was clear that I should be using a dedicated power supply rated for at least 7 amps.

In the final installation, the lamp is powered by two 5V supplies. The first is a 2 amp supply used for the Arduino and motor plugged into the Arduino’s barrel jack. The second supply is a 10 amp supply connected to the LEDs using this barrel jack adapter (with the ground tied to both the LEDs and the Arduino).

Thats about it

All in all, this was a fun project and I’m pleased with the the results. It presented a number of puzzling challenges both with modifying the physical lamp and getting the different electronics working together and I learned a number of new details along the way.

You can find the Arduino and SmartThings code on GitHub.

If you have any questions let me know in the comments and I’ll do what I can to answer them. And, if this you build your own, I’d love to see it.

Getting Started with Arduino

If you are new to electronics, but want to start making things with Arduino, I recommend that you begin with an Uno and these great resources.

  1. Make’s Getting Started with Arduino book
  2. Make’s Ultimate Arduino Microcontroller Kit

The book includes a brief introduction to electricity and then dives into working with Arduino.

The kit includes many of the things you will want to play with as you read the book and includes an Uno.

Once you have a handle on the basics, you can add internet connectivity with the Arduino WiFi Shield or step up to the Yun.

The WiFi Shield can be used easily with the Uno, but it will limit the amount of memory and the IO pins available to you. The Yun avoids these limitations, but has some frustrating idiosyncrasies to it. Because of these idiosyncrasies, I don’t recommend the Yun for beginners.

Eggs 2014

Image

Sine waves were a popular choice for this year’s eggs. And the Minecraft pigs were in demand as always.

All the eggs pictures except the pigs were plotted directly from Processing, the pigs were drawn using Inkscape.

I’ll post the files to Github within  a couple weeks.

update: code and svg files are now available on Github.

Air Quality Egg Mod

crop I was not thrilled with the air quality egg enclosure that shipped with the final product and since I planned to use it inside, I decided to mount it on a plank of wood and leave the circuitry exposed. I also wanted some sort of display so I added a meter and modified the code to use pin 3 (pwm) to display the humidity.

Original project date: April, 2013.

Code for multi-switch posted to github

I’ve posted the code for my SmartThings multi-switch project to Github.

There you will find 3 files.

  1. smartthings_controller.ino – the Arduino code which communicated with the SmartThings cloud using the SmartThings Arduino library. I’m using an Uno.
  2. device_handler.groovy – the device handler code. This defines the device for use in the cloud and its UI in the SmartThings app. It is specific to the hardware, but not the use of the hardware.
  3. SmartApp.groovy – the SmartApp code. This defines how the device is used. In my app I tie specific hardware bits to specific device types (e.g. switch, switchLevel or musicPlayer).

For more information on the SmartThings IDE, writing SmartApps and related topic, have a look at these tutorials on the SmartThings developer site.

Multi-switch for SmartThings

Now that the SmartThings lab has released support for both Sonos wireless speakers and Hue lighting, I decided to build a custom switch using the SmartThings Arduino shield to interact with the system. The goal was to provide physical control over the systems without using a phone or tablet.

In my case, I wanted to be able to quickly:

  • Pause/Play all speakers in my house
  • Skip the current song
  • Turn groups of lights on and off
  • Dim the lights (not yet implemented)

The hardware uses a reclaimed project box from the last century with an Arduino UNO and SmartThings shield inside. It includes two pushbuttons, three switches and a knob.

Image

With the hardware put together, the next step was to create a custom Device Handler for the SmartThings cloud and write the SmartApp.

The Device Handler essentially creates a virtual version of the device. It identifies each button and switch in the hardware to provide the basic inputs and outputs used by my SmartApp. The Device Handler also defines the device’s UI that is presented within the SmartThings mobile app.

The SmartApp determines what happens when someone interacts with the hardware. For example, I define which switches will turn things on and off and which ones will call play and pause. The App also defines the UI used to configure the app and map specific switches to specific Sonos and Hue hardware.

Documentation for writing handlers is lacking and this required a good deal of trial and error. In fact, I have not yet been able to hook up the knob within the handler. Once I do, I will post the bits on Github; but, for now if you want to work on something similar, I found this Arduino Code and corresponding Handler Code quite useful.

Another other bit of documentation that came in handy for how to control the Hue and Sonos devices is this list of device types and capabilities.