Posts Tagged 'light'
2016-09-03

A few days ago, the urge to create an internetted thingy was upon me. Recently, I had been reading documentation regarding machine to machine communication using MQTT as well as BLE, and then I took a quick look at my tinker pile. The amount of neat things that I purchased for use in a project was far too high.... and then it hit me: LESS HOARDING, MORE MAKING!

What I was craving to make, was a network accessible pixel LED, inside an orb light fixture, that could be controlled using MQTT.

For this build, I used:

  • an orb light fixture from the ReStore
  • an Unwired One single board computer running OpenWRT
  • a single ws2801 pixel LED that was left over from the Glimmer build.

The Build

The Fixture

The orb light fixture appears to be a run of the mill wall or ceiling CFL fixture. If I remember correctly, the orb cost around $5. The cost of computer cases these days is getting out of hand. :)

Take it Apart!

For some reason, the fixture manufacturer decided to put a bunch of unnecessary crap in my new computer case. Fortunately, it only took a few minutes to get the orb in a usable state.

Test the Circuit

ws2801 pixel LEDs are controlled using SPI. On the Unwired One device, there are no GPIO pins that are dedicated to SPI. Instead, the SPI bus is created by loading a kernel module with arguments to determine which GPIO pins will be used for SPI.

Solder Leads to the LED

Once the circuit was working, leads were soldered to the LED so that it could be connected directly to the GPIO headers.

After the soldering was complete, the leads were wrapped in electrical tape.

Make a Notch for the Power Cable

Since the orb is intended to rest on a table, it was necessary to make a notch in the base for the power cord to fit through. Thus ensuring that the orb will be flush on a flat surface. After a bunch of waffling around trying to find my files and metal snips, a grab and twist with some needle nosed pliers did the trick.

Put it Together

After more waffling while trying to determine the best way to make some fancy standoffs for the computer board, I opted to simply hot glue the board to a piece of cardboard, and then hot glue the cardboard to the underside of the orb base.

Fast
Simple
Effective
... and I'm lazy

The LED was also hot glued to the base, pointing upward into the glass orb. /

Now me has ORB!

Have Some Coffee

Technically, this picture is for the morning after the Orb Device had been created, but it does a damn fine job of showing what the orb thingy looks like.

The Code

Enable SPI

As previously stated, the SPI on the board needs to be configured by added a kernel module. In order for the kernel module to be loaded each time the device is restarted, the /etc/rc.local file was edited to launch the following script:

#!/bin/sh

#see http://www.unwireddevices.com/wiki/index.php/Working_with_SPI_(C/C%2B%2B)
#BUS : SPI bus number, can be bus0, bus1, bus2, bus3
#ID : SPI device ID (integer number)
#SCK, MOSI, MISO : GPIO numbers for the corresponding SPI signals
#MODE : SPI mode (0, 1, 2 or 3)
#FREQ : max SPI frequency (Hz)
#CS : GPIO number for the CS signal (optional)
# insmod spi-gpio-custom BUS=ID,SCK,MOSI,MISO,MODE,FREQ,CS

bus="bus1"
id=1
sck=20
mosi=23
miso=18
freq=25000000

cmd="insmod spi-gpio-custom $bus=$id,$sck,$mosi,$miso,0,$freq"
echo $cmd
`$cmd`

Honestly, the entire script can be replaced with one line of code: the final command. However, the script was written while reading the documentation of the process and if I ever need to edit the script, there are hella useful comments in there.

Control the Orb

The code for controlling the orb is written in Python and requires the Paho MQTT library.

code is available at https://gitlab.com/jezra/orb

oh... It would be really nice if I could copy the payload parsing documentation from the README.md in the code repository. Sadly, the lazy dev hasn't yet created that file. Well then, I know what I'm doing later!

Now quit reading, and go make an orb thingy.

Comments
Name:
not required
Email:
not required (will not be displayed)
Website:
not required (will link your name to your site)
Comment:
required
Please do not post HTML code or bbcode unless you want it to show up as code in your post. (or if you are a blog spammer, in which case, you probably aren't reading this anyway).
Prove you are human by solving a math problem! I'm sorry, but due to an increase of blog spam, I've had to implement a CAPTCHA.
Problem:
2 plus 5
Answer:
required
subscribe
 
2019
2016
2015
2014
2013
2012
2011
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008