Pocket-sized Raspberry Pi Zero 2 W strapped to a portable battery pack
All posts

How to Build a Pocket-Sized Raspberry Pi Zero 2 W Travel Media Server (Wi-Fi Hotspot, CIFS, DLNA & UPS Safe Shutdown)

Turn a $15 Raspberry Pi Zero 2 W into a pocket-sized, battery-powered wireless media server with a built-in Wi-Fi hotspot, CIFS/Samba shares, MiniDLNA streaming, and automated UPS safe shutdown.

You can turn a $15 Raspberry Pi Zero 2 W—or any newer Raspberry Pi 3B, 4B, or 5—into a pocket-sized, battery-powered wireless media server that streams movies, music, e-books, and documents to your family's phones, tablets, and laptops with zero internet required. If you have ever been three hours into a family road trip when cellular service drops and the kids' tablets can no longer stream shows, this gum-pack-sized device solves the problem permanently. At home, you plug the Pi into your router using a cheap USB-to-Ethernet adapter so it joins your home Local Area Network (LAN) via DHCP for fast, drag-and-drop media loading. When you pack for a trip, you unplug the Ethernet cable, flip on the battery pack, and the Pi's built-in Wi-Fi radio automatically operates as a standalone wireless router—assigning IP addresses to connected devices via DHCP and serving files over both CIFS (Samba) network shares and DLNA (minidlna) media streams.

To build a system that works reliably using the latest Raspberry Pi OS (Debian 13 "Trixie") and Raspberry Pi Imager 2.0, you need to avoid two common hardware traps. First, skip the original Raspberry Pi Zero W; its single-core 32-bit processor struggles with network file transfers (dropping to ~1.3 MB/s write speeds in user tests) and is losing modern 32-bit software support, whereas the quad-core 64-bit Raspberry Pi Zero 2 W handles multiple streams while drawing just 1 to 3 Watts of power. Second, while you can power the Pi from a standard USB powerbank for portability, multi-port consumer powerbanks frequently reset their 5V USB output whenever a second USB port is used or a charging cable is plugged in, causing instant reboots and microSD card corruption. Pairing your Pi with a native pogo-pin Uninterruptible Power Supply (UPS) HAT provides seamless pass-through power and allows an automated script to safely shut down the Pi before the battery runs dry.

Dual-Mode Network & Power Architecture Overview

Your portable server is designed to transition automatically between two operating modes without requiring you to change a single setting when you leave the house:

Dual-Mode Network & Power Architecture diagram for Pi Zero 2 W travel media server
Dual-mode architecture: wired Home LAN sync vs. standalone road-trip Wi-Fi hotspot.

Operating Mode

Physical Connections

Network & DHCP Behavior

How Your Family Uses It

Mode 1: Home LAN Setup & Fast Sync

USB-to-Ethernet adapter (eth0) plugged into your home router; wall charger plugged into the UPS HAT charging port.

Home router assigns an IP address to eth0 via DHCP (travelpi.local). Meanwhile, wlan0 broadcasts your hotspot and shares home internet to wireless clients via NAT.

Drag and drop gigabytes of movies, music, books, and PDFs from your desktop PC or Mac over wired Ethernet at up to ~30 MB/s.

Mode 2: Travel Road-Trip Hotspot

Ethernet unplugged; powered wire-free by the native pogo-pin UPS HAT (or dedicated single-port USB battery).

Built-in Wi-Fi (wlan0) runs as an Access Point at static gateway 192.168.4.1/24, using dnsmasq-base to hand out 192.168.4.x IPs via DHCP.

Up to 4+ tablets, phones, and laptops connect to your Pi's Wi-Fi to stream movies/music via DLNA or open books/docs via CIFS.

Step 1: Choosing Your Hardware (And Why the Original Pi Zero W Won't Cut It)

Before buying parts or raiding your spare electronics drawer, make sure your board is a Raspberry Pi Zero 2 W (or a Raspberry Pi 3B, 4B, or 5) and not the original 2017 Raspberry Pi Zero W.

Comparison chart of Raspberry Pi Zero 2 W vs Original Pi Zero W
Why the quad-core 64-bit Raspberry Pi Zero 2 W outperforms the original Pi Zero W.

Although the original Pi Zero W and the Pi Zero 2 W share the exact same board footprint, their performance is night and day. The original Pi Zero W relies on a single-core, 32-bit processor that bottlenecks heavily when encrypting Wi-Fi traffic and serving SMB/CIFS files simultaneously. In community benchmarks on the r/raspberry_pi forum, users testing Samba shares on an original Pi Zero W reported write speeds bogging down to ~1.3 MB/s and read speeds hovering around 4 to 5 MB/s—noting that 1 MB/s causes constant video playback stuttering. Furthermore, Raspberry Pi engineers have noted that software dependencies are dropping 32-bit (armhf) support in favor of 64-bit (aarch64) environments.

By contrast, the $15 Raspberry Pi Zero 2 W packs a quad-core, 64-bit processor (matching the CPU architecture of the Raspberry Pi 3) and 512 MB of RAM inside a 1 to 3 Watt power envelope. When running the headless Raspberry Pi OS Lite (64-bit) image without a graphical desktop, community builders report typical memory usage of around 250 MB of RAM, while tuned media server builds such as the Mini-Pi Media Server project on Hackaday have reduced idle RAM usage on the Pi Zero 2 W from ~220 MB down to ~154 MB while streaming to up to four client screens simultaneously. Community throughput tests show that while the Pi Zero 2 W's single-stream 2.4 GHz 802.11n Wi-Fi radio caps real-world wireless transfers around 3 to 4.5 MB/s (~30–45 Mbps) and its USB 2.0 bus tops out around 30 MB/s, a standard 1080p movie stream requires only a fraction of that bandwidth—making the Zero 2 W more than fast enough for family travel.

Pi Zero 2 W throughput, bus limits, and 512 MB RAM footprint chart
Real-world Wi-Fi, USB 2.0, and RAM headroom benchmarks on headless Raspberry Pi OS Lite.

Hardware Shopping List

Travel Media Server Hardware Shopping List graphic
Core hardware checklist for the pocket-sized travel media server.

Component

Recommended Spec / Model

Why You Need It

Raspberry Pi Board

Raspberry Pi Zero 2 W (or Zero 2 WH with pre-soldered GPIO header)

The $15 quad-core 64-bit brain of the server. (A Raspberry Pi 3B, 4B, or 5 also works using the exact same setup steps if you already have one at home).

MicroSD Card

64 GB to 512 GB High-Endurance MicroSD

Holds both the operating system and your media library on a single internal card with no bulky external thumb drives sticking out.

LAN Setup Adapter

Micro-USB OTG to Ethernet Adapter (or standard USB Ethernet + Micro-USB OTG adapter)

Connects the Pi Zero 2 W (eth0) to your home router via DHCP for initial headless setup and fast home file transfers.

Portable Power (Best)

Native Pi Zero UPS HAT (PiSugar 3, Waveshare UPS HAT C, or Geekworm X306 V1.5)

Attaches directly to the back of the Pi via solderless spring-loaded pogo pins, preventing USB powerbank reset crashes.

SD Card Reader

USB MicroSD Card Reader

Plugs into your Windows PC, Mac, or Linux machine to write the operating system image.

Step 2: Flashing the SD Card with Raspberry Pi Imager 2.0

Recent updates to the Raspberry Pi ecosystem introduced Raspberry Pi OS based on Debian 13 ("Trixie") alongside a completely redesigned Raspberry Pi Imager 2.0 (v2.0.12). If you have seen older tutorials that tell you to press Ctrl+Shift+X or click a gear icon to set up your username and SSH, note that Imager 2.0 removed the old gear icon in November 2025 and replaced it with a guided, six-part Customisation wizard built directly into the left-hand menu.

Follow this sequence to flash your microSD card:

  1. Download and Launch Imager 2.0: Download Raspberry Pi Imager from the official software page (raspberrypi.com/software), install it on your Windows, macOS, or Linux computer, and insert your microSD card into your card reader.
  2. Select Device: In the left-hand wizard sidebar, click Device and choose Raspberry Pi Zero 2 W (or your specific Pi 3, 4, or 5 model).
  3. Select OS: Click OS, open Raspberry Pi OS (other), and choose Raspberry Pi OS Lite (64-bit) (the Debian Trixie port with no desktop environment). Running the headless Lite edition avoids wasting memory on a graphical desktop you will never see.
  4. Select Storage: Click Storage and pick your microSD card, keeping Exclude system drives checked so you cannot accidentally overwrite your computer's hard drive.
  5. Complete the Customisation Wizard: Clicking next opens the Customisation tab, which guides you through six sub-screens using the Next button (detailed in the table below).
  6. Review Summary and Write: After finishing the six customisation sub-steps, review the Summary screen, click Write, and confirm the overwrite prompt. Imager will download, write, and verify the image in about 3 to 10 minutes before reaching the Done tab.

Imager 2.0 Customisation Wizard Settings

Configure the six sub-tabs inside Step 5 (Customisation) exactly as follows:

Raspberry Pi Imager 2.0 Customisation Wizard Settings infographic
The six Customisation wizard steps in Raspberry Pi Imager 2.0.

Imager 2.0 Sub-Tab

Setting to Enter

Why This Matters for Your Travel Server

1. Hostname

travelpi

Lets you connect to your Pi at travelpi.local on your home network without looking up its IP address.

2. Localisation

Select your capital city / country

Automatically sets your time zone, keyboard layout, and Wireless Regulatory Domain—which is mandatory so the Pi's Wi-Fi transmitter is legally unlocked to broadcast a hotspot.

3. User

Username: dad (or your choice) + Password

Creates your administrator login. Raspberry Pi OS no longer uses the old default pi account.

4. Wi-Fi

Leave Blank / Do Not Configure

Because a single Wi-Fi radio (wlan0) cannot connect to your home router and broadcast a travel hotspot at the same time, leave client Wi-Fi blank. Your USB-to-Ethernet adapter will handle the home connection.

5. Remote Access

Toggle Enable SSH ON → Password authentication

Allows you to log in and copy-paste setup commands from your PC or Mac over the network.

6. Raspberry Pi Connect

Skip / Leave Off

Optional cloud browser sharing; not needed for an offline portable server.

Troubleshooting Note on Imager 2.0 & Windows Card Readers: Users on the Raspberry Pi Forums testing Imager 2.0.4 through 2.0.6 reported two minor quirks worth keeping in mind. First, on Windows 10 and 11, some USB 3.0 card readers play a connection chime when re-inserting a card but do not mount bootfs in File Explorer unless a drive letter is manually added in Windows Disk Management—which you can safely ignore since we don't need to edit files on the card manually. Second, a Linux user reported that an Imager 2.0.4 Lite installation occasionally prompted for a username on first boot despite specifying it in the wizard; if ssh dad@travelpi.local ever refuses your password on first boot, updating to the latest Imager 2.0.12 release or plugging in a temporary monitor/keyboard resolves it.

Step 3: First Boot Over Home LAN (USB-to-Ethernet)

Now connect your hardware for its first boot on your home network:

  1. Insert the flashed microSD card into the Raspberry Pi Zero 2 W.
  2. Plug your USB-to-Ethernet adapter into the USB / DATA micro-USB port on the Pi Zero 2 W (the port closer to the center of the board) and connect an Ethernet cable from the adapter to a LAN port on your home router.
  3. Connect a 5V micro-USB power supply to the outer PWR IN micro-USB port (or power it via your attached UPS HAT's USB charging port).

Wait 60 to 90 seconds on the very first boot. In Raspberry Pi OS Trixie, Imager 2.0 uses cloud-init and Netplan on first boot to apply your user account, generate SSH keys, and request a local IP address from your home router's DHCP server over Ethernet.

Open PowerShell / Command Prompt on Windows or Terminal on macOS and log into your Pi over your home LAN:

ssh dad@travelpi.local
(Replace dad with your chosen username, type yes to accept the SSH fingerprint, and enter your password.)

Once logged in, update your Debian Trixie system packages so you have the latest kernel and NetworkManager fixes:

sudo apt update && sudo apt full-upgrade -y

Step 4: Setting Up the Travel Wi-Fi Hotspot (The Trixie nmcli Way)

Older Raspberry Pi hotspot tutorials required manually installing and wiring together dhcpcd, hostapd, dnsmasq, and iptables. In Raspberry Pi OS Trixie (and Bookworm), NetworkManager (nmcli) handles the entire Wi-Fi router, DHCP server, and DNS setup natively in a single connection profile.

Why We Use NAT Hotspot Mode (ipv4.method shared) Instead of Bridge Mode

NetworkManager supports two main ways to create a wireless access point: Bridge Mode (br0) and NAT Hotspot Mode (ipv4.method shared). For a home-and-travel server, NAT Hotspot Mode is essential:

NetworkManager Hotspot: Bridge Mode vs NAT Shared Mode diagram
Why NAT Shared Mode (ipv4.method shared) works cable-free on road trips.

Feature

Bridge Mode (br0)

NAT Hotspot Mode (ipv4.method shared) — Our Choice

DHCP IP Assignment

Relies entirely on your home router to hand out IP addresses.

The Pi runs its own DHCP & DNS server (automatically invoking dnsmasq-base) to assign IPs to phones and tablets.

Standalone Travel Use

Fails without an Ethernet cable. Requires a router attached to work.

Works 100% cable-free on the road as a self-contained network (192.168.4.1), while also forwarding home LAN/internet traffic when Ethernet is plugged in at home.

The Trixie WPA2 Security Fix (Preventing Wi-Fi Dropouts)

Forum members testing hotspots on Raspberry Pi OS Trixie in 2026 discovered an important change: if you use basic Bookworm hotspot commands without explicit cipher definitions, the Wi-Fi network broadcasts, but phones and tablets either fail to connect or suffer unstable dropouts. Explicitly setting the security protocol to RSN (WPA2) and the encryption cipher to CCMP (AES) (wifi-sec.proto rsn and wifi-sec.pairwise ccmp) completely eliminates Trixie Wi-Fi instability.

First, confirm that dnsmasq-base is installed (NetworkManager uses it under the hood to serve DHCP addresses) and check that your wireless interface is named wlan0:

sudo apt install -y dnsmasq-base
nmcli device
Next, run the following commands to create your auto-starting travel hotspot profile (feel free to change "RoadTripMedia" and "FamilyPass2026!" to your preferred Wi-Fi name and password):
# 1. Remove any existing hotspot connection with the same name
sudo nmcli connection delete "TravelHotspot" 2>/dev/null

# 2. Create the Access Point profile on wlan0 and set it to auto-start on boot
sudo nmcli connection add type wifi ifname wlan0 con-name "TravelHotspot" \
  802-11-wireless.mode ap ssid "RoadTripMedia" \
  connection.autoconnect yes connection.autoconnect-priority 10

# 3. Lock in WPA2-RSN and CCMP encryption for rock-solid Trixie client stability
sudo nmcli connection modify "TravelHotspot" \
  wifi-sec.key-mgmt wpa-psk \
  wifi-sec.proto rsn \
  wifi-sec.pairwise ccmp \
  wifi-sec.group ccmp \
  wifi-sec.psk "FamilyPass2026!"

# 4. Set to 2.4 GHz (802.11b/g/n) Channel 6
sudo nmcli connection modify "TravelHotspot" \
  802-11-wireless.band bg 802-11-wireless.channel 6

# 5. Enable built-in DHCP/NAT ('shared') and assign static gateway IP 192.168.4.1
sudo nmcli connection modify "TravelHotspot" \
  ipv4.method shared ipv4.addresses 192.168.4.1/24 ipv6.method disabled

# 6. Optional (Trixie / NetworkManager 1.52+): Define a clean DHCP IP range for clients
sudo nmcli connection modify "TravelHotspot" \
  ipv4.shared-dhcp-range "192.168.4.50,192.168.4.100"

# 7. Activate the Wi-Fi hotspot immediately
sudo nmcli connection up "TravelHotspot"

(Note: If you build this on a Raspberry Pi 4 or 5 and prefer a faster 5 GHz hotspot instead of 2.4 GHz, you can run sudo nmcli connection modify "TravelHotspot" 802-11-wireless.band a 802-11-wireless.channel 36 followed by sudo nmcli connection up "TravelHotspot"—keep 2.4 GHz bg for the Pi Zero 2 W, as its radio is 2.4 GHz only).

Test your hotspot right now: Pull out your phone, connect to RoadTripMedia, and verify that it receives an IP address in the 192.168.4.x range. Because your Ethernet adapter (eth0) is plugged into your home router, NetworkManager's ipv4.method shared mode automatically routes your phone's traffic out to your home LAN and the internet while also giving you local access to the Pi at 192.168.4.1!

Step 5: Setting Up CIFS (Samba) Shares for Videos, Music, Books & Documents

To let your family copy files onto the Pi from Windows or macOS—and to let iPads, iPhones, Android tablets, and laptops browse Videos, Music, Books, and Documents over the network—we will set up a CIFS / Samba network file share.

Avoiding the Bookworm/Trixie Home Directory Permissions Trap

When checking Raspberry Pi Forums and Reddit threads where builders troubleshooted Samba and MiniDLNA setups, the single most common failure happens when users place their media folders inside their personal home directory (/home/dad/...).

In older Debian releases (Bullseye and earlier), user home folders defaulted to 755 (rwxr-xr-x) permissions, allowing any background service to read inside them. In Bookworm and Trixie, home folder permissions are restricted by default, and systemd's service sandboxing (ProtectHome) blocks background daemons like minidlna from accessing /home. Rather than opening up permissions on your private home directory (chmod +rx /home/dad) or overriding systemd security files, placing your shared media vault in /srv/media ensures both Samba (CIFS) and MiniDLNA have clean, uninterrupted access from day one.

Run these commands to create your four media folders (Videos, Music, Books, and Documents) and set group-friendly permissions:

sudo mkdir -p /srv/media/{Videos,Music,Books,Documents}
sudo chown -R $USER:$USER /srv/media
sudo chmod -R 775 /srv/media
Important Tip If You Add an External USB Drive Later: If you ever plug an external USB flash drive or SSD into your Pi for extra storage, format that drive as Linux ext4, NOT Windows NTFS! As verified by r/raspberry_pi community testing, Linux's non-native NTFS driver introduces heavy overhead on a Pi, bottlenecking Samba write speeds to ~1.3 MB/s, whereas formatting the drive as native ext4 immediately restores full transfer speeds. Because client devices read and write over the network via CIFS/Samba, Windows PCs, Macs, and iPads can still access an ext4 drive seamlessly.

Installing and Configuring Samba

Install the Samba server packages:

sudo apt install -y samba samba-common-bin
Open the Samba configuration file in the Nano text editor:
sudo nano /etc/samba/smb.conf
Scroll to the very bottom of /etc/samba/smb.conf and add this [FamilyMedia] share block. Setting guest ok = yes and force user = dad allows family tablets to open books and documents without complex login prompts while ensuring every uploaded file is owned by your user account so MiniDLNA can read it:
[FamilyMedia]
   comment = Portable Pi Media Server (Videos, Music, Books, Documents)
   path = /srv/media
   browseable = yes
   writeable = yes
   read only = no
   guest ok = yes
   public = yes
   create mask = 0664
   directory mask = 0775
   force user = dad
(Remember to replace dad on the force user line with the username you created in Step 2!)

Save the file (Ctrl+O, Enter) and exit Nano (Ctrl+X). Next, set a Samba password for your user account (for devices that prefer authenticated SMB logins) and restart the Samba daemon:

sudo smbpasswd -a $USER
sudo systemctl restart smbd nmbd
You can now open File Explorer on Windows and enter \\travelpi.local\FamilyMedia (at home over LAN) or \\192.168.4.1\FamilyMedia (on the travel Wi-Fi), or press Cmd+K in macOS Finder and enter smb://travelpi.local/FamilyMedia (or smb://192.168.4.1/FamilyMedia). On iPhones and iPads, open the built-in Files app, tap the top-right ... menu, choose Connect to Server, and enter smb://192.168.4.1 to read PDFs and ePubs straight from the Books and Documents folders.

Step 6: Fast DLNA Setup (minidlna) for Instant Video & Music Streaming

While CIFS shares are ideal for transferring files and opening e-books or PDFs, DLNA (via minidlna / ReadyMedia) is the fastest, most kid-friendly way to stream Videos and Music. DLNA automatically indexes your movies and songs and broadcasts them over Universal Plug and Play (UPnP), so anyone on your Pi's Wi-Fi can open the free VLC app (on iPad, iPhone, Android, Fire Tablet, Windows, or Mac) and tap your server name with zero IP addresses or passwords required.

Install minidlna from the official Raspberry Pi OS repository:

sudo apt install -y minidlna
Open the MiniDLNA configuration file:
sudo nano /etc/minidlna.conf
Locate the media_dir, friendly_name, and inotify settings (or add them at the bottom of the file) so they match this configuration:
# Scan /srv/media/Videos for Video (V) and /srv/media/Music for Audio (A)
media_dir=V,/srv/media/Videos
media_dir=A,/srv/media/Music

# Server name displayed inside VLC and Smart TV media players
friendly_name=Family RoadTrip Media

# Automatically detect new files as soon as you drop them into the CIFS share
inotify=yes

# Standard HTTP port for status and media streaming
port=8200
Save (Ctrl+O, Enter) and exit (Ctrl+X).

Three Community-Verified Fixes for MiniDLNA on Raspberry Pi OS

To ensure your DLNA catalog updates reliably and never fails to start, apply these three community-verified fixes from the Raspberry Pi Forums and Arch/Debian documentation:

Common MiniDLNA Pitfall

What Causes It

The Exact Fix to Run

1. parsing error file /etc/minidlna.conf

Entering a subnet mask like listening_ip=192.168.4.1/24 crashes the parser in recent minidlna versions.

Leave #listening_ip= and #network_interface= commented out with # so MiniDLNA listens on both eth0 (Home LAN) and wlan0 (Travel Wi-Fi) automatically.

2. Permission denied reading media files

By default, the service runs as the minidlna system user, which needs read/execute access to your folders.

Add minidlna to your user group: sudo usermod -a -G $USER minidlna.

3. New files dropped in Samba don't show up

Linux's default inotify watch limit can fill up when indexing large music or movie folders.

Increase max_user_watches in /etc/sysctl.conf and force a clean database rebuild (minidlnad -R).

Run these four commands in your terminal to apply the group permissions, increase the inotify watch limit, and rebuild the media database:

sudo usermod -a -G $USER minidlna
echo "fs.inotify.max_user_watches=65536" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
sudo systemctl restart minidlna
sudo minidlnad -R && sudo systemctl restart minidlna

Verify that DLNA is working: Copy a test .mp4 video into your Videos folder over Samba, then open a web browser and visit http://192.168.4.1:8200 (or http://travelpi.local:8200). You will see MiniDLNA's built-in status page showing your exact count of indexed audio and video files. Open VLC on any phone or tablet connected to RoadTripMedia, tap Network, and select Family RoadTrip Media under UPnP to start streaming!

Step 7: Portable Power, the "USB Powerbank Trap," and Native UPS Safe Shutdown

To take your server on the road, you need battery power. While you can plug the Pi Zero 2 W's PWR IN micro-USB port into a standard USB portable battery bank, you must be careful about how consumer powerbanks behave.

Warning: Why Standard Multi-Port USB Powerbanks Crash Raspberry Pis

If you use a regular multi-port USB powerbank (the kind made for charging phones that has two or three USB outputs and a "pass-through" charging input), beware of the USB port reset behavior!

On most portable USB batteries, all ports share an internal power controller. Whenever you plug a second cable into an open USB port on the battery bank—or whenever you plug the battery bank into a car charger or wall outlet to top it up—the powerbank briefly resets its 5V output across all ports to renegotiate USB Power Delivery (PD) and current limits. While a smartphone doesn't care if its charging cable drops to 0V for a split second, a Raspberry Pi has no onboard buffer battery: that brief 5V reset acts like yanking the power cord out of the wall, immediately crashing your movie stream, rebooting the Pi, and risking microSD card filesystem corruption.

If you use a standard USB powerbank, dedicate a single-port battery exclusively to the Pi, never plug another device or charger into that powerbank while the Pi is running, and always run sudo shutdown -h now before unplugging it.

Standard USB Powerbank reset crash vs Native Pi Zero UPS HAT diagram
How native pogo-pin UPS HATs prevent 5V USB powerbank reset crashes.

The Recommended Upgrade: Native Pogo-Pin UPS HATs for Pi Zero 2 W

For a much cleaner, crash-proof build, get a native Uninterruptible Power Supply (UPS) HAT designed specifically for the Raspberry Pi Zero footprint. These boards mount directly underneath the Pi Zero 2 W using four screws and deliver 5V power through spring-loaded pogo pins pressing against the underside pads of the Pi—meaning no loose USB power cables and no soldering (unless using a Waveshare HAT on a board without header pins). Because they include dedicated recharge and boost chips, you can plug and unplug external 5V power at any time without resetting the Pi.

Here is how the three leading Pi Zero 2 W UPS boards compare:

Pi Zero 2 W Native UPS HAT Comparison: PiSugar 3, Waveshare UPS HAT C, and Geekworm X306 V1.5
Comparing the three leading pogo-pin UPS HATs for the Raspberry Pi Zero 2 W.

(Crucial Hardware Rule: Always plug your wall or car charging cable into the USB charging port on the UPS board itself, never into the Raspberry Pi Zero 2 W's micro-USB port, so the UPS can charge the battery and manage the power path properly!)

Configuring the Automated Safe-Shutdown Script

If you choose the PiSugar 3 / 2 or the Waveshare UPS HAT (C), you can set up an automatic background watchdog that monitors battery health over the I2C bus and runs a clean Linux shutdown before the battery dies.

First, enable the Raspberry Pi's I2C interface and install the required Python and I2C tools:

# Enable I2C interface in Raspberry Pi configuration and install smbus tools
sudo raspi-config nonint do_i2c 0
sudo apt install -y i2c-tools python3-smbus netcat-openbsd
sudo reboot
(Wait 60 seconds after rebooting, then reconnect via SSH.)

Option A: Automated Safe Shutdown for PiSugar 3 / PiSugar 2

PiSugar provides an official installation script (pisugar-power-manager.sh) that installs pisugar-server and pisugar-poweroff (which their engineering team tests directly against Raspberry Pi OS Trixie ARM64). Run these commands to install it:

wget -O pisugar-power-manager.sh https://cdn.pisugar.com/release/pisugar-power-manager.sh
sudo bash pisugar-power-manager.sh -c release
When the interactive prompt appears, select your hardware model (such as PiSugar 3 or PiSugar 2 (2-LEDs)). Once installed, you can visit http://192.168.4.1:8421 in any browser to view battery percentage and configure settings, or run these four commands to automatically trigger a safe shutdown at 5% battery (with a 30-second delay) and allow a long-press of the PiSugar button to cleanly shut down the Pi:
echo "set_safe_shutdown_level 5" | nc -q 0 127.0.0.1 8423
echo "set_safe_shutdown_delay 30" | nc -q 0 127.0.0.1 8423
echo "set_button_enable long 1" | nc -q 0 127.0.0.1 8423
echo "set_button_shell long sudo shutdown now" | nc -q 0 127.0.0.1 8423
Option B: Custom Python Safe-Shutdown Service for Waveshare UPS HAT (C)

The Waveshare UPS HAT (C) includes an onboard INA219 voltage and current monitor chip at I2C address 0x43. While Waveshare provides a downloadable demo archive (UPS_HAT_C.7z containing INA219.py) that prints voltage, current, and capacity percentage to the screen, their official wiki does not include an automatic shutdown daemon.

First, verify that your Pi detects the Waveshare INA219 chip at address 43 on I2C bus 1:

sudo i2cdetect -y 1
(Note: If ls -la /dev/ | grep i2c on your specific setup shows i2c-0 instead of i2c-1, change I2C_BUS = 1 to 0 in the script below; similarly, if you ever use a virtual environment without python3-smbus, you can install smbus2).

Now create a lightweight Python daemon that polls the Waveshare INA219 sensor every 20 seconds and executes sudo shutdown -h now when the battery voltage drops below 3.40V (for a 3.7V Li-Po cell whose full charge is ~4.2V) for three consecutive readings:

sudo nano /usr/local/bin/waveshare-ups-shutdown.py
Paste the following script:
#!/usr/bin/env python3
import smbus
import time
import os

# Waveshare UPS HAT (C) INA219 sensor sits at I2C address 0x43 on Bus 1
I2C_BUS = 1
INA219_ADDR = 0x43
REG_BUSVOLTAGE = 0x02

# Shutdown threshold: 3.40V on a 3.7V nominal (4.2V max) Li-Po battery
LOW_VOLTAGE_THRESHOLD = 3.40
MAX_STRIKES = 3

bus = smbus.SMBus(I2C_BUS)

def get_battery_voltage():
    raw_word = bus.read_word_data(INA219_ADDR, REG_BUSVOLTAGE)
    # INA219 returns big-endian word; swap bytes, shift right 3 bits, multiply by 4mV LSB
    swapped = ((raw_word << 8) & 0xFF00) + (raw_word >> 8)
    return (swapped >> 3) * 0.004

def main():
    strikes = 0
    while True:
        try:
            voltage = get_battery_voltage()
            if 2.0 < voltage < LOW_VOLTAGE_THRESHOLD:
                strikes += 1
                print(f"Low battery warning: {voltage:.2f}V (strike {strikes}/{MAX_STRIKES})")
                if strikes >= MAX_STRIKES:
                    print("Battery critical! Running safe shutdown...")
                    os.system("sudo shutdown -h now")
                    break
            else:
                strikes = 0
        except Exception as err:
            print(f"INA219 I2C read error: {err}")
        time.sleep(20)

if __name__ == "__main__":
    main()
Save (Ctrl+O, Enter) and exit (Ctrl+X). Make the script executable and register it as a systemd service so it runs automatically in the background on every boot:
sudo chmod +x /usr/local/bin/waveshare-ups-shutdown.py

sudo tee /etc/systemd/system/waveshare-ups.service > /dev/null << 'EOF'
[Unit]
Description=Waveshare UPS HAT (C) INA219 Auto Safe Shutdown Service
After=multi-user.target

[Service]
Type=simple
ExecStart=/usr/bin/python3 /usr/local/bin/waveshare-ups-shutdown.py
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now waveshare-ups.service
(Helpful operational note from Waveshare UPS HAT C owners: once the Pi Zero 2 W completes a software shutdown, simply toggle the physical ON/OFF switch on the UPS HAT off and back on when you want to boot the Pi again!)

Step 8: Family Quick-Reference Card (Keep This in the Glovebox!)

Your portable Raspberry Pi Zero 2 W media server is completely finished and automated. Here is a quick-reference cheat sheet for connecting devices at home and on the road:

Family RoadTrip Media Quick-Reference Card
Quick-reference cheat sheet for connecting phones, tablets, and laptops.

What You Want to Do

Where to Go / What to Enter

Quick Tips

Join the Travel Wi-Fi

SSID: RoadTripMedia
Password: FamilyPass2026!

Automatically assigns 192.168.4.50–100 IPs to tablets and phones via DHCP.

Stream Movies & Music (Phones, Tablets, Laptops)

Open VLC Media Player → Network → UPnP → Family RoadTrip Media

Zero login needed; streams directly from /srv/media/Videos and /srv/media/Music.

Open Books & Documents (iPad / iPhone / Android)

Open Files App → Connect to Server → smb://192.168.4.1

Connect as Guest (or dad) to open PDFs and ePubs inside Books and Documents.

Load Media at Home (Windows File Explorer)

Address bar: \\travelpi.local\FamilyMedia (or \\192.168.4.1\FamilyMedia)

Plug the USB-to-Ethernet adapter into your home router for fast wired transfers.

Load Media at Home (macOS Finder)

Press Cmd+K → smb://travelpi.local/FamilyMedia

Drag and drop new files; inotify adds them to DLNA automatically.

Check DLNA Server Status

Web Browser: http://192.168.4.1:8200

Displays exact counts of indexed Videos, Songs, and connected devices.

Check PiSugar Battery UI

Web Browser: http://192.168.4.1:8421

Shows battery percentage and charging status (if using PiSugar UPS).

Manual Safe Shutdown

Hold PiSugar button (or SSH to dad@192.168.4.1 and run sudo shutdown -h now)

Wait ~15 seconds for the Pi's green activity LED to turn off before switching off hardware power.

Troubleshooting and Finding Help Online or via AI

Even when following setup steps carefully, hardware quirks or system updates can sometimes cause unexpected behavior. Knowing how to extract systemic logs and structure your queries makes resolving issues fast and straightforward.

Essential Terminal Commands for Checking System Logs

When a service fails to start or drops connections, systemd logs provide exact error messages. Use these terminal commands to inspect service statuses:

# Check live status and recent log output for key services
sudo systemctl status NetworkManager
sudo systemctl status smbd
sudo systemctl status minidlna
sudo systemctl status waveshare-ups.service

# View real-time streaming logs for specific daemons
sudo journalctl -u minidlna -f
sudo journalctl -u smbd -n 50
sudo journalctl -u NetworkManager --since "10 minutes ago"
Leveraging AI Assistants and Online Forums Effectively

If log commands uncover errors you aren't sure how to fix, AI assistants (such as Google Gemini, ChatGPT, or Claude) and community forums (Raspberry Pi Forums, Reddit r/raspberry_pi, r/homelab) can troubleshoot your specific setup when given proper context.

  1. Include Hardware & OS Specs: Always specify that you are running Raspberry Pi OS Lite (Debian 13 "Trixie") on a Raspberry Pi Zero 2 W. Networking in Trixie uses NetworkManager (nmcli), which differs significantly from older dhcpcd setup guides.
  2. Paste Direct Terminal Output: Copy exact error snippets from journalctl -u <service> or configuration files (such as /etc/minidlna.conf or /etc/samba/smb.conf) into your prompt or forum post.
  3. Specify Operating Mode: Mention whether the issue occurs while connected to your home LAN via Ethernet (eth0) or while running standalone on the travel Wi-Fi hotspot (wlan0).

Works Cited & References

  1. Raspberry Pi software
  2. What's the point of a Raspberry Pi above $50? : r/raspberry_pi - Reddit
  3. 6 Best Raspberry Pi 5 Projects 2025 - Circuit Cellar
  4. Raspberry Pi Foundation brengt Pi Zero 2 W uit met quadcore-soc
  5. How To Create a Wireless Access Point on Raspberry Pi - DigiKey
  6. Home NAS + home assistant with Raspberry pi zero 2 w? - Reddit
  7. https://raspberry.tips/en/raspberrypi-tutorials/setup-raspberry-pi-wifi-access-point-bridge
  8. Raspberry Pi Projects | PDF - Scribd
  9. Config minidlna - Raspberry Pi Forums
  10. https://forums.raspberrypi.com/viewtopic.php?t=395800
  11. Raspberry Pi OS downloads
  12. Raspberry Pi Imager Guide 2026: Flash OS & Advanced Settings
  13. A new Raspberry Pi Imager
  14. Extremely slow transfer speeds using SMB : r/raspberry_pi - Reddit
  15. Pico-Cloud: Cloud Infrastructure for Tiny Edge Devices - arXiv
  16. How to Use PiSugar 3: Pinouts, Specs, and Examples | Cirkit Designer
  17. Ask HN: Does anyone use a Raspberry Pi as your main computer?
  18. Phone SSD Hub Validation Checklist for OEM Buyers - Digiera
  19. pisugar-power-manager-rs - GitHub
  20. UPS HAT (C) - Waveshare Wiki
  21. UPS HAT for Raspberry Pi Zero, Uninterruptible Power ... - Newegg
  22. PiSugar2 | PiSugar Docs
  23. Geekworm X306 18650 UPS Shield for Raspberry Pi Zero 2 W User
  24. Uninterruptible Power Supply UPS HAT For Raspberry Pi Zero
  25. Mini-PI Media Server - Hackaday.io
  26. Build A Raspberry Pi NAS For $35 Using All New Parts - The DIY Life
  27. Practical Raspberry Pi Projects - 7th Edition 2022 - FlipHTML5
  28. New Pi Imager 2.0.5 released - Raspberry Pi Forums
  29. GitHub - raspberrypi/rpi-imager: The home of Raspberry Pi Imager, a
  30. New Pi Imager 2.0.4 released - Raspberry Pi Forums
  31. How do I set up networking on Raspberry Pi OS - Bookworm or later
  32. Configuring a WiFi Access Point using Raspberry Pi..... How To with
  33. Raspberry Pi Media Server - MiniDLNA : 6 Steps - Instructables
  34. Creating a WiFi hotspot - Raspberry Pi Forums
  35. SnapPipe - normantaipei - GitHub
  36. Trying to set up minidlna, doesn't work - Raspberry Pi Forums
  37. MiniDlna problem accessing files : r/raspberry_pi - Reddit
  38. ReadyMedia - ArchWiki
  39. Network Attached Storage (NAS) Setup Guide - With Raspberry Pi
  40. Category: DLNA Server - Linux Audio Foundation
  41. Raspberry Guide
  42. Build Your Own USB-C Power Meter
  43. Assembling and configuring the Game Console | WK - wesleykent.com
  44. https://wiki.geekworm.com/X306
  45. Geekworm X306 V1.5 5V UPS Expansion Board for Raspberry Pi
  46. Geekworm X306-C1 Metal Case Compatible with Raspberry Pi Zero