Download this tutorial as a pdf
Overview
- Set up raspberry pi (
<pi><number>
) and get it connected to wifi hotspot - Connect to device using ssh
- Update the system
- Manage ssh connection to the device using ssh keys
- Install editing, streaming, and networking tools (vim, libcamera, motion, tailscale)
- Set up motion for streaming over internet
1. Get connected to wifi
- Set up the connection to wifi hotspot when burning the image and enable ssh
- Start the pi and check on hotspot that more devices are connected
- run
arp -a
in gitbash to find the ip address into the device
2. Access the raspberry pi device
ssh <name>@<ip-address>
- Input your password
3. Update the system
sudo apt update
sudo apt upgrade
4. Setup access through ssh keys
NOTE: Log out of the remote raspberry pi and work on your computer command line
Generate the keys on your machine
ssh-keygen -t rsa -b 4096 -f <pc>-for-<pi><number>
cp <pc>-for-<pi><number>* .ssh/
ssh-copy-id -i <pc>-for-<pi><number>.pub <pi-ip>
Create/Add connection to this pi on given network
Open /.ssh/config
sudo vim ~/.ssh/config
Edit the file
# On S75 hotspot network
Host <pi><number>_s75
HostName <pi-ip>
User <user>
IdentityFile ~/.ssh/<pc>-for-<pi><number>
Test connection
ssh <pi-ip>
5. Install tools
Tools:
- noefetch to get info about the system
- vim for editing
- motion for streaming video
- libcamera to make motion work with raspberry pi camera
Install
sudo apt install neofetch -y && \
sudo apt install vim -y && \
sudo apt install motion -y && \
sudo apt install libcamera-tools -y && \
sudo apt install libcamera-dev -y && \
sudo apt install libcamera-v4l2 -y && \
sudo sed -i 's/stream_localhost on/stream_localhost off/g' /etc/motion/motion.conf && \
echo "done"
Verify it runs
Test by running
sudo libcamerify motion -n
Access in browser at an address: <pi-ip>:8081
Shut down <Ctrl>+<C>
Start so that ssh logout will keep it running
sudo nohup libcamerify motion -n &
After pressing <Enter>
you can work in the shell
NOTES:
- To close the stream get back to background process
fg
and then<Ctrl>+<C>
- If it is not in the background process of this shell
sudo pkill motion
to terminate the process
6. Install tailscale for remote access
Tailscale is a networking tool (like vpn) to access your devices over internet link
Install using commands and activate:
curl -fsSL https://pkgs.tailscale.com/stable/debian/bookworm.noarmor.gpg | sudo tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null
curl -fsSL https://pkgs.tailscale.com/stable/debian/bookworm.tailscale-keyring.list | sudo tee /etc/apt/sources.list.d/tailscale.list
sudo apt-get update -y
sudo apt-get install tailscale -y
sudo tailscale up
Resource
Detailed instruction how to install tailscale on Debian bookworm (on which the raspberry pi OS is based): link
7. Verify the streaming works over tailscale
In browser: <tailscale-pi-name>:8081
8. Put the link online to website
NOTE: works for hugo static website
Create a file webcam.md
in the content/
folder and copy inside this text with updated link and instructions:
[webcam link](http://<tilscale-pi-name>:8081)
Activate the stream from camera over ssh:
`nohup sudo libcamerify motion -n &`
9. Tweaks
Set alias for streaming
sudo echo 'alias start-stream="sudo nohup libcamerify motion -n &" # alias to start streaming' >> ~/.bashrc
source ~/.bashrc
Now typing start-stream
starts the stream in the background
Rotate the camera image
Adding rotate <number-in-degrees>
into motion.conf
rotates the image clockwise
# if the camera is upside down
sudo echo "rotate 180" >> /etc/motion/motion.conf
Restart the stream after the modification for it to take place
10. Motion config files
The default config file for motion is in /etc/motion/motion.conf
.
To run a different configuration:
- Make a copy of this file
- Adjust it
- Call it using
sudo libcamerify motion -n -c <path-to-config-file>
Example config files
- Snapshots: Take a 2592x1944pxs image every 10 seconds saved in
/home/vld/Pictures
Download - To be filled in…
Parameters to set
width 1296
height 972
- to be filled in…
11. Installing samba for shared folder
For easier transfer of files from the raspberry pi to the pc you can mount a shared folder on the pi as a network disk.
Samba project link.
Instructions for raspberry pi setup: link.
Install samba from repository
sudo apt update
sudo apt install samba samba-common-bin smbclient cifs-utils -y
Create a shared folder with the proper rights
cd ~
mkdir shared
chmod 0740 shared
Create the user who will be connecting
Think about user name and a password and write it on a piece of paper or use the same as you use to access rapsberry pi
sudo smbpasswd -a <username>
Configure samba
Open the config file
sudo vim /etc/samba/smb.conf
Add following at the end
[<share-name>]
path = /home/<username>/shared
read only = no
public = yes
writable = yes
NOTE: The text inside the brackets is how the folder will be called when you are connecting from outside (mapping the network disk)
Check it is working
sudo systemctl status smbd
NOTE: in case you use sudo systemctl status samba
gives a condition failed
message which does not mean the share is not working
Conect to the folder from a Win11 machine
- Right click
This Computer
- Select the letter for a disk
- Put
\\<pi-ip>\<share-name>
- Fill in the user name and a password (for samba)
NOTE: instead of <pi-ip>
also the <pi-name>
can be used but initially, the <pi-ip>
is safer
12. Use USB cable for ssh connection
in /boot/firmware/config.txt
dtoverlay=dwc2
in /boot/firmware/cmdline.txt
rootwait modules-load=dwc,g_ether
reboot and connect
check if the usb0 is up
ip a show usb0
if it is dowb bring it up
sudo ip link set usb0 up
in etc/dhcpcd.conf
should set it automatically
interface usb0
static ip_address=192.168.7.2/24
nolink
sudo reboot
Is not recognized from windows side, need insatllaiton of rndis drivers, downloaded from here emm2a post link
System
The above works for following systems
Camera(s)
Raspberry Pi camera V1.3
Raspberry Pi Zero W
Firmware
vld@pi0D:~ $ vcgencmd version
Apr 30 2025 13:35:18
Copyright (c) 2012 Broadcom
version 5560078dcc8591a00f57b9068d13e5544aeef3aa (clean) (release) (start)
OS
vld@pi0D:~ $ neofetch --off --color_blocks off
ld@pi0D
--------
OS: Raspbian GNU/Linux 12 (bookworm) armv6l
Host: Raspberry Pi Zero W Rev 1.1
Kernel: 6.12.34+rpt-rpi-v6
Uptime: 2 hours, 33 mins
Packages: 1595 (dpkg)
Shell: bash 5.2.15
Terminal: /dev/pts/2
CPU: BCM2835 (1) @ 1.000GHz
Memory: 130MiB / 427MiB
Camera
vld@pi0D:~ $ rpicam-hello --list-cameras
Available cameras
-----------------
0 : ov5647 [2592x1944 10-bit GBRG] (/base/soc/i2c0mux/i2c@1/ov5647@36)
Modes: 'SGBRG10_CSI2P' : 640x480 [30.00 fps - (65535, 65535)/65535x65535 crop]
1296x972 [30.00 fps - (65535, 65535)/65535x65535 crop]
1920x1080 [30.00 fps - (65535, 65535)/65535x65535 crop]
2592x1944 [30.00 fps - (65535, 65535)/65535x65535 crop]
Raspberry Pi 4
Firmware
vld@pi4:~ $ vcgencmd version
Aug 30 2024 19:17:39
Copyright (c) 2012 Broadcom
version 2808975b80149bbfe86844655fe45c7de66fc078 (clean) (release) (start)
OS
vld@pi4:~ $ neofetch --off --color_blocks off
vld@pi4
-------
OS: Debian GNU/Linux 12 (bookworm) aarch64
Host: Raspberry Pi 4 Model B Rev 1.4
Kernel: 6.6.51+rpt-rpi-v8
Uptime: 2 hours, 46 mins
Packages: 1610 (dpkg)
Shell: bash 5.2.15
Terminal: /dev/pts/2
CPU: (4) @ 1.800GHz
Memory: 405MiB / 7809MiB
Camera
vld@pi4:~ $ rpicam-hello --list-cameras
Available cameras
-----------------
0 : ov5647 [2592x1944 10-bit GBRG] (/base/soc/i2c0mux/i2c@1/ov5647@36)
Modes: 'SGBRG10_CSI2P' : 640x480 [30.00 fps - (65535, 65535)/65535x65535 crop]
1296x972 [30.00 fps - (65535, 65535)/65535x65535 crop]
1920x1080 [30.00 fps - (65535, 65535)/65535x65535 crop]
2592x1944 [30.00 fps - (65535, 65535)/65535x65535 crop]