I've been working on getting a Raspberry Pi webcam set up, thanks to a how-to post on PingBin. However, I cannot get past a problem where the camera becomes lost after a few hours of taking snapshots.
I picked up the Microsoft LifeCam Cinema 720p HD Webcam mentioned in the post and hooked it up to a Plugable 7 Port High Speed Hub. I also doubly-connected a Raspberry Pi Model B to the hub, both for power and for data. Lastly connected the Wi-Pi USB WiFi adapter to the hub and configured it for my network. Here's a photo of my hardware setup:
As for the software setup, I'm running a Raspbian “wheezy” image from 2012-12-16. I've made my motion.conf available. I've configured
motion as a daemon to take a snapshot ever 10 seconds. I have a cronjob that uploads the latest snapshot to a web server for viewing.
This all works great for a few hours (longest run-time has been around half a day), but then the camera will become lost, as can be seen by looking at
10:46:25 motion:  v4l2_next: VIDIOC_QBUF: No such device 10:46:25 motion:  Video device fatal error - Closing video device 10:46:25 motion:  Closing video device /dev/video0 10:46:30 motion:  Retrying until successful connection with camera 10:46:30 motion:  Failed to open video device /dev/video0: No such file or directory
If I then take a look at the output of
lsusb, I don't even see the camera listed anymore as one of the connected devices (same goes for
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 016: ID 0424:9512 Standard Microsystems Corp. Bus 001 Device 017: ID 0424:ec00 Standard Microsystems Corp. Bus 001 Device 018: ID 1a40:0201 Terminus Technology Inc. FE 2.1 7-port Hub Bus 001 Device 019: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
I've tried everything I can think of, including a root cronjob that stops
motion once an hour for a few seconds to give the camera a “break”:
sudo service motion stop sleep 5 sudo service motion start
This has not had any noticeable effect. I've even tried researching how to programmatically turn off the USB port for the device in order to power-cycle the camera, but it seems this is not possible (besides the fact that it would be a sorry hack). The camera does not provide a
power/level interface but only
power/persist, so I even tried toggling it to no avail:
echo 0 | sudo tee /sys/bus/usb/devices/usb1/1-1/1-1.3/1-1.3.2/power/persist
The only way I've been able to get
motion to continue taking snapshots is to physically disconnect the webcam from the hub, then re-connect it and restart the daemon.
Any idea for how to keep the camera from going offline? It seems the camera turns itself off after a certain amount of time of being connected to power.