Wireless IP Camera – Part 2

Last time I promised to explain how to setup WiFi on the BB.

I don’t want to run cables through my entire house. Also I want to be able to place the camera anywhere in my house. So the security camera will use WiFi as the main connection to the web.  Running Linux, the BB is already internet ready from a software standpoint. However, the BB does not carry WiFi hardware. So we’ll have to connect a WiFi adapter to it. The standard BB comes with one USB slot, so using a USB hub we can attach as many devices as we need. And we need a lot of devices. We’ll be connecting 2 camera’s, a memory stick and a WiFi adapter.

For the wifi adapter I settled on the Sweex LW053. I chose this unit because 1) it is cheap and 2) it is based on the Ralink RT73 chipset which has proper drivers in Linux. Just hooking up the USB-hub and the USB WiFi adapter does not automatically yield a new ethernet device in OpenWRT Linux, however. We’ll have to jump trough a few hoops.

you’ll need to install the RT73 wireless driver which you can find in the make menu when building OpenWRT with:

What I do is instruct menuconfig to create a package for the driver. You can install the opkg package as I explained in the previous post.

You’ll also need to install wireless-tools. In my case I have protected my local WiFi network using WPA encryption. If you want to have your BB connect to your WiFi using WPA you’ll need WPA_supplicant-miniThis will add WPA capability to your BB.

WPA supplicant is the WPA client that negotiates the authorization on your wifi network. On the BB it is configured in the file /etc/wpa_supplicant.conf. Mine looks like this:

Next step is to make sure that the BB knows when to setup this authorization and for what network interface. For this purpose I’ve created a startup script in /etc/init.d which i call network_wifi_cfg it contains:

The first line is to assign an ip-address to the wifi network interface. The second line calls wpa_supplicant with the settings as described above. The third line sets the wifi network interface as the default gateway so all network traffic is routed through the wifi connection. The fourth line makes sure that the BB knows it is in the correct time zone (GMT+1 for me). And the last line makes sure the BB synchronizes it’s time via the internet (through the ntp protocol). This last step is necessary because the BB does not have a battery powered clock on board. It will forget the time when you switch it off.

After figuring out the proper configuration settings to connect to the network. The next step is to make this connection an automatic step after booting the BB. You can do this by creating a symbolic link to your startup script (such as the network_wifi_cfg script above). You can do this manually or use the enable command in OpenWRT, see here.

In the proces of figuring out this automatic connection to the network I came across a vexing issue. When you remotely (via SSH for instance) reboot the BB. The WiFi device would not come up as a network interface. It turns out that certain steps needed to connect to the network are only executed when booting the BB for the first time or upon disconnecting and reconnecting the USB adapter. I finally figured out that manually unloading and reloading the RT73 driver forces these steps. So I’ve added that to the bootup sequence. I’ve added the following lines to my network_wifi_cfg script:

This will reload the RT73 driver upon each reboot.

Now we have a BB that 1) recognizes it’s WiFi adapter on the USB port, and 2) connects automatically to the WiFi network using a secure WPA connection each time it boots. We can now just plugin the BB anywhere in the house and SSH into it (woohoo!).

Next time we’ll give the security cam it’s eyes. Untill next time…

Update: you can find part three here.

  • StumbleUpon
  • Facebook
  • Twitter
  • Google Bookmarks
  • email
  • RSS
This entry was posted in Security. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *