Raspberry Pi add-ons: My experiments with camera and wi-fi

Adding a high-res camera and a USB wi-fi dongle for more fun with the Pi

In the first four posts of this seried, I examined the various operating systems included in the Raspberry Pi NOOBS distribution: first Raspbian and then Arch and Pidora , then the XBMC focused Raspbmc and OpenELEC , and finally the non-Linux option, RISC OS

Now I am going to move on to some different kinds of fun with the Raspberry Pi, adding some optional hardware to it.

First up is one of the most popular Raspberry Pi add-ons, the camera module. The basic unit is nothing more than a small circuit board with a ribbon cable attached.

Rasberry Pi Camera
The basic Raspberry Pi Camera module

There are two different camera modules available, a "standard" HD 5 Megapixel with 2592x1944 still resolution and video at 1080p 30fps, 720p 60fps or 640x480 60/90fps, and the NoIR Infrared unit for low light phtography. 

The name NoIR comes from the fact that the infrared filter has been removed from the standard camera module, thus the general specifications for the NoIR camera are the same as the original camera (duh, it's the same module). The board size is 20x25mm, and it weighs about 3g.

The ribbon cable connects to an Insulation Displacement Connector located between the ethernet and HDMI ports on the Pi board.

This is a typical push-pinch kind of thing, if you have ever replaced a laptop keyboard for example you are probably familiar with it. Most of the Pi cases have a slot located above this connector for the flat cable to pass through, and then you have... well, if you only purchased the basic camera module, you have the camera board flopping around in the air.

There are three different mount/case units available that I am aware of. In order of increasing sophistication, cost and aesthetic appeal, they are the simple Pi Camera Mount, which is not much more than a block with screws in the right places to mount the camera module (still exposed) and a hole in the bottom so it can be mounted on a tripod; or several variations of camera cases, some made to match particular Pi board cases; or the Pi-Pan unit, which has servo-driven pan (180°) and tilt (110°) capability.  You can even add a light ring with four LEDs around the camera module.

Pi Camera Mounts
The Three Types of Camera Mounts

I bought one of the camera cases pictured in the center above. I sort of had it in my head that they were roughly the size of the Raspberry Pi case itself, but it is not (this is a good thing), it is just large enough to hold the camera circuit board. 

Assembling the board and case is not entirely trivial or obvious at first. There are slots cut inside each side of the case, you have to seat the camera board into those slots - but it is a tight fit, it has to be because this is what keeps the camera still once it is mounted. So you have to carefully spread the side of the case very slightly to get the board to slide into place and seat properly. Also, don't forget to remove the tiny plastic protective cover from the camera lens before closing the case.

If you have a case for your Raspberry Pi, you have to thread the camera flex cable through the slot in the case. If you have a cute "layer cake" style case, as I do, you have to thread the flex cable through each layer. I thought that case was a minor PITA when I originally assembled it, but with the camera cable threaded through, it is no longer minor.

The Raspberry Pi Camera post includes a video showing how to connect the camera to the Pi board, and instructions on how to configure Raspbian for it. Be sure to follow these instructions carefully - in particular, running raspi-config to enable the camera and then reboot.  The instructions the explain how to use raspistill to take a still picture with the camera and raspivid to take a video, with the output saved in files. 

I took the obvious approach and tried a still picture first - and just about jumped out of my chair when a video of my mug came up on the display. It turns out that raspistill actually runs the camera to make a video, and then simply saves the final frame of the video as the still picture. I thought that these were a couple of cute, simple little demo programs, until I got curious about their command line options.  Try typing raspistill -? and have a look at the list of options. Wow.

The instructions also include a description of how to stream video from the camera and view it on another computer. I think these are excellent for a simple demonstration of what can be done, but they are rather impractical for most real world uses.

Having to know the IP addresses of both systems, and using nc (netcat) to send and receive the data across the network... well, it's great to prove that eveything works, but if you want to do anything more serious than that, try searching the web for 'Raspberry Pi camera monitor' and such terms. There are lots of descriptions of interesting projects out there, many of which are really quite easy to implement. 

One last note and warning about the camera. If you are an experienced Linux user, the first thing you are likely to do to try out a camera is run cheese. In most cases that is a quick, easy and reliable way to test; in this case, it will be a disappointment. 

The cheese program is just too much for the poor little RasPi CPU; if you watch the monitor in the bottom panel of the Raspbian LXDE screen, you'll see the cpu use peg out at 100 percent and stay there, perhaps forever. So my advice is to stick with the raspistill and raspivid programs for testing and demonstration.

The other hardware that I have added to my Raspberry Pi is a USB WiFi network adapter. There are two things to worry about here, first what wi-fi adapters will work with the least bother, and second how to actually get the adapter configured and the network connection working. 

So far I have tried two USB wi-fi adapters, one that I ordered from the Pi-Shop which clearly stated "works out of the box with Raspian" (nothing like starting out nice and conservative), and then later I remembered that I still had an old ASUS wi-fi adapter laying around. The good news here is that both of these adapters really did work out of the box with Raspbian! 

The one I ordered from the Pi-Shop is a "nano dongle" adapter, with just a small knob extending from the USB port, and LEDs visible through the slots between the nano head and the USB port. It is as "no-name" as anything I have ever seen, there is not one indication of a manufacturer anywhere on the adapter or the packaging that came with it (unless the manufacturer's name is "802.11n").

According to lsusb -v it contains a Realtek RTL8188CUS chip: the important thing is that it was recognized and configured by Rapbian with no trouble, and it works perfectly. There was also a "Driver Installation & Manual CD" included in the package, which you can throw very happily into the trash because Linux doesn't need it. 

The wi-fi adapter that I already had is an ASUS USB-N13. It is much larger than the nano adapter, about the size and shap of a large USB flash memory stick. It was also recognised and configured automatically, and it also works without a hitch.

With Raspbian running, plug in the USB wi-fi adapter. If there are status LEDs on the device (there almost always are) after a few seconds they should come on, indicating that the adapter has been recognised and the driver loaded. 

Double-click on the wi-fi Config icon (on the desktop), and then click Scan. If all is well, you should get a list of available wireless networks, which hopefully includes the one you want to connect. Select the network, enter the WPA key if needed, and it should connect. 

That's it. No drivers to load, no other configuration necessary before or after this. Once it has been configured this way it will be saved across shutdown and reboot, so it should connect on boot automatically thereafter.

Raspbian WiFi
Raspbian WiFi Config

Performance of the wireless adapters is acceptable, but not spectacular. According to the Bandwidth Place both of the wireless adapters do 14Mbps download and 3.25Mbps upload, while the wired connection does 18.25Mbps download and 4.75Mbps upload. 

However, from casually watching the CPU usage monitor while these tests were running, I have a feeling that the speed was being limited by the system processing the sent/received data file, not by the effective network speed. For comparison, my Lenovo T400 on a wired connection gets about 20Mbps download and about 5Mbps upload.

With OpenELEC the procedure is only slightly more difficult.  From what I have found on the internet, it appears that it used to be somewhat more tedious to get wi-fi working on OpenELEC, but with the latest version, all I had to do was go to System / OpenELEC / Network, and make sure Wireless Networks / Active is enabled. 

Then on Connections there is a list of available wireless networks, and I selected my home network. A window popped up for Connect/Refresh, I clicked Connect, and then another window came up where I could type the WPA passphrase/key and then clicked Done

This should get you connected. Unfortunately, there seems to be a problem with OpenELEC and very long WPA2 keys, so I have not been able to get mine connected. I have searched in vain for a solution - but I did find a response, apparently from one of the OpenELEC developers, to someone else who had this problem, which basically said "you don't need a WPA key that long". That's not terribly helpful.

I am not going to discuss wi-fi configuration in detail on the other Raspberry Pi operating systems, for the following reasons:

  • Arch Linux ARM - If you're good enough to run Arch, you don't need me to tell you how to configure wireless networking and I don't want to insult anyone.
  • Pidora - Mostly because I would like to let this die a natural death, but also because it is a simple Network Manager configuration. 
  • Raspbmc - The procedure is almost identical to OpenELEC, you just get to it by going to Programs / Settings / Raspbmc Settings.
  • RISC OS - As far as I have been able to determine, there is no wireless support. If anyone knows otherwise, please speak up in the comments.

So, with these two bits of add-on hardware, the Raspberry Pi is more portable - because of the wireless connection - and has a camera attached.

So it could be set up as a surveillance device, for example. Which is kind of ironic, since I remember something about using Unix-based systems for remote monitors of coke machines at CMU, amoung others. 

Of course, people today are coming up with lots of different, interesting and inventive uses for the PiCam, just check the blog on the Raspberry Pi web page!

Related stories


You have been successfully signed up. To sign up for more newsletters or to manage your account, visit the Newsletter Subscription Center.
Subscription failed.
See All