Tag Archives: edimax EW-7811Un

Using a Raspberry Pi as a wireless robot controller

This is a step by step guide on how to configure a Raspberry Pi as I did for a wireless robot controller. Please note – some of the software versions may change over time.

Download/Install Raspbian:
If you already have your Pi installed and set up, skip this section

  1. Plug your SD card into your computer.
  2. Format the SD card with software here.
  3. Download NOOBS (offline and network install) here.
  4. Unpack the .zip file onto your SD card.
  5. Plug your SD card into your Pi.

Configure Raspbian

  1. Set up and power up your Raspberry Pi.
  2. If you are prompted to log in, use pi as the login, and raspberry as the password.
  3. Configure your keyboard – the Raspberry Pi keyboard file is located here: /etc/default/keyboard
    • Use nano command: nano /etc/default/keyboard
    • Change the line
      XKBLAYOUT="gb"

      to the line

      XKBLAYOUT="us"
  4. Use reboot command: reboot 
  5. Once the Pi has rebooted and you have logged in again, remove the login prompt for the Raspberry Pi:
    • Change to superuser: sudo su
    • Use nano command: nano /etc/inittab
    • Comment out this line
      1:2345:respawn:/sbin/getty 38400 tty1

      by adding a # at the beginning

      
       #1:2345:respawn:/sbin/getty 38400 tty1
    • Add this line below
      1:2345:respawn:/bin/login -f root tty1 </dev/tty1 >/dev/tty1 2>&1
  6. Your Pi should be good to go. Test that the changes have worked by rebooting: reboot

Get Wireless Connected

  1. Plug in your Edimax EW-7811Un Wireless Adapter and reboot your Raspberry Pi: reboot
  2. Check that the Pi is reading the device: lsusb
  3. Check that the Pi has the right drivers: lsmod
  4. Change network interfaces: nano /etc/network/interfaces
    1. auto wlan0
      allow-hotplug wlan0
      iface wlan0 inet manual
      wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
  5. Add your wireless network to the end of your WPA supplicant: nano /etc/wpa_supplicant/wpa_supplicant.conf
    1. network={
      <see this link to configure for your network>
      <want to learn more on this?>
      }
      
  6. Reboot your system: reboot
  7. Check your ip address: ifconfig or ifconfig wlan0

Install Python Tools

  1. Make sure your Raspberry Pi is connected to the internet.
  2. Enable easy_install from command line: python ez_setup.py
  3. Install cherrypy: easy_install cherrypy
  4. Install RPIO: easy_install -U RPIO

Get Files in Place

  1. Download raspberry_pi_robot_code onto your Raspberry Pi.
  2. Unzip and move files:
    • robot.py, command.py, and start_robot.py should all be placed on your desktop
    • robot_server should be moved to: /etc/init.d/
  3. Open a terminal.
  4. Make sure all files are owned by root user. If not: sudo chown root /root/desktop/* and sudo chown root /etc/init.d/robot_server
  5. Make robot_server executable: sudo chmod 755 /etc/init.d/robot_server
  6. Register the robot_server file with startup: sudo update-rc.d robot_server defaults

You should be able to reboot: reboot and the robot server should start right up. Open an internet browser on another computer in the local network and go to the Raspberry Pi’s IP address.