I have been meaning to set up a pet cam to watch my two cats for a while, and finally had some free time to get around to doing it. Since I have an old USB webcam, a Raspberry Pi that was lying around doing nothing, I decided to set up something with my existing hardware rather than buying something off the shelf.

Functionalities desired

  • Have a live view of my living room from my phone or from my laptop
  • Use existing hardware: a USB webcam and Raspberry Pi 4 Model B
  • Nothing accessible from an unknown phone or laptop

I had considered setting up a system where motion is started only if someone is actively requesting a view, instead of the USB camera being on all the time, but the energy saved did not seem worth it as the Pi would be on all the time anyway.

Setup

After a preliminary exploration with AI, I settled on this setup:

  • Motion for handling video input
  • Tailscale for access from phone and laptop

Clearly this is a common use case for Tailscale as they have this handy guide in their documentation with very comprehensive instructions.

Motion

Motion is a Linux program that monitors video input for changes between frames and saves images or video clips when motion is detected. It has been around for a very long time and is well-supported on Raspberry Pi OS.

Tailscale

Tailscale creates a private WireGuard mesh between your devices, so the stream is only accessible from other machines on your Tailnet.

After authenticaton, the Pi appears in the Tailscale admin console with a stable IP (e.g. 100.x.x.x). The live stream is then accessible from my phone or laptop at:

http://100.x.x.x:8081

once I add my phone and laptop to the same Tailnet, even when I’m not on the same network as the Pi. A helpful side effect is having easy SSH acess to my Pi from my laptop wherever I am!

Reflections

I can now determine the distance from the door where my cats realize that I’m home and come running! The ease of setup definitely surprised me - if I had known it was this simple, I would have set this up long ago.

Further projects for the future: detecting how often my cats drink throughout the day, or determining their favourite napping spots…