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