Note to the Reader: What I describe in this post has been already done, literally millions of times, for at least 3 years, and described in countless other blog posts. I write this because there is nothing quite like the thrill of seeing new hardware come to life (It reminds me of my embedded systems days.) and there may be a nugget of wisdom or two for others trying set up a webcam with the Raspberry Pi.
In my last post, I outlined what I thought I needed to get a Raspberry Pi board up and running. I estimated that I would have to spend about what a bare RBP costs on supporting peripherals, just to get it going. As it turns out, my estimate was about 100% wrong. My son knew I wanted to try out the RBP, and when he stopped by our house, a few days after that post, and he just happened to bring with him (unasked) a 32G micro SD card and a HDMI cable. Perfect!
I quickly formatted the SD card, loaded the OS files on it and inserted into the RBP. I plugged in a USB mouse and keyboard, and connected the HDMI output to one of my monitors. About SD cards, I did not realize this at the time, but some versions of the RBP board use standard SD cards and others use micro SD cards. Good thing I did not go out a buy and SD card when I really needed a micro SD card. The card my son lent me had an SD adapter with it, so either way I would have been fine. For the monitor, I just wanted to mention that for the last two monitors I bought, I deliberately looked for VGA, DVI, and HDMI inputs, internal speakers, and VESA mounts. That way, I figured I would be ready for anything, monitor related. For the network connection I went the wired route, sharing the Ethernet connection in my home office, via the Ethernet hub I had conveniently laying around.
My one remaining fear was that the power supply I had would not handle the load, and that I would have to butcher its connector, just to connect it to the RBP to find out. Turns out I was wrong again, on both counts. The power supply I had, was originally made to power a USB hub, so I thought, before we do anything rash, lets just power up the USB hub, and plug the RBP into that, with a standard USB to microUSB cable, and see what happens. So I held my breath, crossed my fingers, plugged it in, and wonder of wonders, it just started running. No problem! I immediately forgot about my power supply worries.
Again, I did not do anything special here and the steps I took have been well documented elsewhere. I will however, describe what I went through to get a webcam working with my RBP.
One of the first things I did once, I got the RBP going was to enable ssh. Once that was done, I could disconnect the monitor, mouse, and keyboard from the RBP, and run commands remotely from another PC. I had an old USB webcam, so of course, I wanted to connect that up. There are plenty of sites that describe how to do this using the motion application, but I struggled for a few hours to get it work for me. The problems I encountered were:
It did not work through the USB hub. I first connected the webcam through the USB hub, theorizing that it might be better, power-wise to not power the webcam through the RBP. Although when I ran the “lsusb” command it showed the webcam in the list of USB devices, it still did not work, so I switched to plugging the webcam directly into one of the RBP USB ports and the RBP did not seem to mind. It probably helped that by this time I was using ssh, so no power was wasted on the mouse or keyboard. I wonder if there is any power savings by not connecting the monitor?
It did not work on my work PC. My work laptop PC was close at hand, so I initially tried to view the webcam feed via Chrome and Firefox browsers on that. However, I was never able to get it to work on my work PC. It was only when I switched to using my home PC, that I was able to view the feed. I’m guessing there is some software, most likely McAfee, that is blocking the IP address and/or port number of the webcam feed.
It only worked with the Firefox browser. To see the actual pictures from your webcam, you need to fire up a browser and point it at your RBP’s IP address, and the port number of the webcam, which is configured in the motion application (default port number is 8081). Some webcam posts say Chrome works for this, and I don’t doubt them, but for me, I was only able to see the webcam feed using Firefox.
So here it is, the view out a window of my house, using a USB webcam, the RBP board, and the motion application. Sorry about the window screening, and the low resolution, but I was thrilled the first time this appeared.
Next up for the Raspberry Pi; make it do something useful. Stay tuned.