Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

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:

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 /var/log/syslog:

10:46:25 motion: [1] v4l2_next: VIDIOC_QBUF: No such device
10:46:25 motion: [1] Video device fatal error - Closing video device
10:46:25 motion: [1] Closing video device /dev/video0
10:46:30 motion: [1] Retrying until successful connection with camera
10:46:30 motion: [1] 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 ls /dev/bus/usb/001/):

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.

Update: I've abandoned this USB camera and am now using the Pi camera module with great success.

share|improve this question
    
I'm going to get one of the Raspberry Pi camera board that is due out next month. As soon as I get it, I'll try out motion with the camera board and see if that resolves the problem. –  Weston Ruter Mar 28 '13 at 4:00
    
I have the similar problem. I have two cams, one is UVC 1.3M HD Cam from a laptop, the other is Logitech C120 web cam. when I use "service motion restart", it works for about 4 minutes for the first cam and 6 minutes for the Logitech one. Then no pics anymore and the motion daemon dispears. I monitored the CPU is about 30-98%, and mem usage is about 6%. The difference thing is my /dev/video0 and /dev/video1 are still there since I have a powered USB hub but this hub does not feedback voltage to pi (I disconnect the position line to pi). I checked the /var/log/messages. It says: Closing video d –  user9111 Aug 20 '13 at 3:04
    
Does the webcam provide raw or compressed video formats? I guess the problem is with either the internal H.262 encoder of the webcam or the USB hub you are using. –  Rasoul Nov 29 '13 at 13:10
    
I've abandoned this USB camera and am now using the Pi camera module with great success. –  Weston Ruter Nov 30 '13 at 0:27
add comment

8 Answers 8

Unfortunately there isn't any easy answer to get it working straight away, however here are a few things I would try in your case;

First off I would try lowering your resolution to something like 320x240 and see if it's any more stable, basically that should lower any load on the Pi.

You could actually go one step further and change "webcam_port" to zero for one of your tests, that will disable the web server but keep your snapshot functionality running, your not going to get the load much lower than this setup.

Next get out a multimeter (if you have one), check the USB power output before you plug in the web cam, then once it's in, and finally once its failed. I have heard of a few powered USB hubs out there that don't really inject enough power, especially if there are a few devices using it.

Finally I would also look at trying a wired network connection for a while instead of WiFi, again just to rule it out.

Hope some of them might help you pin it down :)

share|improve this answer
1  
Thanks for the suggestions, Tom. I've set the webcam_port to zero and reduced the resolution. I should note that I had also tried to sudo shutdown -r now when on_camera_lost happened. But when the Pi would restart, the camera would still be lost, and /dev/video0 would be non-existant. Doesn't this indicate some issue with the camera and not with the Pi itself? –  Weston Ruter Feb 15 '13 at 21:32
    
Yeh it's sounding more like a power issue or a issue with the camera, i'm not sure if the Pi de-powers the USB on a clean reboot like the above. You might also want to try using the camera in another device like your laptop/desktop to see if it works over long periods of time. –  iTom Feb 16 '13 at 10:24
    
This happens to my USB camera as well after about 30 minutes. –  outside2344 Mar 20 '13 at 22:13
add comment

You didn't state which OS you are running on your Pi.

I've been messing around with motion (the camera capture program) on the Raspberry Pi running Arch Linux. I have several Pi's, several webcams, several power supplies, several SD cards...and one thing remains the same. All of them will completely lock up (as in you can't even ping the Pi and the video display is black) after 1 to 3 days of running. If I remove motion from the setup, the Pis will run indefinitely (currently, I have to Pis running without motion for two weeks and counting now).

My experience leads me to the opinion that motion is buggy, at least the Arch Linux ARM version. I've been trying to track down the root of this problem since February.

share|improve this answer
    
Thanks for pointing out that I forgot to mention the OS I'm on. I just updated the question to note that I'm using wheezy. –  Weston Ruter Mar 27 '13 at 7:16
add comment

I've been running a tech support company full-time for 12 years. Here's the steps I'd use to further isolate and troubleshoot the issue:

1) Try a different camera on the Pi. Does it also lose connection after a period of time?

2) Try the original camera on Windows, Mac or Linux. Does it stay up for a long period of time?

Results (most likely problem):

1=yes, 2=yes - Bad USB on the Pi. It could be a faulty Pi board. The USB and Ethernet both operate on the same bus, so it could tell you something if the USB stops working and the Ethernet keeps working, or both stop working. To test further would likely require another Pi.

1=no, 2=no - The problem is the original camera.

1=yes, 2=no - You may have two bad cameras.

1=no, 2=yes - Most likely an incompatibility between the original camera and the Pi, or some strange power issue on the Pi.

share|improve this answer
add comment

Another possible "ugly hack" would be to use the GPIO pins to power a relay that would be spliced into the USB cable of the camera. You could then use that to toggle on and off the power line to the camera.

share|improve this answer
add comment

I've been working here too. Using fswebcam it fails occasionally to "start stream". My current feeling is that it is a camera issue, waiting for the fswebcam to finish helps, but the ideal solution to the problem is to unplug the camera and plug it in again.

If this can be done programmatically then we have it by the tail. Otherwise I'll have to find some other way to disable and re-enable the camera.

share|improve this answer
add comment

Try this on motion.conf file it works perfectely for me...

####################START#######################
daemon=on
norm=3
input=8
auto_brightness=on
framerate=300
height=240width=320
jpeg_filename=motion/%Y%m%d/%v-%H%M%S-%q
noise_tune=on
output_all=off
output_motion=on
output_normal=on
quality=1000
snapshot_interval=500
text_left=(c) Kiran
text_right=%d %b %Y\n%k:%M:%S
threshold=500
v4l2_palette=6
videodevice=/dev/video0
webcam_localhost=off
webcam_maxrate=50
webcam_port=8080
wecam_quality=100
#########################END######################
share|improve this answer
1  
To create code formatting, put backquotes around your code. Like this ` –  xxmbabanexx Apr 23 '13 at 2:46
add comment

I am having a similar issue. I have a simple vaadin app which reads the logs files. You have the ability to select the images. I am having problems with motion and a logitech usb cam that seems to hang occasionally. Stopping and starting motion is no help. I have to unplug the cam.

My app also has a proximity sensor. I am thinking of not using a usb cam. And as Motion requires a usb cam leaving motion as well. Instead getting a raspi cam module...and when the sensor activates take a pic.

Any suggestions on rebooting the web cam would be helpful through

share|improve this answer
add comment

I have excatly the same problem with a Carambola2 board. The USB Microsoft Lifecam simply disconnects from the USB port after some hours.

I tried stopping motion, unloading modules, reloading uvc modules, running fswebcam once inbetween to turn from MJPEG to some other output format. Doing so every hours does not cure the problem.

I have seen Microsoft has a "Firmware Upgrade" on their website "CinemaFW1033.exe". Did anyone try to apply this?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.