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

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

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

SHARE:

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

Topics: Linux, Hardware, Open Source, Operating Systems

J.A. Watson

About J.A. Watson

I started working with what we called "analog computers" in aircraft maintenance with the United States Air Force in 1970. After finishing military service and returning to university, I was introduced to microprocessors and machine language programming on Intel 4040 processors. After that I also worked on, operated and programmed Digital Equipment Corporation PDP-8, PDP-11 (/45 and /70) and VAX minicomputers. I was involved with the first wave of Unix-based microcomputers, in the early '80s. I have been working in software development, operation, installation and support since then.

Kick off your day with ZDNet's daily email newsletter. It's the freshest tech news and opinion, served hot. Get it.

Talkback

10 comments
Log in or register to join the discussion
  • @JAWatson

    First of all very good article and I looking forward for the rest. I have couple of requests:
    1. RISC OS - I've very little knowledge about it, could you please elaborate about it in your next articles.
    2. Could you please mention, how much it cost you for the total setup?
    Ram U
    • Yes and No

      Hi, yes, good point, it is time to add up the total cost. In the next post of this series (which will include a couple more new pieces of hardware) I will itemize the items and total it all up.

      No, sorry, I can't say much more about RISC OS because pretty much like you I am unfamiliar with it, and anything that I said would likely do it a disservice and probably be wrong. I would suggest that you go to their web page (riscosopen.com) and have a look around, there seems to be a good bit of information there, and there are forums where you might find users with more experience to answer questions for you.

      Thanks for reading and commenting.

      jw
      j.a.watson@...
      • Thanks a lot.

        I have Pi Kit and I would like to use it as my dashboard cam by utilizing one of the unused 5mp camcorder.
        Ram U
  • Thanks

    I just bought a Pi camera module this morning, and then stumbled upon this article. Looking forward to putting two and two together. Thanks for the informative write-up.
    nicknormal
  • Man, are your readers spot on!

    Someone commented very early in this series that they hoped you'd get interested in the RPi, because they KNEW you'd do an outstanding job of explanation, exposition, and thorough, clear important reporting of needed detail (as best I remember what was said).
    Were they ever correct!
    I'll be really disappointed if the Raspberry Pi Foundation doesn't make you an honorary member for the really outstanding job of promoting interest in the Pi which you are doing via this series of yours.
    Please keep it going; I think you're just hitting your stride. Great work!

    Warmest regards...
    styxriver
  • Great to see success with the Pi

    JW,
    Very good writeups on the Raspberry Pi. I too started experimenting with the Pi back in December of last year, and am very excited about it and other similar devices that are slowly appearing on the market (Intel Galileo, etc.). Definitely looking forward to more on the Pi, it's a great little device with an infinite number of possibilities!
    Chris_Clay
  • Camera and Bluetooth

    I want to use the PI to send video to my Android tablet via Blue tooth so I can capture photos.
    The locations I will be in do not support wifi internet. How do I do this?
    Stephen
    Shoumard
  • porting another camera driver in raspberry pi hardware

    Hi Mr. Watson.

    The article is extremely wonderful in its presentation and thanks for sharing the knowledge.

    I would like to add another camera sensor instead of Raspi. I may be using samsung sensor with same interfaces(Mipi).

    1. What are all the things I have to take care(to do list) for this purpose. The linux drivers are available for that sensor.

    2. How can make use of the commands raspstill, raspvid etc

    could you please share your knowledge . Awaiting your earliest response.

    Thanks and Regards,
    Visakh
    svvisakh
    • Using USB camera

      @svvisakh, 1. if You talk about camera with usb interface, this may help: http://nanvel.name/weblog/photo-registrator-raspberry-pi/
      2. try apt-cache find camera or similar to find necessary packages and man raspstill to show manual pages.
      nanvel
  • Camera board case

    Where did you get the camera case from that you used?
    astinton