Hacks

How To Setup Ambilight on the Odroid-c1/c2 and Not Blow a Fuse

I’ve struggled with setting up Ambilight on the Odroid-C1 for a while. I stopped in frustration after week when I realized it was not going to work.

And now I think I have finally found the solution. But let me back up a bit.

It all started with me reading a glossy article in the Odroid magazine in April proclaiming that it is very easy to set up your own Amblight with a strip of WS2801 enabled LEDs and a few jumper wires. The setup was made on Linux but I wanted it on Android so I emailed the author of the article and he explained it should be possible to obtain the same effect on Android using a chroot.

Check out the original article here: http://magazine.odroid.com/ . Look for the April 2015 issue. I am not saying the article is not good but that there is an oversight(the damn flickering!). Follow the instructions on this article to mount your LEDs.

Done and done. Except the setup does not really work. LEDs flicker like crazy on color changes. On both Linux AND Android. After scouring the forums (odroid) for a couple of weeks I had given up. I even had to compile my own kernel module for Android because SPI is only built-in for Linux, not Android. And yet the flicker was still there messing with me, taunting me. So I gave up for a while.

In my searches I had found this article: http://www.grabthiscode.com/diy/how-to-set-up-an-ambilight-system-in-home-and-not-die-trying/

It argues that in order not to die setting up your own Ambilight (on a Raspberry Pi) you can delegate the task of lighting up the LEDs to an Arduino (aha!).

So I purchased a bunch of Arduinos. First I had a cheap one from China which turns out uses a different serial driver, the CH340 which… yep… is not compiled into the Arduino kernel for Odroid but which is in any recent kernel on desktop distros. Ooooh…kay. Then I got myself a Sparkfun redboard. To be honest I didn’t even try to connect this one to the Odroid-C1, I used it for other Arduino projects. But it should work. BTW, Teensy based boards also don’t work on the Odroid-C1. Moving on.

After the initial CH340 failure I ordered yet another Arduino from China(yup, I am cheap) but this time the supplier happily announced that his board is “original” and uses the Atmega 16U2 for serial communication. And guess what? It was not a lie! Now, I don’t know if he infringed any copyrights there nor do I care but the board does look and feel like the real deal. Aaand when hooked up to my Odroid-C1 running Android it finally shows up in /dev!!

[    1.547084@0] usbcore: registered new interface driver cdc_ether
[    1.564569@0] usbcore: registered new interface driver cdc_subset
[    1.576387@0] usbcore: registered new interface driver cdc_ncm
[    1.582317@0] usbcore: registered new interface driver cdc_acm
[    1.587896@0] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
[38113.091381@0] cdc_acm 1-1.1:1.0: ttyACM0: USB ACM device

Yes! Thank you my Aliexpress friend!

OOK. Now for the hard part. Wiring the Arduino and using the Odroid to control it.

First thing’s first:

  • Program the Arduino with the code needed to control the WS2801 LEDs:
  • Hook it up to your Odroid-C1 via USB
  • Connect the LED strip to the pins on the Arduino(NOT the Odroid!). I have the Chinese WS2801 strip and not the Adafruit one so my wires are White, Green and Blue.
    • As the blog post linked above explains this is how you wire them:
      • White -> Pin 11(clock)
      • Green -> Pin 13(data)
      • Blue -> Ground
    • I’ll add some pics later…
  • Pff… Install Linux on Android on Odroid-C1. Yup…
    • I used LinuxDeploy for that. Great chroot distrib from Russia: https://play.google.com/store/apps/details?id=ru.meefik.linuxdeploy&hl=en
    • SSH on your new Linux on Android and compile boblight.
      • I used git because SVN is so 1999: https://github.com/crazyquark/boblight/
      • Compile it with:
        • git clone https://github.com/crazyquark/boblight/
          cd boblight
          sudo apt-get install git build-essential
          ./configure --without-portaudio --without-x11 --without-libusb
          make -j 4
          sudo make install
          sudo ldconfig
        • We need no stinkin’ X for this, we are running headless, boy!
      • Compiles pretty fast on the little bucket of chips that is the Odroid-C1
    • We now need a boblight config!
      • Luckily our friend from the original Raspi post provides with a config we can just plug-in: https://www.dropbox.com/s/xy423w6kj76ldwq/boblight.conf
      •     sudo wget https://www.dropbox.com/s/xy423w6kj76ldwq/boblight.conf -O /etc/boblight.conf --no-check-certificate
      • One liner install like we like.
  • Test boblight!
    • I like to run things in ‘screen’ so that if I disconnect from SSH or whatever the program keeps running so apt-get that sucker.
    • apt-get install screen
      screen -S boblight
      sudo boblightd
      
      Output:
      (InitLog)                       start of log /root/.boblight/boblightd.log
      (PrintFlags)                    starting boblightd
      (CConfig::LoadConfigFromFile)   opening /etc/boblight.conf
      (CConfig::CheckConfig)          checking config lines
      (CConfig::CheckConfig)          config lines valid
      (CConfig::BuildConfig)          building config
      (CConfig::BuildConfig)          built config successfully
      (main)                          starting devices
      (CClientsHandler::Process)      opening listening socket on 127.0.0.1:19333
      (CDevice::Process)              ambilight: starting with output "/dev/ttyACM0"
      (CDevice::Process)              ambilight: setting up
      (CDevice::Process)              ambilight: setup succeeded
      
      
    • Boom!
  • Install Boblight XBMC(sorry, Kodi!) extension and configure it to use localhost:19333. It’s straightforward.
  • Still getting flicker!

Later edit: This article was actually written around 2 years ago. I actually managed to fix this by using the FastLED library on Arduino but I seem to have misplaced the code. The above setup however still holds, you need an Arduino to control the LEDs as the SPI clock on the Odroid is not fast enough(or it’s too fast?).

You can nowadays find examples all over on how to use the FastLED library with Boblight and Hyperion. Probably this works: https://github.com/RanzQ/serial-fastled

Or maybe this: https://github.com/dmadison/Adalight-FastLED

I haven’t tested it yet as I have gotten a fresh LED strip now.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.