Sunday, August 5, 2012

Getting a Logitech C270 webcam working on a Raspberry Pi running Debian


I thought it was about time I shared something after all the hours I've committed to Pi-hacking and the above title says it all. These instructions are very simple but should hopefully save you some trial-and-error.

Importantly, hat-tip to Insipid Ramblings and Hexxeh for their info and work that helped me get this far.

Firstly, I started with a slightly old version of Debian - namely the debian6-19-04-2012 image. Your results may vary depending on what version you use. I am also assuming that you have already installed the image and can successfully boot to the desktop.

So, here goes:

1. Add UVC support to the image
Download and run rpi-update as described here. This will update your image to include the initially-missing UVC support. Reboot as suggested.

2. Update your packages
sudo apt-get update
sudo apt-get upgrade 

3. Install the guvcview webcam viewer
sudo apt-get install guvcview

4. Set up your permissions and enable the driver
sudo usermod -a -G video pi
sudo modprobe uvcvideo

Reboot the Pi.

5. Open up the cam (these are the settings that worked for me)
guvcview --size=544x288 --format=yuyv

Caveats
Well, you are almost done, there are a few things to keep in mind before you rush out to buy one of these webcams for your Pi.
  • Before you view the C270 you must disconnect your mouse*. I am not sure if this is problem specific to my install but if I don't the camera will either not connect or will drop out constantly. The error I saw was along the line of not having any "periodic" USB channels.
  • The resolution is low. Clicking on the above image will open it at full size (544x288). Trying resolutions above this didn't work.
  • The webcam "must" be connected before powering up the Pi. If not you need to run sudo rmmod uvcvideo and sudo modprobe uvcvideo before it will work.
Even with this caveats, this is better than nothing and step one towards my Pi-powered mobile robot.

Hopefully this how-to helps you out and if you have more luck than I using a mouse and/or higher resolutions please let me know in the comments.

* Now, "real" Linux people would say that you shouldn't be using one anyway, but when your goal is to use a webcam, it's somewhat inferred that you'd like to see the result in a mouse-equipped GUI :-)

23 comments:

  1. Related info to the "disconnect the mouse" thing:
    http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=12097&p=145278#p145479

    ReplyDelete
    Replies
    1. Thanks very much for the info, Tomas, at least I'm not the only one who's come across this :)

      Delete
  2. Thank you very much. After a lot of hours trying to "see something", i get it with your help.

    ReplyDelete
  3. How do we use this while using tightvnc :)

    ReplyDelete
  4. Thank-you for your excellent guide on getting guvcview running on a Raspberry Pi. I can now get images from my Packard Bell webcam. I also noticed the interference when using the mouse. However, after installing this software, I am disappointed that the commands aplay and speaker-test -c 2, no longer produce any sound, only a click when entered - any ideas why this happened?

    ReplyDelete
  5. Hey. My first question would be whether this problem happens only with the camera plugged in, or always?

    ReplyDelete
  6. when i try to open the program it says illeagal instruction do you know how to fix this?

    ReplyDelete
  7. Same guide works perfectly with the C310 cam. Thx m8

    ReplyDelete
  8. On C270 with Motion 1024x576 as well.
    (V4l_2_palette 6)

    ReplyDelete
  9. Thanks guys for the feedback, glad this was of assistance :)

    ReplyDelete
  10. Thanks for the write-up. This worked fine on a new raspberry pi installation running 2013-02-09-wheezy-raspbian.zip, and following your guide.

    ReplyDelete
  11. great! working at first attempt with Logitech p9000.

    ReplyDelete
  12. This official link says that you need an external power for C270 to work with Pi. Is that your observation as well?

    ReplyDelete
    Replies
    1. Hi GJ. Yep, I needed a powered hub for it work. Bit of a pain :)

      Delete
  13. Thanks for the instructions. In my case everything worked. There was no need to disconnect the mouse and all resolutions worked fine.

    ReplyDelete
  14. I hooked up two logitech older style eyeball cams to my Pi and followed your directions. Works like a champ!. You can open both up and see two streams. They are slow but it will allow me to switch between the two remotely to look in on things.
    Great instructions and thank you!

    ReplyDelete
    Replies
    1. Oh I forgot to mention. I am using a Belkin non-powered USB hub (High speed USB 2 Ultra-mini hub).
      Upon plugging in the hub initially it causes the Pi to reboot but stable after that.

      Delete
  15. Thanks for this Robert, after wrestling with motion for a few ... I'm in higher spirits! ... that said, if you don't want to use a mouse (like me) I just enabled ssh and 'ssh -X pi@IP" to it and all X commands will come to my session (sorry windows folks) OS X and Linux it should work off the bat.

    Orlando,

    ReplyDelete
  16. This worked fine with a different webcam (MS VX-700) and is a great way of checking to see if things are working OK. Cheers.

    ReplyDelete
  17. thanks for your instruction,mine didn't work first but after removing the webcam from the hub and plugging it to the pi directly worked for me.i didn't got the mouse problem like you said and it's working like a charm

    ReplyDelete
  18. This is very nice article. I have been trying to get mine to work, although I'm being counterculture, and using ArchLinuxArm. ; P Anyhow, I think I can get it to work now.
    Thanks a lot. ; )

    Keep on Geeking, Philipbenr

    ReplyDelete
  19. Thanks for the post.Is it possible to check the Pi camera using guvcview.

    ReplyDelete