材料準備
Ameba x 1
範例說明
WPA加密模式的WiFi連線
打開 Connect With WPA 的範例, “File” -> “Examples” -> “AmebaWiFi” -> “ConnectWithWPA”
在SSID後修改“yourNetwork”為要連線的WiFi名稱, “secretPassword”改為對應的密碼。
修改之後上傳程式碼,按下Ameba的Reset按鈕, 這時候會看到You’re connected to the networkSSID: XXXXX,以及後面會每十秒列印出WiFi信息。
WEP加密模式的WiFi連線
打開 Connect With WEP 的範例, “File” -> “Examples” -> “AmebaWiFi” -> “ConnectWithWEP”

在SSID後修改“yourNetwork”為要連線的WiFi名稱, key改為對應的十六進制的密碼,keyIndex 修改為對應的數字。
修改之後上傳程式碼,按下Ameba的Reset按鈕, 這時候會看到You’re connected to the networkSSID: XXXXX,以及後面會每十秒列印出WiFi信息。
常見的WiFi有三種加密方式,一種為OPEN,即沒有密碼,第二種為WPA,即我們通常使用的密碼,第三種為WEP,會需要十六進制的密碼以及一個初向量(keyindex)。
下面我們將分別介紹這三種加密方式的WiFi連線方法。
首先確定板子是 Ameba, “Tools” -> “Board” -> “Arduino Ameba”

Open (即無密碼的WiFi連線)
打開 Connect No Encryption 的範例, “File” -> “Examples” -> “AmebaWiFi” -> “ConnectNoEncryption”

在SSID後修改“yourNetwork”為要連線的WiFi名稱。

修改之後上傳程式碼,按下Ameba的Reset按鈕, 這時候會看到You’re connected to the networkSSID: XXXXX,以及後面會每十秒列印出WiFi信息。
下面我們將分別介紹這三種加密方式的WiFi連線方法。
首先確定板子是 Ameba, “Tools” -> “Board” -> “Arduino Ameba”


在SSID後修改“yourNetwork”為要連線的WiFi名稱。

修改之後上傳程式碼,按下Ameba的Reset按鈕, 這時候會看到You’re connected to the networkSSID: XXXXX,以及後面會每十秒列印出WiFi信息。
在SSID後修改“yourNetwork”為要連線的WiFi名稱, “secretPassword”改為對應的密碼。
修改之後上傳程式碼,按下Ameba的Reset按鈕, 這時候會看到You’re connected to the networkSSID: XXXXX,以及後面會每十秒列印出WiFi信息。

在SSID後修改“yourNetwork”為要連線的WiFi名稱, key改為對應的十六進制的密碼,keyIndex 修改為對應的數字。
修改之後上傳程式碼,按下Ameba的Reset按鈕, 這時候會看到You’re connected to the networkSSID: XXXXX,以及後面會每十秒列印出WiFi信息。
程式碼說明
在連線WiFi時會使用到WiFi.begin();
https://www.arduino.cc/en/Reference/WiFiBegin
連線成功后會讀取WiFi的信息:
顯示WiFi的名稱WiFi.SSID()
https://www.arduino.cc/en/Reference/WiFiSSID
顯示WiFi的訊號強度WiFi.RSSI()
https://www.arduino.cc/en/Reference/WiFiRSSI
顯示WiFi的加密方式WiFi.encryptionType()
https://www.arduino.cc/en/Reference/WiFiEncryptionType
顯示連線的路由器的物理地址即BSSID WiFi.BSSID()
https://www.arduino.cc/en/Reference/WiFiBSSID
也會讀取Ameba自己的信息:
顯示Ameba的MAC信息WiFi.macAddress()
https://www.arduino.cc/en/Reference/WiFiMACAddress
顯示Ameba的IP信息WiFi.localIP()
https://www.arduino.cc/en/Reference/WiFiLocalIP
顯示子網掩碼WiFi.subnetMask()
https://www.arduino.cc/en/Reference/WiFiSubnetMask
顯示網關信息WiFi.gatewayIP()
https://www.arduino.cc/en/Reference/WiFiGatewayIP
https://www.arduino.cc/en/Reference/WiFiBegin
連線成功后會讀取WiFi的信息:
顯示WiFi的名稱WiFi.SSID()
https://www.arduino.cc/en/Reference/WiFiSSID
顯示WiFi的訊號強度WiFi.RSSI()
https://www.arduino.cc/en/Reference/WiFiRSSI
顯示WiFi的加密方式WiFi.encryptionType()
https://www.arduino.cc/en/Reference/WiFiEncryptionType
顯示連線的路由器的物理地址即BSSID WiFi.BSSID()
https://www.arduino.cc/en/Reference/WiFiBSSID
也會讀取Ameba自己的信息:
顯示Ameba的MAC信息WiFi.macAddress()
https://www.arduino.cc/en/Reference/WiFiMACAddress
顯示Ameba的IP信息WiFi.localIP()
https://www.arduino.cc/en/Reference/WiFiLocalIP
顯示子網掩碼WiFi.subnetMask()
https://www.arduino.cc/en/Reference/WiFiSubnetMask
顯示網關信息WiFi.gatewayIP()
https://www.arduino.cc/en/Reference/WiFiGatewayIP
與Arduino的差異
Arduino在完成WiFi的操作時,需要另外使用WiFi Shield來作為WiFi模塊,因此在使用WiFi是需要#include 來使用SPI與WiFi模塊進行通訊。
但是Ameba自身就具有WiFi模塊的功能,因此,不需要#include。若想要使用Arduino的範例,要先刪掉這一項。
但是Ameba自身就具有WiFi模塊的功能,因此,不需要#include
Materials
Ameba x 1
Procedure
WiFi connection with WPA encryption
Open the "ConnectWithWPA" exmaple, "File" -> "Examples" -> "AmebaWiFi" -> "ConnectWithWPA"
In the sample code, modify "SSID" to the SSID to be connected, "secretPassword" to be the passwrd.
Next, upload the sample code, and press the reset button on Ameba. Then you will see a message says "You’re connected to the networkSSID: XXXXX", and the information of this WiFi connection is printed in the IDE every 10 seconds.
WiFi connection with WEP encryption
Open the "ConnectWithWEP" example, "File" -> "Examples" -> "AmebaWiFi" -> "ConnectWithWEP"

In the sample code, modify "SSID" to the SSID to be connected, "key" to the hexadecimal password, "keyIndex" to your key index number.
Next, upload the sample code, and press the reset button on Ameba. Then you will see a message says "You’re connected to the networkSSID: XXXXX", and the information of this WiFi connection is printed in the IDE every 10 seconds.
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 encryption on Ameba.
First, make sure the current board is Ameba, select "Tools" -> "Board" -> "Arduino Ameba".

Open (WiFi connection without password)
Open the "ConnectNoEncryption" example, “File” -> “Examples” -> “AmebaWiFi” -> “ConnectNoEncryption”

In the sample code, modify "SSID" to the SSID to be connected.

Next, upload the sample code, and press the reset button on Ameba. Then you will see a message says "You’re connected to the networkSSID: XXXXX", and the information of this WiFi connection is printed in the IDE every 10 seconds.
In the following, we will give a brief introduction on how to establish WiFi connection with these three types of encryption on Ameba.
First, make sure the current board is Ameba, select "Tools" -> "Board" -> "Arduino Ameba".


In the sample code, modify "SSID" to the SSID to be connected.

Next, upload the sample code, and press the reset button on Ameba. Then you will see a message says "You’re connected to the networkSSID: XXXXX", and the information of this WiFi connection is printed in the IDE every 10 seconds.
In the sample code, modify "SSID" to the SSID to be connected, "secretPassword" to be the passwrd.
Next, upload the sample code, and press the reset button on Ameba. Then you will see a message says "You’re connected to the networkSSID: XXXXX", and the information of this WiFi connection is printed in the IDE every 10 seconds.

In the sample code, modify "SSID" to the SSID to be connected, "key" to the hexadecimal password, "keyIndex" to your key index number.
Next, upload the sample code, and press the reset button on Ameba. Then you will see a message says "You’re connected to the networkSSID: XXXXX", and the information of this WiFi connection is printed in the IDE every 10 seconds.
Code Reference
Use WiFi.begin() to establish WiFi connection;
https://www.arduino.cc/en/Reference/WiFiBegin
To get the information of a WiFi connection:
Use WiFi.SSID() to get SSID of the current connected network.
https://www.arduino.cc/en/Reference/WiFiSSID
Use WiFi.RSSI() to get the signal strength of the connection.
https://www.arduino.cc/en/Reference/WiFiRSSI
Use WiFi.encryptionType() to get the encryption type of the WiFi connection.
https://www.arduino.cc/en/Reference/WiFiEncryptionType
Use WiFi.BSSID() to get the MAC address of the router you are connected to.
https://www.arduino.cc/en/Reference/WiFiBSSID
To get the information of Ameba:
Use WiFi.macAddress() to get the MAC address of Ameba.
https://www.arduino.cc/en/Reference/WiFiMACAddress
Use WiFi.localIP() to get the IP address of Ameba.
https://www.arduino.cc/en/Reference/WiFiLocalIP
Use WiFi.subnetMask() to get the subnet mask.
https://www.arduino.cc/en/Reference/WiFiSubnetMask
Use WiFi.gatewayIP() to get the WiFi shield's gateway IP address.
https://www.arduino.cc/en/Reference/WiFiGatewayIP
https://www.arduino.cc/en/Reference/WiFiBegin
To get the information of a WiFi connection:
Use WiFi.SSID() to get SSID of the current connected network.
https://www.arduino.cc/en/Reference/WiFiSSID
Use WiFi.RSSI() to get the signal strength of the connection.
https://www.arduino.cc/en/Reference/WiFiRSSI
Use WiFi.encryptionType() to get the encryption type of the WiFi connection.
https://www.arduino.cc/en/Reference/WiFiEncryptionType
Use WiFi.BSSID() to get the MAC address of the router you are connected to.
https://www.arduino.cc/en/Reference/WiFiBSSID
To get the information of Ameba:
Use WiFi.macAddress() to get the MAC address of Ameba.
https://www.arduino.cc/en/Reference/WiFiMACAddress
Use WiFi.localIP() to get the IP address of Ameba.
https://www.arduino.cc/en/Reference/WiFiLocalIP
Use WiFi.subnetMask() to get the subnet mask.
https://www.arduino.cc/en/Reference/WiFiSubnetMask
Use WiFi.gatewayIP() to get the WiFi shield's gateway IP address.
https://www.arduino.cc/en/Reference/WiFiGatewayIP
Comparison with Arduino
In the Arduino platform, we need to add an extra WiFi shield to be the WiFi module to realize the WiFi connection. And we have to #include to use SPI to communicate with WiFi module.
However, Ameba is already equipped with WiFi module. Therefore, #include is not needed.
However, Ameba is already equipped with WiFi module. Therefore, #include is not needed.
0 comments:
Post a Comment