Remote video monitoring with Raspberry Pi
By Anatoly Mironov
My Ender 3 v2 3D Printer does not have a webcam to remotely check 3D prints. Sometimes when I am not at home I need to see how things are going. I thought a simple webcam solution would do the trick.
I grabbed my older Raspberry Pi (RPi 2) and set it up as a remote web camera.
Hardware and Software
So here is the hardware I am using:
- Raspberry Pi 2 (I suppose it should work with any SBC)
- Wifi dongle (you don’t need it if you have buil-in wifi or you want use an ethernet cable instead)
- Usb web camera (of course it would also work with a raspberry pi camera)
I have the following software installed and configured:
- Rasbperry Pi OS Lite Bookworm (no desktop)
- motion
- ngrok (requires account and token)
Github Repo
My goal was a plug-n-play scenario. I have a Github repo with an installation script: motion-ngrok.git. Once installed, all I have to do is plug in the raspberry pi and point the webcam at my 3d printer. Then, wherever I am, I can open the video stream in the browser on a computer or phone.
There are more details (how it works and how to configure it) in the repo.
Inspiration
For inspiration I used the following resources:
- How to Make Raspberry Pi Webcam Server and Stream Live Video, a good starting point, although the configuration of motion is different now, I don’t change motion.conf at all.
- Raspberry Pi — secured webcam streaming with motion, nginx and ngrok | by Daniel Herman | Medium, I tried it and it indeed worked. I removed the nginx part in my setup, since motion streams video over http, and I could tunnel it directly via ngrok, I just skipped the nginx part. Also, ngrok offers authentication, so really no need for nginx here.
- systemd-ngrok.git, amazing repo for setting up ngrok as a service, I forked this repo and adjusted it for my needs (ngrok + motion)
- Docs on running motion as a service
- Launching ngrok Agent Tunnels Automatically with systemd on Boot, this blog walks you through how to set ngrok service by yourself, you don’t need it, just run
install.sh
from my repo, but the blog post is still educational and sheds light on how you can transform any linux runnable into a service and start it automatically when a computer is powered on.
Final Thoughts
It is amazing to see what can be done with some older hardware and great open source software like motion and ngrok. Using services that start on boot is a great way to make it really easy to use. There are also some dedicated systems for monitoring and controlling 3D printing like octoprint, maybe that will be my next project.