Latest posts

Connect to Wi-Fi Directly from PiStorms!

Introduction

Many project require your Raspberry Pi to have access to the internet. You can attach an Ethernet cable, but that does not give your robot any mobility. Luckily, the Raspberry Pi 3 already has Wi-Fi built in! This tutorial provides instructions on how to connect to a Wi-Fi network directly from PiStorms without having to attach a monitor or access the Raspberry Pi through SSH.

This tutorial has instructions to:

  1. Connect to a Wireless Network
  2. Disconnect from a Wireless Network
  3. Test Internet Connectivity
  4. Revert Wi-Fi Configuration Changes

 

Connect to a Wireless Network

Before you start, make sure you know the network details. You will need the network name (SSID) and a secret passcode if the connection is secured.

First, run the “WiFi_Setup” program. You will see a list of available networks. A closed lock means that the network is secured while an open lock signifies an open network.

At the top of the screen, you will either see a “Not Connected” or “Connected to:” message depending on the state of your connection.

Use the arrows (“<” and “>”) to navigate between pages. The available networks are listed alphabetically. If the network is hidden (SSID broadcasting is disabled), it will show up as a “Hidden Network” and be at the top of the list. You may also exit the menu any time by pressing the “GO” button on the shield.

Once you find your network, select it using the touch screen. If you are already connected to a different network, you do not have to “Leave” it before establishing a new connection. Once the network is selected, the program will ask for confirmation. You may cancel or continue.

Note: the previous connection will be aborted even if you do not successfully connect to the new network.

Unless the wireless network is open, the script will prompt you for a secret passcode. If the router is configured to use WEP, the key must have a 5 or 13 ASCII characters or have 10 or 26 hexadecimal digits (case insensitive). If you are using WPA, the pre-shared key must have at least 8 characters. The script automatically identifies the encryption type, and the security key you have should already match the requirements.

The on-screen keyboard shows four characters at a time. Use the arrows to navigate through the character set or use the buttons on the top to select the characters.

  • Shft – Shift, switch between uppercase and lowercase
  • Abc – English alphabet
  • ?-! – special characters and space (space looks like an empty button)
  • 123 – numbers
  • Clr – clears the input box
  • Bsp – backspace (deletes the last character)

Press “Submit” to continue. You will see a loading image while the changes are applied. This may take anywhere from a few seconds to a minute depending on your Wi-Fi network.

If the key has invalid length, the program will notify you.

If you entered the passcode correctly, the screen should now show a green “Connected to:” message with your network name underneath. If you still see “Not Connected”, try re-entering the password or restart the Raspberry Pi if you are certain that it was correct.

You can now exit the program by pressing “GO” button on the shield.

If you run the About_Me script from the file explorer, it should now show your local (LAN) IP address next to “wlan0”.

If your network connection has access to the internet (WAN), you may test it with the “TestInternetConn” script (instructions are below).

Note, if your Raspberry Pi has more than one Wi-Fi adapter, the script will only use the “wlan0” one.

 

Disconnect from a Wireless Network

If you want to disconnect from a wireless network, run the WiFi_Setup script. You should see a “Leave” button in the top right corner. If it is not there, you are already disconnected.

Press the “Leave” button. The script will ask for confirmation. Press “Continue” to disconnect. A loading image will display while the changes are being applied.

You should now see a red “Not Connected” message on the top.

You may exit with the “GO” button on the shield.

 

Test Internet Connectivity

If your wireless connection has access to the internet (WAN), run the “TestInternetConn” Program from the file browser. You will see a loading image while the Raspberry Pi attempts to connect a server on the WAN. The script should not take any longer than 5 seconds.

If the internet connection was successful, you will see a green success message. Else, you will see a red X with an error message.

Press “Continue” to exit.

 

Revert Wi-Fi Configuration Changes

The Wi-Fi Setup script modifies the “wpa_supplicant.conf” file to manage wireless connections. Each time the script makes a change; it saves a backup copy of the configuration file prior to editing it.

If your internet stops working after you change connection settings using the WiFi_Setup script, you cannot connect to any network, the WiFi_Setup script gives you an error, or you want to reconnect to a network with a previous key; use the RevertWiFiConf script to roll back the previous configurations.

You will see a list of backups with the most recent one on the top. Use the arrows to navigate through the options. Once you find the correct date, select it. Press “Continue” at the confirmation screen to apply changes.

As the changes are applied, you will see a loading image. Once the settings have been reverted, you will see a green success message.

Press “Continue” to exit.

You may now go back to the WiFi_Setup script to verify the state of your Raspberry Pi’s internet connection.

Posted in: How to, PiStorms

Leave a comment