Mike's Meanderings

What Does My Dog Do All Day?

My wife Kristin and I were talking about our dog, Wendy. We wondered: what does she do all day while we're at work? Wendy likes to stand on her hind legs — she's insanely curious and always trying to get people food. We only recently learned she can leap onto our kitchen table! But does she do this when we're gone?

Using a Raspberry Pi and some extra hardware, I built an always-on webcam that streams live video and takes pictures when motion is detected. The WendyCam was born.

One of the really cool things about this project was how much I learned about Linux. I picked up a lot about how permissions work, and it was a great exercise in Bash — I did the entire project over SSH without ever touching a GUI.

Hardware

  • Raspberry Pi Zero
  • USB wireless network adapter
  • Raspberry Pi Camera Module (a PS3 Eye or any USB camera also works)

Steps to Follow

  1. Prep the Raspberry Pi Zero
  2. Install Motion
  3. Configure Motion
  4. Watch dog and be happy

1. Prep the Raspberry Pi Zero

I chose the Pi Zero for its small size. I loaded it with Raspbian Jessie Lite — no GUI, command line only. Once the Pi was set up, I connected the Camera Module (enabled through raspi-config) and plugged in a USB WiFi adapter so the WendyCam could reach the network.

For a case: electrical tape and a lunch meat container. Pretty fancy.

2. Install Motion

Motion is a lightweight, open-source program with great documentation. It doesn't take many resources to run — perfect for the Pi Zero.

sudo apt-get install motion

3. Configure Motion

Enable the daemon to start on boot:

sudo nano /etc/default/motion

Set:

start_motion_daemon=yes

Then open the main config file:

sudo nano /etc/motion/motion.conf

Key settings to change:

# Resolution
width 1920
height 1280

# Allow streaming from outside localhost
stream_localhost off

# Motion detection sensitivity
# Raise this to reduce false triggers (default: 1500)
threshold 3000

# Require motion in this many consecutive frames before triggering (default: 1)
minimum_motion_frames 4

# Where to save pictures
target_dir /var/lib/motion

Then forward port 8081 on your router to the Pi's local IP address so you can view the stream from your phone.

4. Watch Dog and Be Happy

Start Motion:

sudo motion

And there we go! Kristin and I can check on Wendy any time. Turns out she mostly sleeps — but she looks adorable doing it.

Takeaways and Future Thoughts

Unexpected problems: The Motion settings are all over the place and took time to tune for the Pi Camera Module. The default settings also generated at least 1GB of pictures per day — tweaking the threshold and minimum frames settings brought that way down.

I also couldn't easily delete photos in /var/lib/motion until I fixed the permissions:

sudo chown pi /var/lib/motion
sudo chmod 777 /var/lib/motion

Eventually I turned off picture saving entirely and now use it only for live streaming.

Future concerns: As always — what happens if my IP address changes? (A Dynamic DNS setup would fix this.)

Future enhancements: The camera needs a proper case to protect the cable, and I'd love to mount it on the wall permanently.

Resources

💬 Webmentions

No webmentions yet. Be the first to respond!