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. 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:

 

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

hostapd

  • sudo apt-get install hosted
  • /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.
  1. Power on. In 2-3 minutes the open WiFi network RASP_NET should appear.
  2. Connect to it via laptop/smartphone/whatever.
  3. Go to http://10.0.0.1:8080
  4. Chose the desired wireless network, its encryption type and the enter key.
  1. Press the submit button.
  2. Remove the shorting wire from the GPIO.
  3. 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.