Build your own camera monitor (worksheet)

Companion to this video

Every command below can be copied and pasted. Blanks are for values you'll need again later.

Parts list:

  • Raspberry Pi 4 (1gb) - $35 at Micro Center. Available on Amazon, here

  • Hosyond 7” DSI Touchscreen - $38 on Amazon, here

  • 16GB microSD card

  • USB-C power adapter - the one I use is on Amazon, here

  • Wall-mounted case - files located here, by TacoTruckMcTacoTruck

STEP 1: Flash Raspberry Pi OS Lite (64-bit)

•     Download the Raspberry Pi Imager: https://www.raspberrypi.com/software/

Settings in the imager:

•     Device: Raspberry Pi 4

•     OS: Raspberry Pi OS (other) > Raspberry Pi OS Lite (64-bit)

•     Storage: your microSD card

Hostname (suggested: pi-cam-mon-0):  _______________________________

Username (video uses: netserv):  _______________________________

Password:  _______________________________

•     WiFi: enter your network name and password (or skip if using Ethernet)

•     Services: Enable SSH, password authentication

•     Write the card, eject, insert into the Pi, power on. Wait for the login prompt on the touchscreen.

Pi IP address (from router client list, or ping the hostname):  _______________________________

STEP 2: Assemble the hardware

•     Ribbon cable: display board to the Pi port labeled DISPLAY. Lift clip, insert ribbon, close clip. This one cable carries video, touch, and power (Hosyond and similar DSI panels).

•     Screw the Pi onto the standoffs on the back of the display, then attach the stand or mount. With the Hosyond, you’ll screw the brass standoffs into the threaded holes on the back of the display that correspond to the RPi mount.

•     Note for the Official Raspberry Pi touchscreen only: also connect the two jumper wires, display 5V to GPIO pin 2 (5V) and display GND to GPIO pin 6 (ground). Pin 2 is the second pin from the corner on the OUTER row; pin 6 is two below it on the same row.

•     Do not power on yet.

STEP 3: Connect and install software

Open a terminal on your computer (Windows: press Windows+R, type cmd, press Enter), then, using YOUR username and IP:

Hello, World!

(ex: ssh netserv@192.168.0.72)

Run these one at a time:

sudo apt update
sudo apt full-upgrade -y
sudo apt install -y mpv python3-evdev


STEP 4: Camera RTSP URLs

Use the SUBSTREAM (low resolution) URL for every camera. Common patterns:

Reolink:        rtsp://USER:PASS@CAMERA-IP:554/h264Preview_01_sub
Amcrest/Dahua:  rtsp://USER:PASS@CAMERA-IP:554/cam/realmonitor?channel=1&subtype=1
Hikvision:      rtsp://USER:PASS@CAMERA-IP:554/Streaming/Channels/102
Frigate/go2rtc: rtsp://FRIGATE-IP:8554/CAMERA_NAME_sub
Blue Iris       rtsp://USER:PASS@BLUEIRIS-IP:81/CAMERA-NAME

Tips: create a view-only camera account with an alphanumeric password. If a password has special characters, percent-encode them (@ becomes %40, : becomes %3A, / becomes %2F).

Test each URL on the touchscreen (press q in the SSH window to quit):

mpv --fs --vo=gpu --gpu-context=drm --rtsp-transport=tcp "rtsp://YOUR-URL-HERE"


Camera 1 name and URL:  _______________________________

Camera 2 name and URL:  _______________________________

Camera 3 name and URL:  _______________________________

Camera 4 name and URL:  _______________________________

STEP 5: Install the monitor script

mkdir -p ~/rtsp-monitor && cd ~/rtsp-monitor
wget https://dad-the-engineer.com/s/monitor.py
wget https://dad-the-engineer.com/s/cameras.conf
wget https://dad-the-engineer.com/s/rtsp-monitor.service

Edit the camera list with:

nano cameras.conf

One camera per line: Name|URL from Step 4.

Then set GRID (1 = grid view on) and CYCLE_SECONDS (0 = manual, or seconds between automatic rotation)

Save with Control-X, then Y, then Enter

STEP 6: Permissions and housekeeping (one time)

Group access to video, GPU, and touch input (use YOUR username):

sudo usermod -aG video,render,input netserv

Backlight permission rule:

echo 'SUBSYSTEM=="backlight",RUN+="/bin/chmod 666 /sys/class/backlight/%k/brightness /sys/class/backlight/%k/bl_power"' | sudo tee /etc/udev/rules.d/99-backlight.rules

Stop the console from blanking, and hide the cursor:

sudo nano /boot/firmware/cmdline.txt

Add a SPACE at the end of the existing single line, then add (still on the same line):

consoleblank=0 vt.global_cursor_default=0

Save with Control-X, then Y, then Enter.

STEP 7: Autostart as a service

If your username is not netserv (from Step 1), first edit rtsp-monitor.service and change the User, Group, and the two /home/netserv paths. Then:

sudo cp ~/rtsp-monitor/rtsp-monitor.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable rtsp-monitor
sudo reboot

About 15 seconds after reboot, the first camera should appear.

Daily use

•     Tap: next view (cameras, then grid, then around again)

•     Press and hold 1 second: screen off (Pi stays on)

•     Tap while dark: wake to the last view

•     Brightness (0 to 255):

echo 128 | sudo tee /sys/class/backlight/*/brightness

Troubleshooting

•     No video in Step 4: test the same URL in VLC on your computer (Media > Open Network Stream). If VLC fails too, the URL or credentials are wrong, or RTSP is disabled in the camera's settings

•     Video works in VLC but not on the Pi: try replacing --vo=gpu --gpu-context=drm with --vo=drm in the test command, and tell me in the comments

•     Black screen after reboot: read the service log:

journalctl -u rtsp-monitor -n 50 --no-pager

•     Choppy or laggy video: you're probably on the main stream. Switch to the substream URL

•     Touch does nothing: confirm your user is in the input group (log out and back in after Step 6), and that the ribbon cable is fully seated

•     Screen never sleeps on hold: check the udev rule file from Step 6 for typos, then reboot. Note: on some third-party panels the script dims the backlight to zero instead of switching it off; the screen still goes fully dark either way

Maintenance

•     Every month or two:

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

•     After editing cameras.conf, restart the monitor:

sudo systemctl restart rtsp-monitor

Previous
Previous

Do you want to make something?

Next
Next

Tower warrants are unconstitutional!