This guide details how to setup a WIFI Hotspot using the Edimax USB WIFI adapter on an EmonPi or EmonBase to make it possible to connect directly to an EmonPi from a tablet or computer without the need for a router or internet connection.
The guide is based on Dave Conroy's guide here but also covers setting up a DHCP server rather than ethernet to WIFI bridge.
http://www.daveconroy.com/turn-your-raspberry-pi-into-a-wifi-hotspot-with-edimax-nano-usb-ew-7811un-rtl8188cus-chipset
There are 3 pieces of software that need to be installed to get this to work:
sudo apt-get install hostapd isc-dhcp-server
2) Install Edimax version of hostapd (this uses Dave Conroy's precompiled binary, see Dave Controy's tutorial for information on compiling this yourself)
wget http://www.daveconroy.com/wp3/wp-content/uploads/2013/07/hostapd.zip
unzip hostapd.zip
sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.bak
sudo mv hostapd /usr/sbin/hostapd.edimax
sudo ln -sf /usr/sbin/hostapd.edimax /usr/sbin/hostapd
sudo chown root.root /usr/sbin/hostapd
sudo chmod 755 /usr/sbin/hostapd
3) Configure /etc/network/interfaces
Open the network interfaces file to edit:
sudo nano /etc/network/interfaces
Replace content with:
auto lo
iface lo inet loopback
auto eth0
allow-hotplug eth0
iface eth0 inet manual
# auto wlan0
# allow-hotplug wlan0
iface wlan0 inet static
address 10.0.1.1
netmask 255.255.255.0
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
auto wlan1
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
4) Configure /etc/hostapd/hostapd.conf
Open hostapd config file with:
sudo nano /etc/hostapd/hostapd.conf
Add the following lines to hostapd.conf
interface=wlan0
driver=rtl871xdrv
bridge=br0
ssid=EmonPi
channel=1
wmm_enabled=0
wpa=1
wpa_passphrase=raspberry
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
auth_algs=1
macaddr_acl=0
Manual start: sudo hostapd -dd /etc/hostapd/hostapd.conf
5) Configure /etc/default/hostapd
sudo nano /etc/default/hostapd
Set DAEMON_CONF="/etc/hostapd/hostapd.conf"
6) Configure /etc/dhcp/dhcpd.conf
Open dhcpd config file:
sudo nano /etc/dhcp/dhcpd.conf
Add the following to the end of the file:
lease-file-name "/home/pi/data/dhcpd.leases";
subnet 10.0.1.0 netmask 255.255.255.224 {
range 10.0.1.2 10.0.1.20;
}
7) Configure /etc/default/isc-dhcp-server
sudo nano /etc/default/isc-dhcp-server
Remove the comment from DHCPD_CONF, DHCPD_PID and then set the INTERFACES to wlan0, or replace with the following:
# Defaults for isc-dhcp-server initscript
# sourced by /etc/init.d/isc-dhcp-server
# installed at /etc/default/isc-dhcp-server by the maintainer scripts
#
# This is a POSIX shell fragment
#
# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
DHCPD_CONF=/etc/dhcp/dhcpd.conf
# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
DHCPD_PID=/var/run/dhcpd.pid
# Additional options to start dhcpd with.
# Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
#OPTIONS=""
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACES="wlan0"
8) Edit /etc/rc.local
sudo nano /etc/rc.local
Add before exit 0 the following lines to tell the wlan interface to use ip address 10.0.1.1 and then start the isc-dhcp-server:
sudo ifconfig wlan0 10.0.1.1
sudo service isc-dhcp-server start
9) Copy existing dhcpd.leases file to writeable partition on /home/pi/data
sudo cp /var/lib/dhcp/dhcpd.leases /home/pi/data
Thats it restart your emonpi/emonbase to finish and then connect to network EmonPi with password: raspberry
Useful blogs, guides and forum threads that I used to work out how to set up the above:
http://www.daveconroy.com/turn-your-raspberry-pi-into-a-wifi-hotspot-with-edimax-nano-usb-ew-7811un-rtl8188cus-chipset
http://askubuntu.com/questions/140126/how-do-i-configure-a-dhcp-server
http://ubuntuforums.org/showthread.php?t=2068111
http://raspberrypi.stackexchange.com/questions/9678/static-ip-failing-for-wlan0
https://forums.opensuse.org/showthread.php/438756-DHCP-can-t-write-to-dhcpd-leases
http://elinux.org/RPI-Wireless-Hotspot
http://askubuntu.com/questions/140126/how-do-i-configure-a-dhcp-server
The guide is based on Dave Conroy's guide here but also covers setting up a DHCP server rather than ethernet to WIFI bridge.
http://www.daveconroy.com/turn-your-raspberry-pi-into-a-wifi-hotspot-with-edimax-nano-usb-ew-7811un-rtl8188cus-chipset
There are 3 pieces of software that need to be installed to get this to work:
- hostapd – WIFI Hotspot
- edimax version of hostapd
- isc-dhcp-server – DHCP Server
sudo apt-get install hostapd isc-dhcp-server
2) Install Edimax version of hostapd (this uses Dave Conroy's precompiled binary, see Dave Controy's tutorial for information on compiling this yourself)
wget http://www.daveconroy.com/wp3/wp-content/uploads/2013/07/hostapd.zip
unzip hostapd.zip
sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.bak
sudo mv hostapd /usr/sbin/hostapd.edimax
sudo ln -sf /usr/sbin/hostapd.edimax /usr/sbin/hostapd
sudo chown root.root /usr/sbin/hostapd
sudo chmod 755 /usr/sbin/hostapd
3) Configure /etc/network/interfaces
Open the network interfaces file to edit:
sudo nano /etc/network/interfaces
Replace content with:
auto lo
iface lo inet loopback
auto eth0
allow-hotplug eth0
iface eth0 inet manual
# auto wlan0
# allow-hotplug wlan0
iface wlan0 inet static
address 10.0.1.1
netmask 255.255.255.0
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
auto wlan1
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
4) Configure /etc/hostapd/hostapd.conf
Open hostapd config file with:
sudo nano /etc/hostapd/hostapd.conf
Add the following lines to hostapd.conf
interface=wlan0
driver=rtl871xdrv
bridge=br0
ssid=EmonPi
channel=1
wmm_enabled=0
wpa=1
wpa_passphrase=raspberry
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
auth_algs=1
macaddr_acl=0
Manual start: sudo hostapd -dd /etc/hostapd/hostapd.conf
5) Configure /etc/default/hostapd
sudo nano /etc/default/hostapd
Set DAEMON_CONF="/etc/hostapd/hostapd.conf"
6) Configure /etc/dhcp/dhcpd.conf
Open dhcpd config file:
sudo nano /etc/dhcp/dhcpd.conf
Add the following to the end of the file:
lease-file-name "/home/pi/data/dhcpd.leases";
subnet 10.0.1.0 netmask 255.255.255.224 {
range 10.0.1.2 10.0.1.20;
}
7) Configure /etc/default/isc-dhcp-server
sudo nano /etc/default/isc-dhcp-server
Remove the comment from DHCPD_CONF, DHCPD_PID and then set the INTERFACES to wlan0, or replace with the following:
# Defaults for isc-dhcp-server initscript
# sourced by /etc/init.d/isc-dhcp-server
# installed at /etc/default/isc-dhcp-server by the maintainer scripts
#
# This is a POSIX shell fragment
#
# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
DHCPD_CONF=/etc/dhcp/dhcpd.conf
# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
DHCPD_PID=/var/run/dhcpd.pid
# Additional options to start dhcpd with.
# Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
#OPTIONS=""
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACES="wlan0"
8) Edit /etc/rc.local
sudo nano /etc/rc.local
Add before exit 0 the following lines to tell the wlan interface to use ip address 10.0.1.1 and then start the isc-dhcp-server:
sudo ifconfig wlan0 10.0.1.1
sudo service isc-dhcp-server start
9) Copy existing dhcpd.leases file to writeable partition on /home/pi/data
sudo cp /var/lib/dhcp/dhcpd.leases /home/pi/data
Thats it restart your emonpi/emonbase to finish and then connect to network EmonPi with password: raspberry
Useful blogs, guides and forum threads that I used to work out how to set up the above:
http://www.daveconroy.com/turn-your-raspberry-pi-into-a-wifi-hotspot-with-edimax-nano-usb-ew-7811un-rtl8188cus-chipset
http://askubuntu.com/questions/140126/how-do-i-configure-a-dhcp-server
http://ubuntuforums.org/showthread.php?t=2068111
http://raspberrypi.stackexchange.com/questions/9678/static-ip-failing-for-wlan0
https://forums.opensuse.org/showthread.php/438756-DHCP-can-t-write-to-dhcpd-leases
http://elinux.org/RPI-Wireless-Hotspot
http://askubuntu.com/questions/140126/how-do-i-configure-a-dhcp-server