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 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.
... 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.
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:
#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
cmd="insmod spi-gpio-custom $bus=$id,$sck,$mosi,$miso,0,$freq"
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.