Connect to WiFi
Materials
AMB82-mini x 1
Example
Introduction
There three common encryption type in WiFi connection. The first one is “OPEN”, which means there is no password needed to connect to this network. The second type of encryption is WPA, which requires the correct password to access. The third type is WEP, which requires a hexadecimal password and a keyindex.
In the following, we will give a brief introduction on how to establish WiFi connection with these three types of encryptions on Ameba.
First, make sure the correct Ameba development board is selected in “Tools” -> “Board”.
Open (WiFi connection without password)
Open example in “File” -> “Examples” -> “WiFi” -> “ConnectToWiFi” -> “NoEncryption”
In the sample code, modify “ssid” to be the same as the WiFi SSID to be connected to.
Next, upload the sample code, and press the reset button on Ameba. Then you will see a message “You’re connected to the networkSSID: XXXXX”, and the information of this WiFi connection is printed in the serial monitor every 10 seconds.
WiFi connection with WPA encryption
Open example in “File” -> “Examples” -> “WiFi” -> “ConnectToWiFi” -> “WPA_Security”
In the sample code, modify “ssid” to the WiFi SSID to be connected to and “pass” to the network password.
If you prefer to enter your SSID & password in the Serial monitor while
the program is running, uncomment #define MANUAL_INPUT
at the top of the
file.
Next, upload the sample code, and press the reset button on Ameba. Then you will see a message “You’re connected to the networkSSID: XXXXX”, and the information of this WiFi connection is printed in the serial monitor every 10 seconds.
Note: If you enabled MANUAL_INPUT, after uploading the sample code and pressing the reset button on Ameba, input your SSID in the Serial monitor and press enter. Next, input your password, and press enter. Then you will see a message “You’re connected to the networkSSID: XXXXX”, and the information of this WiFi connection is printed in the serial monitor every 10 seconds.
WiFi connection with WEP encryption
Open example in “File” -> “Examples” -> “WiFi” -> “ConnectToWiFi” -> “WEP_Security”
In the sample code, modify “ssid” to the SSID to be connected, “key” to the hexadecimal password, “keyIndex” to your key index number.
If you prefer to enter your SSID & password in the Serial monitor while
the program is running, uncomment #define MANUAL_INPUT
at the top of the
file.
Next, upload the sample code, and press the reset button on Ameba. Then you will see a message “You’re connected to the networkSSID: XXXXX”, and the information of this WiFi connection is printed in the IDE every 10 seconds.
Note: If you enabled MANUAL_INPUT, after uploading the sample code and pressing the reset button on Ameba, input your SSID in the Serial monitor and press enter. Next, input your key and press enter. Finally enter your password and press enter. Then you will see a message “You’re connected to the networkSSID: XXXXX”, and the information of this WiFi connection is printed in the serial monitor every 10 seconds.
Code Reference
Comparison with Arduino
#include
to
use SPI to communicate with WiFi module.#include
is not needed.