Super Dock Qi Upgrade Video

The “Super Dock” is a dock for my moto x (2014) phone that has a giant 4200mAh battery in it.  It keeps my phone charged for a few days instead of just 10-12 hours.

I made the dock several months ago.  It consists of 2 parts.  The first part is the actual dock.  It’s molded so that the moto x just snaps into it.  It has a USB plug at the bottom to charge the phone.

The second part is the cover.  It is molded to fit around the dock and protect the battery and circuit.  It fits snugly on the dock part and the bottom of the phone.

Here’s the video:

Minnowboard Max RFDuino Lure

rfduino-lure

This lure is still a very rough draft, but it should allow for a number of pretty cool features:

  • Bluetooth Low Energy peripheral mode
  • Programmable with Arduino IDE
  • Adds some IO, PWM, SPI, I2C to the max
  • Communicates with Max over UART

TODO:

  • Define RFduino <-> Max communication protocol
  • Create protocol library for arduino
  • Create protocol library for Max (python?  C++?)
  • Write examples

The source including kicad schematics is here: https://github.com/tripzero/max-lures/tree/master/rfduino-lure

Bluetooth Low Energy LED – Part 1: Hardware

LEDs should be taking the world by storm.  They are so far the most power efficient lighting source available.  Because they are more power efficient, they can save you money.

There are many smart LED lights out there.  The Philipps “Hue” is one where Philips has opened up their API (to registered developers).  This allows people to write custom software to take more control over their lighting.

However, there are concerns.  The Hue is a connected device.  It is on the Internet which brings in security concerns.  Aside from the security concern, maybe you want to just do your own lights?  Perhaps you just want to learn and discover how such systems work?  Maybe you have a killer feature in mind that isn’t supported by the other lights?  For all of these reasons, I have undergone an attempt to create my own Bluetooth Low Energy Smart LED.

DC Power and Solar possibilities

LEDs are DC powered.  Meaning, in order to use them in your AC-powered home, you need a AC-DC converter.  The AC-DC conversion may not itself be inefficient relative to a DC-DC stepdown converter, however, if your power comes from solar, which is also DC, it adds inefficiencies to go from DC to AC and back to DC.

If you have a solar setup, which someday I hope to have, you may want to try to convert your home lighting system to DC powered, in which case, off-the-shelf smart LEDs won’t work because they have built-in AC-DC converters.

Bluetooth Low Energy

Bluetooth Low Energy (BLE) is a new protocol incorporated into the Bluetooth 4.0 standard for low energy consumption.  It doesn’t have the speed that classic bluetooth has, but it allows for a lot lower power usage.  It’s range is also limited, but for a small house, it’s probably tolerable.  Other smart LEDs use bluetooth low energy.  Some use Zigbee, another low-power wireless technology.

I use BLE in some of my other projects, so it made sense to use it here as well.

One cool device that supports BLE is the RFDuino.

RFDuino

This device combines the programming interface of an arduino with a chip that supports BLE.  It’s API is pretty flexible allowing you to customize the UUID’s, device name and even change the transmit power the radio uses.  Best of all, in ultra low power mode it only consumes 4uA.

RGB LED

There are lots of LEDs to choose from.  I went with a 10W RGB LED that I found on Amazon.

 

10W is bright, but not too bright.  With this hardware guide, it’s also possible to use a 20W.  If you go bigger, you’ll need to find different cooling than what I talk about here.  You can also use a plain white LED of 10W or 20W.  You’ll have to calculate the resistor values yourself, but there’s help here.

Cooling

LEDs can get hot.  So cooling is necessary.  I went with the passive cooling route and picked up 5 of these on amazon for pretty cheap:

They have mounting holes for 10W or 20W LEDs and come with the screws and thermal paste.

The Circuit

We want to be able to adjust the brightness on all three color channels.  To do this, we need 3 n-channel MOSFETs and some resistors.  Here’s my circuit diagram:

blelight_revB

LEDs 1-3 represent the Red Green and Blue channels.  If you have only a single white LED, you don’t need to worry about LEDs 2 and 3 or the MOSFETs.  This circuit diagram uses the RFDuino SMD module instead of the DIP.  If you are using the DIP, you won’t need the USB programmer connections.

NOTE: All the code including the RFDuino code, android app and circuit diagrams are all open source.  I will provide links in part 2 of this guide.

NOTE 2: I’m not an electronic engineer.  I’m learning this stuff as I go and sharing what I learn.  Please feel free to correct me, my designs or even better, submit a patch!

Power

For power I use a 12V DC power supply at 3.0A.  The LED takes 12V and the RFDuino uses 3.3V.  To supply the 3.3V for the RFDuino, I use a mini buck converter that takes 12V and converts it down to 3.3V.

The Bulb

How do we house all this hardware?  Well, I designed a “bulb” using a website called “tinkercad“.  Using this website you can design simple 3D models that you can print either using online services, or with your own printer (or in my case, a friend’s printer).

The case is round so that the round heatsink fits perfectly inside it.  I printed the case using clear resin.  My first bulb did not have holes in it to breath.  So it got kinda hot inside.  This latest revision has holes to breath.  Last but not least, it has a hole at the bottom for power input (sized to fit a standard socket adapter) and a lid that fits snugly at the top.

You can copy the design I made here.

For the power socket, I ordered these on amazon:

I used clear epoxy to cement the sockets in place.

WARNING: One flaw in this design, is that it uses a standard socket, but if you plug this LED into a standard socket, bad things could happen.  The LED expects DC current.  I modified a lamp to provide DC which I cover later in this guide.

After putting everything in the bulb, I was pretty happy with the results:
2015-02-22 (1) 2015-02-22

DC Powered Lamp

As noted above, I modified a lamp input to accept DC.  This was pretty easy.  I snagged an DC Barrel adapter from amazon.com, cut some wires, attached the adapter and done!

In part 2, I’ll go over the software to get this up and running including an Android App, Linux “LED” Server and the RFDuino code.  Stay tuned!

2015-02-21

 

 

Minnowboard Max Video Renderer with Ambilights – Part1: Software

2015-03-13

The minnowboard max is a pretty cool platform.  It’s small -just a little larger than a credit card, power efficient and best of all: powerful.  It uses the Intel Atom single or dual core with hyperthreading.  The best part about it, however, may be the integrated graphics with open source accelerated drivers.

Because the drivers are open source, you can expect them to generally “just work” on a typical linux distro.  No extra EULA or compiling necessary like on other embedded system.

The max’s Intel HD graphics also supports OpenCL 1.2 via the open source beignet project.  OpenCL allows you to offload otherwise CPU intensive computations onto the GPU which is specialized for specific tasks.  Having OpenCL available in an embedded system opens up a lot of possibilities including image processing via the open source OpenCV (Computer Vision) project.  I will be using all of these components in this project.Goal:To create a DLNA renderer that uses and LED strip to display an ambient light which correlates to the image on the screen.  There are several projects out there that do this: boblight, hyperion are a few.  In effort to teach myself some new skills, I opted not to use any of these projects and instead start from scratch with an architecture where I could utilize the CPU power that the max avails.  I believe this exercise has created something simple, yet unique.Components of the system:

  • OpenCV for image analysis
  • Gstreamer to play the video
  • Beignet for OpenCL/GPU offloading
  • Rygel for DLNA renderer support
  • Vaapi for hardware accelerated decoding/encoding
  • MRAA for accessing IO on the Max
  • MaxVideoRenderer
  • Python – the language
  • Ubuntu 15.04

Hardware:

  • Minnowboard Max
  • LED Strip with the WS2801 IC (google for LED strip and WS2801 and you’ll find dozens of options that aren’t very expensive)
  • Aluminium right-angle bracket I got from Home Depot for $2
  • Double-sided heavy duty 3M tape.
    (More about hardware in Part 2!)

OpenCV

OpenCV is a library for computer vision.  It’s used for object recognition, detection and has a lot of image manipulation routines that can take advantage of hardware acceleration where available.  OpenCV 3.0, now in beta, features transparent OpenCL usage when available.  In the version 2.4-days, you had to use special opencv function calls to take advantage of OpenCL.  In 3.0, all these functions have been unified into the same call.  The underlying OpenCV system will then decide if it can use OpenCL on the GPU or not.

Ubuntu 15.04 doesn’t have OpenCV 3.0, so we will have to get it from source.  First, lets get the dependencies going.

sudo apt-get install build-essential cmake cmake-gui python-dev python-numpy git

sudo apt-get build-dep opencv

Next, checkout out opencv from github:

git clone https://github.com/Itseez/opencv.git

cd opencv/

mkdir build

cd build/

cmake-gui ..

These commands will have brought you to the cmake gui.   click configure to make Unix-style makefiles and then make sure you click to enable python and the python examples.  After configuring, look at the output to make sure the python module was enabled.  If it wasn’t, look for clues in the output as to what was missing.

Tip: To make compiling faster and to eliminate errors, I usually turn off the opencv_java module in cmake.

type “make -j5”, get yourself a drink and maybe something to eat.  It takes a little bit to compile opencv.  After make is done, run “sudo make install” to install opencv.

Beignet

Beignet is an open source project that provides OpenCL support for Intel graphics platforms.  It supports the minnowboard max as well as Core “i” platforms.  Ubuntu 15.04 has version 1.0.1 already in the repository.  That will work wonderfully for our needs:

sudo apt-get install beignet ocl-icd-libopencl1 ocl-icd-dev

Gstreamer and Vaapi

Gstreamer is a powerful media framework that supports decoding and encoding of numerous media types.  It has a plugin framework system where you can combine several “elements” into a “pipeline”.  We will use this framework with our own customized and optimized pipeline.  Ubuntu comes with Gstreamer 1.0 by default, but we need a few extra packages for rygel and for vaapi support

sudo apt-get install libgstreamer1.0-dev gstreamer1.0-vaapi libgstreamer-plugins-base1.0-dev gstreamer1.0-tools

Test out gstreamer with vaapi support by using gst-launch-1.0:

gst-launch-1.0 videotestsrc ! vaapisink

You should see a test video image.

Rygel

Rygel is a DLNA framework for serving and rendering DLNA content.  Ubuntu has a slightly older version of rygel that doesn’t have python bindings enabled.  Further, upstream rygel does not yet have python bindings for the gstreamer renderer library.  I created a patch to be merged upstream that enables the bindings.  So for now, we’ll use my github fork until the patch is merged upstream.

git clone https://github.com/tripzero/rygel.git

Next, let’s get the build dependencies:

sudo apt-get build-dep rygel

sudo apt-get install python-gi libgirepository1.0-dev

We also need to grab mediaart 2 from github.

git clone https://github.com/GNOME/libmediaart.git

cd libmediaart

./autogen.sh –enable-introspection=yes

make -j5

sudo make install

Build Rygel:

cd rygel

./autogen.sh –enable-introspection=yes

make -j5

sudo make install

If everything compiled and installed, we can now test rygel out.  I use BubbleUPNP on my android to control DLNA renderers.  It also allows me to play content from my phone.  There are probably DLNA apps for other platforms.  Look around and find the one that’s best for you.

To run the example rygel renderer, navigate to rygel/examples/gi and run “python example-gst-renderer.py”.  Note that you may have to edit the interface which is hardcoded to “eth1” at the time of this writing to the interface on your system that has an active connection.  When I run this, I see some output on the screen about some deprecated “SOUP” calls.  This usually indicates to me that it’s working.  I can now launch up BubbleUPNP on my phone and select the “rygel gst renderer” renderer from the renderers list.

MRAA

MRAA is a library for accessing IO on various devices including the Max, RPI, Intel Edison and some others.  It has c++ and python bindings and is pretty easy to use.  It supports SPI, I2C, GPIO, PWM, and AnalogIO.

We will need to grab the source:

git clone https://github.com/intel-iot-devkit/mraa.git
sudo apt-get install swig
cd mraa
mkdir build && cd build
cmake -DBUILDSWIGNODE=OFF ..
make && sudo make install

To test, run python and enter in the following:

import mraa
mraa.getPlatformName()
quit()

This should output “MinnowBoard MAX”.  If it did.  It works!

MaxVideoRenderer – putting it all together

My source code for this project is found on github:

git clone https://github.com/tripzero/MaxVideoRenderer

cd MaxVideoRenderer

mkdir build

cd build

cmake ..

In part 3 of this project series will go into greater detail of how this system works and the discoveries I made alone the way.  For now, let’s just run it.

python videocolor.py eth0 MaxRenderer 0

This will run a DLNA renderer named “MaxRenderer” on “eth0” with “0” lights.  We don’t have any lights hooked up yet, so this should be fine.

Now we should be able to see MaxRenderer in our DLNA control app and play content to it.

Part 2 will go into setting up the LEDs.  Stay tuned!

NOTE: much of this comes from memory.  If you run into issues, drop me a comment and I may remember more of what I did to get this all going.