Want to build your own completely flexible and customisable, yet small and energy efficient home Media System? This is not a simple media server or NAS (Network Attached Storage), although it does that too. It is everything your run-of-the mill Linux server can do (routing? firewall? NAT? VPN? No problem!) plus a built-in Arduino!  I’ve recently completed and uploaded to GitHub the complete code for this project along with a few Linux scripts. This has freed up some of my time so that I can write part 2 of this project (part 1 can be found here). Welcome back!

    In this post we will cover:

    1. Computer hardware build and cabling
    2. Arduino circuit board build and wiring
    3. Linux OS installation
    4. Linux configuration
    5. Linux software installation

Hardware Build and Cabling

4 1 2
(Note pictured. You will need HDMI cable, keyboard and monitor for initial installation).

Parts needed to build this project are pictured above (part numbers needed for the electronics are listed below). The only cable which you will need to build yourself at this point is the SATA Power Cable. This requires 12v, 5v and Ground wires. [Note: If you are using a 2.5″ SATA disk (ie. the disks used in laptops) you only need a 5V and Ground]. Just grab yourself any spare SATA-to-Molex power cable you have lying around (these usually come with motherboards and sometimes disk or CD/DVD drives. Otherwise, they are cheap to buy from any computer store or online) and cut off the Molex end. You will then be left with the SATA plug with four wires coming out of it, as below.


If your cable comes with a fifth wire (usually grey or orange coloured) you can cut this off, we don’t need to use it. Wire up the cable as you see in the diagram above. If you do not have a connector for the 5V plug you can pull 5V from the header pin circled in red and use the same ground as you are using for the 12V. [TIP: The pins on the UDOO should be labelled underneath the board] Once completed it is as simple as plugging in the other pieces. Once you have the pieces together, you should have something that looks similar to below. This is the hardest part of putting the hardware together.


Arduino Hardware Build

The electronics portion of this project is made up of primarily four pieces. On their own they are easy to build and test. They are:

    1. LCD screen
    2. 5V Relay for 12V fan
    3. Pushbutton
    4. Thermistor/temperature sensor

Required parts are:

  • 12V DC fan (an old CPU fan will do or this one from Little Bird)
  • 16×2 LCD screen (available at Little Bird Electronics)
  • Pushbutton
  • 10K Ohm thermistor
  • 56 Ohm resistor
  • 4.7K Ohm resistor
  • 1 Ohm resistor
  • 10K Ohm resistor
  • 2n2222 (or similar) NPN transistor
  • 1N4001 (or similar) diode
  • 5v relay switch (available at Little Bird Electronics)
  • Wire

The Arduino Due used in the Fritzing diagram is the same as the Arduino built in to the UDOO, right down to the pins and their locations.

I have used Fritzing to bring you the diagram below. Download for free.
Download the Fritzing (.fzz) file from GitHub.

Linux OS

UDOO utilises a Micro SD Card for booting. I’ve used a fast speed 32GB card. I highly recommend using 32GB or larger and be sure it is the fastest you can find (it makes a difference!). I’ve installed Linaro Ubuntu 12.04 which you can find on the UDOO download page. The actual installation of the OS is beyond the scope of this tutorial. There are plenty of instructions on how to do this at udoo.org. However, I found I needed to recompile the kernel in order to use the kernel modules needed for iptables/nat and tap/tun driver (used for the servers firewall and VPN service, respectively). A UDOO forum post explaining how to do this can be found here. Once you are successfully able to boot in to Linux you will be performing the following tasks:

        1. Install MiniDLNA
        2. Install CouchPotato
        3. Install Transmission
        4. Install OpenVPN
        5. Install Squid Proxy
        6. Configure VPN
        7. Configure firewall/NAT

This section assumes you have intermediate knowledge of Linux (well, you did compile your own kernel and get this far!). There are plenty of tutorials on how to install much of the above software so I will spare you from the boredom. I will, however, give details on the many ‘gotcha’s’ I encountered along with additional required configuration.

Install MiniDLNA, CouchPotato, Transmission, OpenVPN, Squidproxy

While it is outside the scope of this post to give instructions on how to install the softwares, you will need to ensure that the softwares starts at boot and you have access to the PID file for the process so that we can alert the Arduino when a process starts and/or fails. There is some great information on using upstart to get your processes to start at boot. The configuration files usually allows you to also specify a PID file location. Below is an example of one of my upstart .conf files you could use as a template.

# MiniDLNA launcher. Made by Eddy March 2014
# See related Evernote note for more information
# www.makeitbreakitfixit.com

description "MiniDLNA is a DLNA server"
author "Eddy <makeitbreakitfixit@enail.com.au>"

# Stanzas
# Stanzas control when and how a process is started and stopped
# See a list of stanzas here:
# http://upstart.ubuntu.com/wiki/Stanzas#respawn

# When to start the service. My default runlevel is 3
start on runlevel [2345]

# When to stop the service
stop on runlevel [016]

# Automatically restart process if crashed
# respawn # (no arguments after 'respawn' will use
          # the default of 10 times within 5 seconds)
respawn 15 5

# Essentially lets upstart know the process will
# detach itself to the background
expect fork

# Run after process
post-start script
    /root/bin/arduino_serial.sh "Started MiniDLNA"
        # This doesnt seem to work. I suspect it is because
        # at this point of boot process Arduino is not ready.
        # So I will use a different cron script
end script

# Start the process
# This will run the process like you normally would
exec /etc/init.d/minidlna start

I can then use a cron script to look for the PID. If the PID file is missing or the PID is not present in the process list, then I run another script to send a message to Arduino (more on this later). As I mentioned in PART 1 of this series, I will not go in to detail about the VPN/Proxy/Routing configuration I have as I have explained it in full details in a previous post, which you may want to check out if you are unable to get certain internet TV in your country (eg. Netflix in Australia).

Click here to continue to the next part of the tutorial [Linux to Arduino comms]