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.

  • 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. Mar 28, 2013 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, 2013 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, 2013 at 13:10
  • I've abandoned this USB camera and am now using the Pi camera module with great success. Nov 30, 2013 at 0:27
  • I am having similar problems, running 2 - Raspberry Pi's Model B, one has a wifi adapter plugged into one port and a logictech cam plugged into the other. The other Raspberry Pi has a Zoom modem plugged into one port and a logictech cam plugged into the other. Both exhibit the same problems. Both Pi's will run fine but after I run motion -n (non Daemon) mode, and stop Motion, the USB ports either become partly active or completely inactive. I tired these configurations directly connecting to both USB ports and also using a recommended USB powered hub recommended by RaspberryPI.org. I feel ther
    – user27620
    Mar 3, 2015 at 18:26

5 Answers 5


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 :)

  • 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? Feb 15, 2013 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, 2013 at 10:24
  • This happens to my USB camera as well after about 30 minutes. Mar 20, 2013 at 22:13

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.

  • 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. Mar 27, 2013 at 7:16

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.


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.


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

text_left=(c) Kiran
text_right=%d %b %Y\n%k:%M:%S
  • 1
    To create code formatting, put backquotes around your code. Like this ` Apr 23, 2013 at 2:46

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