Capturing Images with USB Camera, Wi-Fi and Raspberry Pi

By Somnath Bera


Power-on the USB hub; connect the wireless adapter (Wi-Fi dongle), web camera, keyboard and mouse to the USB hub. Go to Raspberry Pi desktop and double-click the wireless module (Wi-Fi Config). Most wireless adapters are easily detected and installed on Raspberry Pi.

Set up a Wi-Fi connection

After double clicking Wi-Fi Config icon, the wpa-gui page will open up. Click Search and a list of available wireless connections will come up. Select a connection and enter the IP address, if required, or leave it as it is for DHCP mode, select the authentication mode (mostly WEP) from the pull-down menu and then enter WEP key in the first blank space. Click Finish and Connect. The symbol will turn to Connected.

(For connecting to a mobile hotspot like cell phones, the WPA2 psk type authentication is used. Select the same from the pull-down menu.)

Checking network connection

To check whether your Wi-Fi is connected to the network or not, you need to go to Terminal and issue ping command as given below.

[stextbox id=”grey”][email protected]:/$ ping[/stextbox]If you get continuous ping response, it means you are online and connected. Otherwise, you need to check the connections and, if required, need to go through the steps below.

Enter the following command at Raspberry Pi terminal:

[stextbox id=”grey”][email protected]:/$ dmesg | grep ^usb[/stextbox]This command will furnish details of the kernel ring buffer of all the devices installed, starting with the word USB. Look out for 802.11 and the manufacturer’s name (realtek or ralink) associated with it. This means that the hardware is built on that chip and Raspberry Pi needs the driver (say realtek) for it. (On the latest Raspbian OS, this step is not required because it finds the suitable driver automatically.)

Driver installation

You can issue the following command to search the driver on your Raspberry Pi computer:

[stextbox id=”grey”][email protected]:~/Desktop/Raspberry-
PI/OS$sudo apt-cache search realtek[/stextbox]

The command will give details of the packages available for that manufacturer. Since your Raspberry Pi is still not connected to the Internet, you need to go to a Linux PC that has an Internet connection and search for realtek drivers online. Go to the manufacturer’s website and download Debian wireless package (e.g., firmware-realtek.deb, firmware-ralink.deb) from their website. Copy this package in the /home/pi folder of the SD card and issue the following command to the Raspberry Pi:

[stextbox id=”grey”][email protected]:/$ sudo apt-get install
firmware-realtek.deb[/stextbox]This will install the right firmware on Raspberry Pi. Once the firmware is installed, disconnect the wireless adapter and reconnect it to Raspberry Pi. This will restart the kernel search process for the right software driver.

With the firmware installed, setting-up the connection is pretty straight forward now. Go back to the desktop and double-click WiFi Config icon and follow the steps mentioned above under Set-Up a Wi-Fi Connection section.

Setting up the webcam server

ffmpg has some issues on Raspberry Pi as a result of which ffserver does not work easily. Some staunch Raspberry Pi supporter claims to tweak it to work but I find it very complicated and not worth when various other easy choices are available.

Apache2 server with webcam software makes our job very easy but, before that, to ensure the webcam is working, we have to install VLC software. Along with showing webcam images, VLC can play all kinds of media files including *.flv files, which was not possible in the earlier OS.

Installation of VLC Apache2

To install it, issue the following command:

[stextbox id=”grey”][email protected]:/$ sudo apt-get install
vlc apache2 webcam[/stextbox]This will install the wav trio—webcam, Apache2 and VLC media player. Go to the desktop, in the media section, click on VLC media player. Go to File → Capture Device, and see if the camera images appear or not. VLC is smart enough to find your first camera at /dev/video0 and the video driver as video4linux2 (if not, select from the pull-down menu). It will take some time for the images to appear on the screen. The images may appear broken at many places, but do not worry about it now.

Webcam software has no default configuration file to run with, so we have to make one now using Nano editor. Nano is the most beautiful, yet versatile, text editor for Debian Linux. Close the current window and open a terminal to write the following commands:

[stextbox id=”grey”][email protected]:/$ sudo nano /etc/
host = localhost
dir = /var/www
file = webcam.jpg
tmp = imageup.jpg
local = 1
device = /dev/video0
width = 176
height = 144
delay = 5
quality = 75
trigger = 180[/stextbox]


  1. I tried the above steps
    Dedian apache works fine on both on my rpi and laptop but when I try
    Opening the webcam server that is
    httpp:// or
    The result it gives is
    404 error url not found
    Plz help as soon as possible

  2. I also attempted to open the webcam server and got the “404 error url not found”. I have gone through many guides and don’t have any positive outcomes. Kindly assist


Please enter your comment!
Please enter your name here