Pi Zero media server for car journeys

I’ve used a Zero running Jessie Lite to make a media server - for the purpose of streaming movies to my kids’ Android tablets on long car journeys. It’s powered by a USB battery pack.

I’ve used a Pimoroni USB hub (the white one with 3 USB ports and an ethernet jack at the end) hosting a USB memory stick and an Edimax 7811 wifi adapter. I used this reference to help: http://www.daveconroy.com/turn-your-raspberry-pi-into-a-wifi-hotspot-with-edimax-nano-usb-ew-7811un-rtl8188cus-chipset/.

The Pi runs
hostapd to create a wireless network
isc-dhcp-server to offer a DHCP service
minidlna to offer a media streaming service

It works fine - and can even stream two MP4 movies simultaneously. I’ve added a reset button onto the RUN points on the board. I’d like to add a soft shutdown button but haven’t spent enough time understanding GPIOs to make that work yet.

1 Like

This may help with the software shutdown.

1 Like

Thanks Richard, much appreciated.

while there’s nothing wrong with the python script in the link above I would suggest taking advantage of gpiozero, not mentioning subprocess is probably the recommended method to integrate shell commands in Python at this point.

Something like this should be working, YMMV:

from subprocess import call
from gpiozero import Button

my_button = Button(26)
my_button.wait.for.press()
print("Shutting system down")
call("sudo poweroff", shell=True)

… the code above uses BCM26, so you’d wire the button to the pins parallel to the RUN pins, like so:

1 Like

just noted you use Jessie Lite and I can’t remember if gpiozero is installed by default, so:

sudo apt-get update
sudo apt-get install python-gpiozero python3-gpiozero

and the doc: https://gpiozero.readthedocs.org

Is there anyway to use this code for Pi Zero W?

I don’t own a Zero W so don’t really know. But I don’t see why not. And with the onboard wifi you wouldn’t need the hub or network adapter either.

But, the tutorial says that you will need the wifi adapter or it will not work. What steps can I skip?

And, also, can you give another tutorial link for pi zero w