How to setup Wi-Fi on Raspberry Pi

14/01/14
Share

When your computer doesn’t have monitor, keyboard, mouse, or you can’t use cables, the task to get online via Wifi looks difficult and practically impossible. Now you can take your Raspberry Pi – a tiny programmable and affordable computer used for… almost anything – and connect it to a wireless network anywhere you need. DataArt DeviceHive team prepared a special app that helps to link the single-board device to a Wifi point.

With the closure of two contacts on the Raspberry bus-bar, Wifi switches into access point mode. After that, the user connects the Raspberry Pi with a cell-phone or other mobile device, selects the network’s interface and enters the required password. With the contact disjunction, Raspberry Pi automatically connects to the selected network.

All hardware needed and sequence of steps - in this post.

Hardware

The system consists of three devices:

  • Raspberry Pi rev 2
  • USB WiFi dongle (please refer to http://elinux.org/RPi_VerifiedPeripherals#USB_Wi-Fi_Adapters to make the right choice)
  • 1 female-female connection cord as a jumper

System software setup

USB WiFi dongle Driver

Please visit your dongle manufacturer’s site to get the appropriate driver (or build it by yourself, as we are not ones who looking for easy ways and follow the path).

g++
  • sudo apt-get install g++
Wireless Tools
  • wget http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/wireless_tools.29.tar.gz
  • tar xvfz wireless_tools.29.tar.gz
  • cd wireless_tools.29
  • make
  • sudo make install

hostapd

  • sudo apt-get install hostapd
  • /etc/hostapd/hostapd.conf:
    RASPinterface=wlan0
    ssid=RASP_NET
    hw_mode=g
    channel=6
    auth_algs=1
    wmm_enabled=0
            
  • /etc/default/hostapd:
    DAEMON_CONF="/etc/hostapd/hostapd.conf"
    udhcpd
            
  • sudo apt-get install udhcpd
  • /etc/udhcpd.conf:
  • /etc/udhcpd.conf:
    start 10.0.0.2
    end 10.0.0.40
    interface wlan0
    remaining yes
    opt subnet 255.255.255.0
    opt router 10.0.0.1
    opt lease 864000
            
  • /etc/default/udhcpd:
    comment out DHCPD_ENABLED="no"
    interface
            
  • /etc/network/interfaces:
    auto lo
    iface lo inet loopback
    iface eth0 inet dhcp
    auto wlan0
    iface wlan0 inet static
    address 10.0.0.1
    netmask 255.255.255.0
    start-up script
            
  • /etc/rc.local:
    service hostapd start
    service udhcpd start
    /path-to-server/server_binary
            

Work sequence

From technical details to practice:

  1. Place the server binary file in any folder along with index.html.
  2. Install the USB wifi dongle and drivers.
  3. Perform software setup.
  4. Shut down RPi.
  5. Short pins 3 and 6 on the GPIO port.
  6. Power on. In 2-3 minutes the open WiFi network RASP_NET should appear.
  7. Connect to it via laptop/smartphone/whatever.
  8. Go to http://10.0.0.1:8080
  9. Chose the desired wireless network, its encryption type and the enter key.
  10. Press the submit button.
  11. Remove the shorting wire from the GPIO.
  12. WiFi network RASP_NET should disappear.

Your RaspberryPi now is connected to selected network. And it’s your turn to take advantage of the new features.

Sign Up for Updates!

Subscribe now to receive industry-related articles and updates

Choose industries of interest
Thank You for Joining!

You will receive regular updates based on your interests. No spam guaranteed

Add another email address
Read more
Sign Up for Updates!
Choose industries of interest
Thank You for Joining!

You will receive regular updates based on your interests. No spam guaranteed

Add another email address
Welcome
We are glad you found us
Please explore our services and find out how we can support your business goals.
Get in Touch
travel-risk-management-social.png
Download the white paper «Brave New World»: Information Technology in the Post-COVID Environment

DataArt experts and practice leaders examine the role information technologies will play in helping businesses across multiple industrial sectors respond to the «new normal» demands.