Configuring Wi-Fi and USB Dongles#
Contents
Warning
Using the Raspberry Pi’s built-in Wi-Fi is not recommended. It introduces high amplitude RF noise into the Raspberry Shake, which can seriously compromise the seismic signal. This occurs because the Wi-Fi antenna is located very close to the Shake board.
Note
The Raspberry Pi 3 Model B’s wifi, which we do not recommend using, is limited to 2.4 GHz wifi connections. So “5G” connections, for example, will not work.
For general home or education purposes#
Wi-Fi can be configured from the Raspberry Shake’s internal web configuration page at http://rs.local/.
Open the page and click Settings (gear icon on the left).
Select Network and then Wi-Fi Settings.
Check Connect to Wi-Fi, then click the refresh icon next to Network SSID.
Wait for the list to appear, and then select your desired Wi-Fi network.
Enter the password and click Test Wi-Fi.
Once the test succeeds, scroll down and click Save and Restart.
Your Raspberry Shake will reconnect automatically via Wi-Fi after reboot.
Step-by-step guide for advanced users#
Connect to your Shake Pi over SSH:
$ ssh myshake@rs.local
(See How to access your Raspberry Shake’s computer via ssh for more details.)
Confirm that the Wi-Fi interface is enabled:
$ cat /etc/network/interfaces
Ensure these lines exist:
allow-hotplug wlan0 iface wlan0 inet dhcp wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
If not, edit the file and add them:
$ sudo nano /etc/network/interfaces
Edit the Wi-Fi credentials with:
$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Add your network details:
network={ ssid="SSID of your wifi" psk="password of your wifi" proto=RSN key_mgmt=WPA-PSK pairwise=CCMP auth_alg=OPEN }
For open networks (with no password):
network={ ssid="SSID of your wifi" key_mgmt=NONE }
Reboot your Shake:
$ sudo reboot
Setting up a USB Wi-Fi Dongle#
Verify your dongle’s compatibility via https://elinux.org/RPi_USB_Wi-Fi_Adapters.
Then plug your USB Dongle into your RPi and see if the RPi recognizes the device. For example:
$ sudo dmesg -T | grep usb
A successful detection looks similar to this output:
$... [Fri Aug 3 13:45:11 2018] usb 1-1.4: new high-speed USB device number 4 using dwc_otg [Fri Aug 3 13:45:11 2018] usb 1-1.4: New USB device found, idVendor=0bda, idProduct=8176 [Fri Aug 3 13:45:11 2018] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [Fri Aug 3 13:45:11 2018] usb 1-1.4: Manufacturer: Realtek [Fri Aug 3 13:45:11 2018] usb 1-1.4: SerialNumber: 00e04c000001 [Fri Aug 3 13:45:12 2018] usbcore: registered new interface driver rtl8192cu
Now try this command and see if the RPi mounts the Dongle as wlan:
$ iwconfig eth0 no wireless extensions. docker0 no wireless extensions. vethba76434 no wireless extensions. wlan0 unassociated Nickname:"<WIFI@REALTEK>" Mode:Auto Frequency=2.412 GHz Access Point: Not-Associated Sensitivity:0/0 Retry:off RTS thr:off Fragment thr:off Power Management:off Link Quality:0 Signal level:0 Noise level:0 Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 Tx excessive retries:0 Invalid misc:0 Missed beacon:0 lo no wireless extensions. vetheb6d057 no wireless extensions.
As you can see, the RPi’s OS sees our Dongle as wlan0. But why wlan0 if the Raspberry Pi boards have their own Wi-Fi module inside? This is because, by default, wlan0 is disabled on Raspberry Shake.
The next step will be to adjust your config file to match your Wi-Fi parameters as described in the section above and reboot your RPi.
If your USB dongle is not recognized#
Warning
The http://fars-robotics.net/ website linked below appears to have been taken down. As of now, we have not found a replacement, so you’ll have to Google your way using your WiFi dongle maker/model/lsusb codes as a reference. A good starting point would be checking/asking on the Raspberry Pi forum at https://forums.raspberrypi.com/.
If the Shake does not recognize your Wi-Fi dongle, it may lack the correct driver (or it may be using the wrong one). This used to be a very frustrating problem until we discovered a bash script that downloads and installs the correct driver for your device automatically based on its USB code.
The script is at http://fars-robotics.net/, clicking on Wifi Drivers. Although it is generally not a good idea to run code directly from the web, this process has never failed us when all else does. To run the script, you need to save it somewhere on your path. Follow these instructions to download and make it executable:
$ sudo wget http://downloads.fars-robotics.net/wifi-drivers/install-wifi -O /usr/bin/install-wifi
$ sudo chmod +x /usr/bin/install-wifi
$ sudo install-wifi
Essentially this script checks the lsusb codes of USB devices against a compiled list, then downloads and installs the correct driver for any devices it recognizes as a WiFi dongle.
What to do if there are two wlan devices#
Sometimes the USB dongle activation process will result in both the internal and USB wifi modules on at the same time. This will look similar to the following:
$ iwconfig
eth0 no wireless extensions.
docker0 no wireless extensions.
vethba76434 no wireless extensions.
wlan0 IEEE 802.11 ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=31 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:on
wlan1 unassociated Nickname:"<WIFI@REALTEK>"
Mode:Auto Frequency=2.412 GHz Access Point: Not-Associated
Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Power Management:off
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
lo no wireless extensions.
vetheb6d057 no wireless extensions.
In this case, wlan0 is the internal device and wlan1 is the USB dongle. This could be switched based on your setup, and may change after a restart.
This defeats the purpose of using the USB WiFi, because the internal module will generate radiofrequency noise that will affect the data, which is what we are trying to avoid by using the dongle in the first place.
To disable the internal WiFi:
Disable the internal module in the boot config:
$ sudo nano /boot/config.txt
Add this line:
dtoverlay=pi3-disable-wifi
Add the internal module to the modprobe blacklist:
$ sudo nano /etc/modprobe.d/raspi-blacklist.conf
Adding:
blacklist brcmfmac blacklist brcmutil
Now, restart the Shake, run iwconfig, and check to make sure that only the wlan0 device appears.
Advanced Configuration#
Scanning for available Wi-Fi networks#
To view visible networks:
$ sudo iwlist wlan0 scanning
This displays signal strength, encryption type, and channel for each detected access point.
Encrypting your Wi-Fi password#
You can encrypt your Wi-Fi password using the wpa_passphrase command:
$ wpa_passphrase <your_wifi_ssid_here> <your_wifi_password_here>
For example:
$ wpa_passphrase mywifi mypasswd
This will generate:
network={
ssid="mywifi"
#psk="mypasswd"
psk=175c63e5acd5b9bb66cfe2f89857db9060f2edf3989c89c19e5a54e5044cd2a4
}
Copy this output to /etc/wpa_supplicant/wpa_supplicant.conf and remove the #psk line to make it fully encrypted.
Enabling both Wi-Fi and Ethernet#
When your Shake Pi boots, if it detects that an Ethernet interface is active, WiFi will be turned off by default. This is how Ethernet and WiFi network connections work with each other:
If an ethernet cable is plugged in, and the setting in the configuration file is OFF, WiFi drivers will be automatically turned off at system boot to avoid unnecessary spikes in the signal.
If no ethernet cable is plugged in, and if WiFi is properly configured, a connection will be made to the WiFi network; the setting in the WiFi configuration file is ignored.
If an ethernet cable is plugged in, and the end-user wants a dual network connection over a WiFi network, then WiFi must be properly configured and the setting in the WiFi configuration file must be set to ON (see below).
Edit the file /opt/settings/user/enable-wifi.conf:
$ sudo nano /opt/settings/user/enable-wifi.conf
Change the default final line from
OFFtoON.Reboot the Shake:
$ sudo reboot