Pi Zero world wide web streaming on Mobile Hotspot
The Raspberry Pi Zero is my favorite development board. It’s smaller than the Arduino UNO or Maixduino, and slightly bigger than the Pi Pico, but its footprint is almost same as the ESP32. However, in terms of capability, the Pi Zero is far ahead of these other boards. Only the Orange Pi Zero or NanoPi Neo can come closer in terms of performance. Unlike microcontrollers the ESP32 or Pi Pico, the Raspberry Pi Zero is a full-fledged computer, capable of running a complete Linux operating system and performing tasks typically reserved for larger computers, but on a much smaller scale.
So far, we’ve developed the following projects on the Raspberry Pi Zero. Projects 1 to 5 are AI-based, while the last two focus on IoT, with the “Pi Zero world wide web streaming on Mobile Hotspot” being one of them:
- Pi zero speech translator [Listens & Translates speech between two languages by press of buttons]
- Pi zero YouTube jukebox [Listens to voice commands & plays the music / news from you tube]
- Pi zero hands free Chatgpt [Voice interactive ChatGPT]
- Pi zero speech functions [All about speech functions of Pi Zero & overclocking]
- Pi zero speech transcriptions [Listens voice & transcribe on Screens]
- Pi zero camera for taking pictures [Takes & plays still pics & Video pics on SPI - TFT screens]
- Pi zero world wide web streaming on Mobile Hotspot [Live streaming through VPN tunnel ]
Prelude: Webcasting on a powerful, server-grade computer like a laptop or desktop is common and not particularly remarkable. Even sending the stream to the web via modem port forwarding is straightforward. However, achieving stable, long-term webcasting using just a mobile phone as a WiFi hotspot and a tiny Raspberry Pi Zero, rather than a large computer, is a challenge of a different caliber. That’s exactly what we aim to accomplish. Our setup? A modest 500 MB RAM Raspberry Pi Zero and a 5MP Pi Zero camera—small, but mighty!
Objective: To build a portable streaming device using a Raspberry Pi Zero, Pi Zero camera, and a mobile phone WiFi hotspot, capable of delivering one-to-one streams globally without relying on proprietary software or paid services—apart from standard mobile internet charges. Utilizing the “motion” software for streaming, the system can also function as a surveillance tool, capturing photos and videos of intruders with a date and time stamp for added security.
BOM:
- Raspberry Pi zero [with WiFi] : INR 1400 [robu.in]
- 5MP Pi zero camera: INR 300 https://robu.in/product/5mp-raspberry-pi-camera-module-w-hbv-ffc-cable/
- SDcard [8GB minimum, 32GB recommended] Push-to-on buttons [4 nos] , LED2 [2 nos], soldering wire, soldering iron, paste etc.
Operating Principle: Raspberry Pi Zero web camera system operates using a combination of hardware and open-source software to achieve continuous video streaming and motion detection. Here’s an overview of the working principle:
Hardware Setup: The system consists of a Raspberry Pi Zero board connected to a 5MP Pi camera module. The Pi Zero is connected to Internet via a mobile phone acting as a WiFi hotspot. This compact and portable setup allows the Pi Zero to function as a web camera or a motion detection system.
Software Components: [motion & ZeroTier ]
• Motion: The core of the system is the “motion” software, It has an inbuilt web server which handles video streaming, motion detection, and recording. Motion captures video streams from the camera and processes these streams in real-time. When the system detects motion, it can trigger actions such as recording video, taking snapshots, and saving them locally or transmitting them over the network. It’s worth to mention that we tried with many other softwares including python & Open CV but other than motion everything else becomes heavier for the Pi-zero board resulting in unreliable streaming. But please hang on, this is not going to be a mere motion-controlled webpage, it has more stock to reveal. You will also learn VPN tunnelling with it!
On Pi Zero do the followings:
$> sudo apt install motion -y #Install motion
$> motion -h #After installation check version of motion
$> sudo systemctl start motion #Start motion at system level
$> sudo systemctl enable motion # Start motion at boot
To see whether motion is running at LAN level try http://<your_pi_ip_address>:8081 from any computer connected on the WiFi network, this will open the video streaming of the motion page.
$> sudo systemctl stop motion # In case you need to stop motion…
$> sudo systemctl restart motion #Restart motion
$> sudo systemctl status motion #Check status of motion
$> sudo nano /etc/motion/motion.conf #motion configuration file, Most of things are already set to work.
You need not to do anything , unless you know what to change. Sometimes you may find some motion.log files , process_id_file or the directories are non existent, in that case just create those directories, files & authorisations & restart motion. Motion software is highly flexible. All the options are scalable in the motion.conf file. Read the file carefully to understand each options like to change the destination of the log file , port on which the streaming will be available etc.
For easy of use I’ve included my motion.conf file as attachment.
• ZeroTier: This virtual networking tool enables secure, encrypted one-to-one communication across the internet without complex networking configurations like port forwarding. It creates a secure tunnel for the video stream to be transmitted and accessed by authorized devices anywhere in the world. Once understood it’s philosophy, it’s easy & straight forward! With Motion software running on your Raspberry Pi Zero, the stream is accessible on port 8081 within your local network. Any device on the same WiFi network can view it by entering http://<pi-zero-ip>:8081 in a browser. However, to make the stream available outside your local network (beyond your mobile hotspot’s NAT firewall), we need ZeroTier to create a secure pipeline between devices. Therefore, when you are on Internet, Zerotier creates a virtual tunnel through which D1 to D5 devices get connected to each other. No one can penetrate this pipeline from outside.
Step-by-Step ZeroTier Setup
1. Connect to the Internet
• Ensure that your Pi Zero and any devices from which you want to access it are connected to the internet. For this setup, a mobile WiFi hotspot can be used.
2. Join a ZeroTier Network
• Create a ZeroTier Account: Go to
ZeroTier Central / [
zerotier.com] create an account, and log in. You need only an email address to create an account.
• Set Up a Network: Click on “Create a Network,” which will generate a unique Network ID (a long hexadecimal string) for your virtual network.
3. Add and Authorize Devices on ZeroTier
• Connect Devices: On each device you want to use, install ZeroTier one and enter your Network ID:
• Mobile Devices: Use the “ZeroTier one” app and connect by entering the Network ID in the “Join Network” section.
• Pi Zero: Install ZeroTier on the Pi Zero with these commands:
$> sudo apt install -y zerotier-one [It may ask your sudo password]
To connect to the ZeroTier network here is the command.
$> sudo zerotier-cli join xxxxxxxxxxxxxxxx [xxxx stands for the network identifier]
$> sudo zerotier-cli info [provides info about the network]
$> sudo zerotier-cli listnetworks [provides the external IP address of the Pi Zero]
• Authorize Devices: In ZeroTier Central, go to the network settings and check the authorization box next to each device’s name. Once authorized, each device will receive a unique ZeroTier IP address visible in ZeroTier Central.
4. Verify the Connection
• Ping Devices: Use the Pi Zero’s command line to ping other devices on the ZeroTier network:
$> ping <ZeroTier-IP-of-other-device>
• Devices with successful responses indicate an established secure connection. This “invisible pipeline” is a
secure VPN tunnel, keeping the stream private and accessible only by authorized devices.
5. Access the Stream from Anywhere
• Now, open a browser on any authorized device and enter http://<ZeroTier-IP-of-Pi-Zero>:8081 to access your video stream.
• The stream will appear seamlessly, accessible across the world as long as both devices remain connected to the internet.
- Secure Connectivity: Even though the connection operates over the internet, your stream is private, and only devices on the ZeroTier network can access it.
- Persistent Connection: This setup remains active as long as both devices stay online and connected to ZeroTier, even when accessed from different geographical locations.
- This approach provides a secure, cost-effective solution for streaming, surveillance, or remote monitoring using only the Pi Zero and mobile data—no third-party services required.
[“Zerotier one” on mobile]
To ensure the Pi Zero automatically checks and connects to the ZeroTier network every time it boots, we’ll create a small shell script and set it up to run as a system service.Open a new file to write the ZeroTier connection script.
$> nano zerotier.sh
#!/bin/bash
network_id=“xxxxxxxxxxxxxxx”
# Check if already connected to the network
if sudo zerotier-cli listnetworks | grep -q "$network_id"; then
echo "Already connected to network $network_id"
else
# Join the ZeroTier network
echo "Joining ZeroTier network $network_id..."
join_output=$(sudo zerotier-cli join $network_id)
if [[ "$join_output" == *"200 join OK"* ]]; then
echo "Successfully joined network $network_id"
else
echo "Failed to join network. Output: $join_output"
fi
fi
# Get ZeroTier info and list networks
sudo zerotier-cli info
sudo zerotier-cli listnetworks
Now, create a systemd service file to run the script at boot.
$> sudo nano /etc/systemd/system/zerotier.service
[Unit]
Description=Run ZeroTier Script at Boot
After=network.target
[Service]
ExecStart=/path/to/your/zerotier.sh
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
User=pi # Or your username
[Install]
WantedBy=multi-user.target
To activate and test the service, run the following commands:
$> sudo systemctl daemon-reload # Reload systemd to recognize the new service
$> sudo systemctl enable zerotier.service # Enable the service to run at boot
$> sudo systemctl start zerotier.service. # Start the service immediately
$> sudo systemctl status zerotier.service # Check the service status (optional)
This setup ensures that your Pi Zero checks for the ZeroTier network on every boot and joins it if not already connected.
Schematic: Nothing to show, just a Raspberry Pi zero connected with a camera on it’s camera port.
IP Addresses on WiFi LAN: Most modern mobile devices, when set up as WiFi hotspots, no longer display the IP addresses assigned to the connected devices, leading to challenges when trying to identify the correct IP—particularly for tasks like SSH access on a Raspberry Pi Zero. To streamline this process, I recommend installing network-scanning tools such as LanScan or IP Scanner on your laptop or desktop. These tools will quickly display the IP addresses of all devices connected to the network, simplifying remote access and management.
Aftermath: This project demonstrates the versatility of the Raspberry Pi Zero as a compact, low-power solution for live streaming, remote monitoring, and IoT applications—all achieved without the need for high-power, resource-intensive hardware. With its efficient energy consumption, it operates reliably over long durations, even in mobile or battery-powered setups, setting it apart from full-sized Raspberry Pi computers. By leveraging open-source software like Motion for streaming and ZeroTier for secure, remote access, this project offers a stable, self-contained solution for one-to-one streaming and flexible monitoring across vast distances, free from proprietary services or costly subscriptions.
Looking ahead, the low-power Raspberry Pi Zero can evolve into an even more powerful tool, supporting advanced AI-based image analysis, real-time alerts, and edge computing capabilities. This opens doors for use cases in security, environmental monitoring, and remote data acquisition, making it a future-ready platform for adaptable, real-time applications.
Project prototype:
S. Bera
Kolkata / India
Discussie (0 opmerking(en))