Travel Media System

General Description:

I have digital backups of all the DVDs I own and I have used a Raspberry Pi DLNA server for years to stream them to devices throughout my home. I also like to take them with me when I travel so I can watch them on my laptop.

Travel Media System Version 1:

We bought a 15 passenger van and I added a 22″ monitor so the passengers could watch TV on long road trips. I built a Raspberry Pi Kodi video playback device that read from a USB stick and played video over HDMI to the TV and audio through the headphone jack to the van’s audio system. I used a wireless keyboard to control everything.

The first setup worked well until the USB stick got corrupted at the beginning of a long trip and I had to connect my chromebook to the TV and use by cell phone as a hotspot to stream Netflix to the TV. I have an unlimited cellular data plan so it wasn’t expensive and I was surprised how well it worked.

Travel Media System Version 2:

I decided I wanted to add digital streaming of Netflix, Disney Plus, Amazon Video, Spotify, and other services to my setup. I wanted anyone in the van to be able to cast to the TV using Spotify Connect, Apple Airplay, and Google Cast.

I went back to the drawing board to design a system that provided this additional functionality. The new system would need to provide:

  • A Local Area Network (LAN) to connect all the devices in the vehicle.
  • A DLNA server to host the digital DVD backups.
  • A DLNA client device.
  • A Spotify Connect device or a spotify client.
  • A Netflix Client
  • An Amazon Prime Video client.
  • Ability to connect to either:
    • a wireless hotspot (cellular phone) for Internet access.
    • my home or a hotel Ethernet for Internet access.

Key Findings:

  1. The Raspberry Pi makes an excellent Spotify connect device but I made several attempts at using it as a DLNA client. I could get Netflix to work but I couldn’t get Amazon Prime Video to work. Raspberry Pi devices don’t seem to be considered trusted devices by the streaming services. I finally decided that on off-the-shelf solution, like a Roku, would be preferable.
  2. I wanted to use an SSD drive to store videos but they typically require USB 3.0 interfaces. That meant I needed to use a Raspberry Pi 4.
  3. I tried to use a USB WiFi dongle as the LAN or the WAN side connection and I never could get it to work. I think it may have been the particular WiFi dongle I was using but I was able to get an Ethernet to WiFi bridge to work. This had the added advantage of separating the WiFi antennas by about 12 inches and it allowed me to connect the device to either WiFi or Ethernet without reprogramming anything.

Roughing out the design:

  • Pi serves as a LAN/WAN router and DLNA server Internal WiFi is used for LAN connections.
    • Internal Ethernet port is used for WAN connections.
    • Vonets bridge is used to connect to the internet via wireless when Ethernet connectivity is not available.
  • Pi hostname is TravelRouter
  • Pi WiFi will be called TravelHotspot

Building the System:

Hardware:

Collect the hardware and install the raspberry pi board into the heatsink case. The heatsink case does a great job of keeping the pi cool without adding a lot of bulk and weight.

  • Raspberry Pi 4 (2GB) $35
  • Vonets VAP11G-300 Wireless Portable Wifi Repeater $20
  • Micro SD Card (I used 32GB) $5
  • Samsung T5 Portable SSD – 500GB – USB 3.1 External SSD $95
  • Argon NEO Raspberry Pi 4 Model B Heatsink Case $15
  • USB C Power Supply or portable phone charger:
    • I use a Miady 26800mAh PD Portable Charger Power Bank with 30W USB C Output for Nintendo Switch, Type C Laptops and Smartphones Power Delivery Support.
    • RAVPower also makes really good portable phone chargers.
  • microHDMI to HDMI adapter cable $8

Software:

  1. On your Windows laptop, download:
    1. PuTTY (ssh client)
    2. RealVNC VNC Viewer
    3. SD Card Formatter (Tuxera, Inc.)
    4. Balena Etcher
  2. Use SD Card Formatter to format the SD card.
  3. Use Balnea Etcher to flash an SD card with Raspbian Buster (from https://www.raspberrypi.org/downloads/raspbian/)
  4. Pull the SD card out of your PC and re-insert it.
  5. Ignore the prompts about needing to format the SD card.
  6. Add an empty text file to the boot sector of the SD card.
  7. Rename the file to ssh (with no extension).
  8. Place the SD card in the Raspberry Pi, attach it to your home network with an Ethernet Cable, and plug in a power supply and wait for it to boot (the led light on the Pi will stop flashing and stay steady green).
  9. Use your Windows laptop and PuTTY to ssh to raspberrypi.local
    1. login: pi
    2. password: raspberry
  10. sudo apt-get update
  11. sudo apt-get dist-upgrade

Get dnsmasq and hostapd

  1. sudo apt-get install dnsmasq hostapd
  2. sudo raspi-config to set localization and boot options and turn on VNC Network Options -> Hostname -> “TravelRouter”
    1. Boot Options -> Desktop / CLI -> Desktop Autologin
    2. Localisation Options -> Change Locale
      1. Use spacebar to remove asterisk from en_GB.UTF-8 UTF-8
      2. Use spacebar to add asterisk to en_US.UTF-8 UTF-8
      3. Tab to select OK
      4. Select Default Locale en_US.UTF-8
    1. Localisation Options -> Change Timezone
    2. Localisation Options -> Change WiFi Country to United States
    3. Interfacing Options -> VNC
      1. Yes to turn on
    4. Advanced Options -> Expand File System
    5. Advanced Options -> Resolution -> 1024 x 768 (for VNC to work without a physical screen).
    6. Update
    7. Finish
  3. sudo reboot (note, you may have to unplug the power cable and plug it back in to get a reboot at this point. )
  4. Open RealVNC Viewer.
  5. VNC into TravelRouter.local
  6. Turn off Bluetooth (we aren’t going to use it)
  7. Follow the on-screen update prompts to configure and update the system.
  8. Reboot

Get a pre-written routing script:

After the raspberry pi reboots, the VNC screen should appear. If not, close the VNC Viewer and reopen it to attach to TravelRouter.local.

Open a command window on the raspberry pi and enter the following:

curl -O https://raw.githubusercontent.com/arpitjindal97/raspbian-recipes/master/eth-to-wifi-route.sh

sudo nano to tweak the variables to represent your own hotspot name, etc.

sudo nano /home/pi/eth-to-wifi-route.sh

Change the section below to create your own WiFi Network”

ip_address="192.168.2.1" 
netmask="255.255.255.0"
dhcp_range_start="192.168.2.2"
dhcp_range_end="192.168.2.100"
dhcp_time="12h"
eth="eth0"
wlan="wlan0"
ssid="Raspberry-Hotspot" #I changed this to TravelHotspot
psk="raspberry" #I changed this to a WiFi password I'd remember

Press CTRL-X followed by the letter Y to save and exit the editor.

Make the file executable:

chmod 755 eth-to-wifi-route.sh

Running the routing script at startup

There are various ways to make scripts run at startup but some are deprecated so we can’t be assured they will keep running after an update and others are complicated to set up. Cron should be around for a long time and we can create an entry in cron to start at boot using the @reboot identifier.

I like to create a bash script in the /home/pi directory that will run whatever I want at boot then call it from cron.

Create an executable file called startup.sh in the /home/pi directory:

touch /home/pi/startup.sh
sudo chmod 755 /home/pi/startup.sh

Create a cron entry:

crontab -e

if this is the first time you run crontab, select your favorite editor.

Go to the bottom of the file and add:

@reboot /home/pi/startup.sh > startup.log &

Save the file.

Check your cron entries with:

 crontab -l

We now need add entries to out /home/pi/startup.sh file to start the routing software at boot.

sudo nano /home/pi/startup.sh

Enter the following line in the /home/pi/startup.sh file

sudo bash /home/pi/eth-to-wifi-route.sh

Press CTRL-X followed by the letter Y to save and exit the editor.

Reboot (from the pi menu) and verify that the wifi hotspot you set up in earlier is advertising a wireless network. Just use any wireless device and see if the network is available and if you can connect to it.

Setting up the DLNA Server:

I used Windows to set up my SSD drive so I need to set up Raspbian to be able to read ExFAT formatted drives.

sudo apt install exfat-fuse exfat-utils

Download and install the minidlna package

sudo apt install minidlna -y

Edit the mindlna configuration file

 sudo nano /etc/minidlna.conf 

Change: media_dir=/var/lib/minidlna to the actual directory where your videos are stored. Mine is /media/pi/Samsung_T5/Videos. NOTE: If you use a physical hard drive instead of an SSD drive, you will need to mount the drive (google this).

Since this is a Video only server, add a V, to the beginning of the media_dir value:

media_dir=V,/media/pi/Samsung_T5/Videos

Remove the comment (pound sign) from: #friendly_name= and add a name for your DLNA server. I used TravelVideoServer

friendly_name=TravelVideoServer

Go to the section that says:

Use a different container as the root of the directory tree presented to clients. The possible values are:
* "." - standard container
* "B" - "Browse Directory"
* "M" - "Music"* "P" - "Pictures"
* "V" - "Video"
* Or, you can specify the ObjectID of your desired root container(eg. 1$F for Music/Playlists)
If you specify "B" and the client device is audio-only then "Music/Folders"will be used as root.

Change it to:

root_container=B

Press CTRL-X followed by the letter Y to save and exit the editor.

I had trouble with minidlna finding video files on my portable SSD drive until I changed the following:

 sudo nano /etc/default/minidlna

Configure the following section to read:

User and group daemon shoudll run as 
USER="root"
GROUP="root"

Press CTRL-X followed by the letter Y to save and exit the editor.

Run the server for the first time to verify it is working with:

 sudo service minidlna restart && sudo service minidlna force-reload

Finally, since we are using an external drive, it may take some time to load so we need to ask the DLNA server to reload a few seconds after the system boots. We can do this by adding a line to the /home/pi/startup.sh we created earlier.

sudo nano /home/pi/startup.sh

Add the following two lines at the end:

sleep 10
sudo service minidlna force-reload

You can also validate minidlna status with a web browser:

http://travelrouter:8200/

At this point, you have a working DLNA server that can also be used as a wireless hotspot to a wired Ethernet connection.

Adding WiFi to WiFi routing capability:

Having a WiFi to Ethernet bridge is useful at home or at a hotel that provides Ethernet connectivity. At other locations, we need to provide internet access via a cellular hotspot. The easiest way to accomplish this is by adding an external WiFi to Ethernet Bridge. I used a Vonets VAP11G-300 Wireless Portable WiFi Repeater ($19 on Amazon).

Configuring the Vonets bridge:

  1. Plug the Vonets USB connector into the raspberry pi. Leave the Ethernet Cable disconnected
  2. If you don’t see an available Vonets WiFi network, press the reset button on the Vonets bridge
  3. Attach to the Vonets Wifi
  4. Navigate to http://vonets.cfg and log in as admin/admin
  5. Set up the wifi connection using the web interface

Connecting the Travel Router to a television via HDMI:

You can also watch videos and surf the Internet by connecting the Travel Router to a television via an microHDMI to HDMI adapter cable. When connecting to 4K monitors, it is probably better to lower the resolution. To prevent the pi from using the resolution set by the monitor, we need to edit the /boot/config.txt file and set the hdmi_safe parameter to 1.

hdmi_safe=1   

I also removed the comments from the arm_freq line to overclock the GPU.

arm_freq=800

If it isn’t already installed, you should also load a video view like VLC Viewer so you can play videos directly:

sudo apt install -y vlc

System Administration via SSH or VNC:

Travel Router Connected to Ethernet

You can access the Travel Router by connecting to the TravelRouter WiFi network connecting to 192.168.2.1.

You can access the travel router by connecting to the same Ethernet network and connecting to hostname TravelRouter.local or TravelRouter.

Travel Router Connected to Vonets Bridge

You can access the Travel Router by connecting to the TravelRouter WiFi network connecting to 192.168.2.1.

Travel Router Stand Alone

You can access the Travel Router by connecting to the TravelRouter WiFi network connecting to 192.168.2.1.

Print Friendly, PDF & Email
Published
Categorized as Guides

Leave a comment

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