WHAT'S NEW?
Loading...
材料準備
範例說明
在前個例子
"I2C - 利用I2C讓Ameba與Arduino UNO溝通"
裡,Ameba 是 I2C master, 而Arduino UNO 是 I2C slave,並且讓 Ameba 送資料給 Arduino UNO。
在這個範例裡, Ameba 一樣是 I2C master, Arduino UNO 是 I2C slave, 但是改成資料從 Arudino UNO 傳給 Ameba。
準備Arduino Uno為 I2C Slave
首先我們先準備 Arduino,先將Arduino IDE選成Arduino, “Tools” -> “Board” -> “Arduino/Genuino Uno”:
接著打開 Slave Sender 的範例,"Examples" -> "Wire" -> "slave_sender"
然後點選 “Sketch” -> “Upload” 將程式編譯並上傳到 Arduino Uno。
準備Ameba 為 I2C Master
我們額外再開一個Arduino IDE,確定板子是 Ameba, “Tools” -> “Board” -> “Arduino Ameba”
然後打開 Master Reader 的範例, “File” -> “Examples” -> “AmebaWire” -> “master_reader”
然後點選 “Sketch” -> “Upload” 將程式編譯並上傳到 Ameba。
接線
Arduino的範例裡,使用A4當作I2C SCL, A5為I2C SDA。這些接腳與Ameba一樣。
另外很重要的是,兩塊板子的GND要互接。
接著我們要從Serial Monitor視窗來看Ameba印出讀到的數據 首先我們要找到Ameba的Serial Port, 點Windows的[開始] 按鈕 、[控制台]、[系統及安全性],然後在 [系統] 下方按一下 [裝置管理員],開啟 [裝置管理員]。 會看到Ports那邊有個mbed Serial Port(COM15), 這邊COM15就是就是Ameba的Port Number
接著我們將Arduino的Port選到COM15, 它在 “Tools” -> “Port” -> COM15 (Ameba目前的Mbed Serial Port)。
每當我們要從Arduino IDE看Ameba印出的訊息, 都要設定成正確的port:
打開包含Ameba的Arduino IDE,開啟Serial Monitor, “Tools” -> “Serial Monitor”, 會出現Serial Monitor的視窗,這個視窗可以讓你看到Ameba印出來的訊息。
接著按下Arduino Uno的Reset按鈕,讓Arduino Uno等待I2C master連接。
再按下Ameba的Reset按鈕,讓Ameba開始接收從Arduino Uno傳過來的訊息。這時候會看到Serial Monitor每隔0.5秒出現 "hello " 的訊息,這樣就代表成功了。
(NOTE: 如果發現 Ameba 的 Serial Monitor沒出現訊息,請試試看重開 Serial Monitor)
在這個範例裡, Ameba 一樣是 I2C master, Arduino UNO 是 I2C slave, 但是改成資料從 Arudino UNO 傳給 Ameba。
首先我們先準備 Arduino,先將Arduino IDE選成Arduino, “Tools” -> “Board” -> “Arduino/Genuino Uno”:
接著打開 Slave Sender 的範例,"Examples" -> "Wire" -> "slave_sender"
然後點選 “Sketch” -> “Upload” 將程式編譯並上傳到 Arduino Uno。
我們額外再開一個Arduino IDE,確定板子是 Ameba, “Tools” -> “Board” -> “Arduino Ameba”
然後打開 Master Reader 的範例, “File” -> “Examples” -> “AmebaWire” -> “master_reader”
然後點選 “Sketch” -> “Upload” 將程式編譯並上傳到 Ameba。
Arduino的範例裡,使用A4當作I2C SCL, A5為I2C SDA。這些接腳與Ameba一樣。
另外很重要的是,兩塊板子的GND要互接。
接著我們要從Serial Monitor視窗來看Ameba印出讀到的數據 首先我們要找到Ameba的Serial Port, 點Windows的[開始] 按鈕 、[控制台]、[系統及安全性],然後在 [系統] 下方按一下 [裝置管理員],開啟 [裝置管理員]。 會看到Ports那邊有個mbed Serial Port(COM15), 這邊COM15就是就是Ameba的Port Number
接著我們將Arduino的Port選到COM15, 它在 “Tools” -> “Port” -> COM15 (Ameba目前的Mbed Serial Port)。
每當我們要從Arduino IDE看Ameba印出的訊息, 都要設定成正確的port:
打開包含Ameba的Arduino IDE,開啟Serial Monitor, “Tools” -> “Serial Monitor”, 會出現Serial Monitor的視窗,這個視窗可以讓你看到Ameba印出來的訊息。
接著按下Arduino Uno的Reset按鈕,讓Arduino Uno等待I2C master連接。
再按下Ameba的Reset按鈕,讓Ameba開始接收從Arduino Uno傳過來的訊息。這時候會看到Serial Monitor每隔0.5秒出現 "hello " 的訊息,這樣就代表成功了。
(NOTE: 如果發現 Ameba 的 Serial Monitor沒出現訊息,請試試看重開 Serial Monitor)
程式碼說明
Ameba使用同樣的Arduino範例,Ardunio官方網站的範例說明可以參考這裡:
https://www.arduino.cc/en/Tutorial/MasterReader
首先Wire.begin()會先設定address, 如果是Master可以不用設定address:
https://www.arduino.cc/en/Reference/WireBegin
接著Master使用Wire.requestFrom()來設定要從哪一個Slave接收資料:
https://www.arduino.cc/en/Reference/WireRequestFrom
https://www.arduino.cc/en/Tutorial/MasterReader
首先Wire.begin()會先設定address, 如果是Master可以不用設定address:
https://www.arduino.cc/en/Reference/WireBegin
接著Master使用Wire.requestFrom()來設定要從哪一個Slave接收資料:
https://www.arduino.cc/en/Reference/WireRequestFrom
... Under construction ...
Arduino內建許多Example, 底下的列表是Ameba支援的內建範例
| Category | Name | Comment |
| 01. Basics | AnalogReadSerial | |
| Blink | ||
| DititalReadSerial | ||
| Fade | ||
| ReadAnalogVoltage | ||
| 02. Digital | Button | |
| DigitalInputPullup | ||
| StateChangeDetection | ||
| 03. Analog | AnalogInOutSerial | |
| AnalogInput | ||
| Fading | ||
| Smoothing | ||
| 04. Communication | ASCIITable | |
| Graph | ||
| Midi | ||
| 05. Control | Arrays | |
| ForLoopIteration | ||
| IfStatementConditional | ||
| switchCase | ||
| 07. Display | barGraph | |
| RowColumnScanning | ||
| 08. Strings | StringCaseChanges | |
| StringCharacters | ||
| StringIndexOf | ||
| StringLengthTrim | ||
| StringReplace | ||
| StringStartsWithEndsWith | ||
| StringSubstring |
There are many built-in examples in Arduino. In the table below, we list all examples that are compatible with Ameba.
| Category | Name | Comment |
| 01. Basics | AnalogReadSerial | |
| Blink | ||
| DititalReadSerial | ||
| Fade | ||
| ReadAnalogVoltage | ||
| 02. Digital | Button | |
| DigitalInputPullup | ||
| StateChangeDetection | ||
| 03. Analog | AnalogInOutSerial | |
| AnalogInput | ||
| Fading | ||
| Smoothing | ||
| 04. Communication | ASCIITable | |
| Graph | ||
| Midi | ||
| 05. Control | Arrays | |
| ForLoopIteration | ||
| IfStatementConditional | ||
| switchCase | ||
| 07. Display | barGraph | |
| RowColumnScanning | ||
| 08. Strings | StringCaseChanges | |
| StringCharacters | ||
| StringIndexOf | ||
| StringLengthTrim | ||
| StringReplace | ||
| StringStartsWithEndsWith | ||
| StringSubstring |
材料準備
Ameba x 1
Laptop(可與Ameba連到相同網域,並安裝tcp工具)
範例說明
這個範例裡,我們使用 Ameba 連上 WiFi,作為 Server,與連接過來的 Client 進行對話。
首先確定板子是 Ameba, “Tools” -> “Board” -> “Arduino Ameba”
然後打開 Simple WiFi Server的範例, “File” -> “Examples” -> “AmebaWiFi” -> “SimpleServerWiFi”
將 WiFi 連線的相關訊息進行修改,將下圖中黃色標註的地方進行對應的修改。
上傳程式碼之後,按下 Ameba 的 Reset 按鈕, 這時會看到 WiFi 連線後的信息。
在 laptop 上的 socket 工具上(本示例中使用的工具為 “sokit” )通過獲取的IP地址以及範例中設定的 port 5000 來進行連線。
選取 Client 模式,填寫 Server IP 和 port 信息,點擊 “TCP Connect”
連接成功后會顯示 ”A client connected to this Server”,以及Client的IP和port訊息。
從 Client 發送一個字串過來,Ameba收到後,會將這個字串再發給 Client。

客戶端會顯示收到這個字串
首先確定板子是 Ameba, “Tools” -> “Board” -> “Arduino Ameba”
然後打開 Simple WiFi Server的範例, “File” -> “Examples” -> “AmebaWiFi” -> “SimpleServerWiFi”
將 WiFi 連線的相關訊息進行修改,將下圖中黃色標註的地方進行對應的修改。
上傳程式碼之後,按下 Ameba 的 Reset 按鈕, 這時會看到 WiFi 連線後的信息。
在 laptop 上的 socket 工具上(本示例中使用的工具為 “sokit” )通過獲取的IP地址以及範例中設定的 port 5000 來進行連線。
選取 Client 模式,填寫 Server IP 和 port 信息,點擊 “TCP Connect”
連接成功后會顯示 ”A client connected to this Server”,以及Client的IP和port訊息。
從 Client 發送一個字串過來,Ameba收到後,會將這個字串再發給 Client。

客戶端會顯示收到這個字串
程式碼說明
在連線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
顯示Ameba的IP信息WiFi.localIP()
https://www.arduino.cc/en/Reference/WiFiLocalIP
設定服務器的端口號WiFiServer server(5000)
https://www.arduino.cc/en/Reference/WiFiServer
開始服務器的監聽server.begin();
https://www.arduino.cc/en/Reference/WiFiServerBegin
判斷是否有客戶端連線server.available()
https://www.arduino.cc/en/Reference/WiFiServerAvailable
從Server讀取數據client.read()
https://www.arduino.cc/en/Reference/WiFiClientRead
對Server發送數據client.write()
https://www.arduino.cc/en/Reference/WiFiClientWrite
與Server斷開連線client.stop();
https://www.arduino.cc/en/Reference/WiFIClientStop
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
顯示Ameba的IP信息WiFi.localIP()
https://www.arduino.cc/en/Reference/WiFiLocalIP
設定服務器的端口號WiFiServer server(5000)
https://www.arduino.cc/en/Reference/WiFiServer
開始服務器的監聽server.begin();
https://www.arduino.cc/en/Reference/WiFiServerBegin
判斷是否有客戶端連線server.available()
https://www.arduino.cc/en/Reference/WiFiServerAvailable
從Server讀取數據client.read()
https://www.arduino.cc/en/Reference/WiFiClientRead
對Server發送數據client.write()
https://www.arduino.cc/en/Reference/WiFiClientWrite
與Server斷開連線client.stop();
https://www.arduino.cc/en/Reference/WiFIClientStop
Materials
Ameba x 1
Laptop(Make sure it is connected to the same network domain as Ameba, and tcp tools are installed.)
Procedure
In this example, we first connect Ameba to WiFi, then we use Ameba as server to communicate with client.
First, we make sure the board is set to Ameba in “Tools” -> “Board” -> “Arduino Ameba”
Then, open up the Simple WiFi Server example in “File” -> “Examples” -> “AmebaWiFi” -> “SimpleServerWiFi”
In the sample code, we modify the parameters concerning the WiFi connection, please set the parameters according to your WiFi connection.
Next, upload the code, then press the reset button on Ameba. At this moment, you will see the connection information is displayed in the console.
Next, we use the socket tool in the laptop to be the client, and connect to the Ameba server via the IP and port we set in the code. (Note: The socket tool we used in this example is "sokit".)
Click on the "Client" tab to choose the client mode, specify the IP and port of the server, then click "TCP Connect".
If the connection is established successfully, the server shows a message: "A client connected to this Server", and the IP and port of the connected client.
In this example, when the client and server are connected and the client sends a string to Ameba server, the Ameba server returns the identical string back to the client.

The string sent to server is returned and showed at the client side.
First, we make sure the board is set to Ameba in “Tools” -> “Board” -> “Arduino Ameba”
Then, open up the Simple WiFi Server example in “File” -> “Examples” -> “AmebaWiFi” -> “SimpleServerWiFi”
In the sample code, we modify the parameters concerning the WiFi connection, please set the parameters according to your WiFi connection.
Next, upload the code, then press the reset button on Ameba. At this moment, you will see the connection information is displayed in the console.
Next, we use the socket tool in the laptop to be the client, and connect to the Ameba server via the IP and port we set in the code. (Note: The socket tool we used in this example is "sokit".)
Click on the "Client" tab to choose the client mode, specify the IP and port of the server, then click "TCP Connect".
If the connection is established successfully, the server shows a message: "A client connected to this Server", and the IP and port of the connected client.
In this example, when the client and server are connected and the client sends a string to Ameba server, the Ameba server returns the identical string back to the client.

The string sent to server is returned and showed at the client side.
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.localIP() to get the Ameba WiFi shield's IP address.
https://www.arduino.cc/en/Reference/WiFiLocalIP
Create server and transmitting data:
Use Server(port) to create a server that listens on the specified port.
https://www.arduino.cc/en/Reference/WiFiServer
Use server.begin() to tell the server to begin listening for incoming connections.
https://www.arduino.cc/en/Reference/WiFiServerBegin
Use server.available() to get a client that is connected to the server and has data available for reading.
https://www.arduino.cc/en/Reference/WiFiServerAvailable
Use client.read() to read the next byte received from the server.
https://www.arduino.cc/en/Reference/WiFiClientRead
Use client.write() to write data to the server.
https://www.arduino.cc/en/Reference/WiFiClientWrite
Use client.stop() to disconnect from the server.
https://www.arduino.cc/en/Reference/WiFIClientStop
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.localIP() to get the Ameba WiFi shield's IP address.
https://www.arduino.cc/en/Reference/WiFiLocalIP
Create server and transmitting data:
Use Server(port) to create a server that listens on the specified port.
https://www.arduino.cc/en/Reference/WiFiServer
Use server.begin() to tell the server to begin listening for incoming connections.
https://www.arduino.cc/en/Reference/WiFiServerBegin
Use server.available() to get a client that is connected to the server and has data available for reading.
https://www.arduino.cc/en/Reference/WiFiServerAvailable
Use client.read() to read the next byte received from the server.
https://www.arduino.cc/en/Reference/WiFiClientRead
Use client.write() to write data to the server.
https://www.arduino.cc/en/Reference/WiFiClientWrite
Use client.stop() to disconnect from the server.
https://www.arduino.cc/en/Reference/WiFIClientStop
材料準備
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.
材料準備
Ameba x 1
天線 x 1
範例說明
程式碼說明
首先使用的是顯示Ameba自己的物理地址WiFi.macAddress(mac):
https://www.arduino.cc/en/Reference/WiFiMACAddress
然後開始搜索周圍WiFi環境的WiFi.scanNetworks()
https://www.arduino.cc/en/Reference/WiFiScanNetworks
在打印WiFi具體訊息時使用到的有
顯示WiFi的名稱WiFi.SSID(thisNet):
https://www.arduino.cc/en/Reference/WiFiSSID
顯示WiFi的訊號強度WiFi.RSSI(thisNet):
https://www.arduino.cc/en/Reference/WiFiRSSI
顯示WiFi的加密方式WiFi.encryptionType(thisNet):
https://www.arduino.cc/en/Reference/WiFiEncryptionType
https://www.arduino.cc/en/Reference/WiFiMACAddress
然後開始搜索周圍WiFi環境的WiFi.scanNetworks()
https://www.arduino.cc/en/Reference/WiFiScanNetworks
在打印WiFi具體訊息時使用到的有
顯示WiFi的名稱WiFi.SSID(thisNet):
https://www.arduino.cc/en/Reference/WiFiSSID
顯示WiFi的訊號強度WiFi.RSSI(thisNet):
https://www.arduino.cc/en/Reference/WiFiRSSI
顯示WiFi的加密方式WiFi.encryptionType(thisNet):
https://www.arduino.cc/en/Reference/WiFiEncryptionType
與Arduino的差異
Arduino在完成WiFi的操作時,需要另外使用WiFi Shield來作為WiFi模塊,因此在使用WiFi是需要#include 來使用SPI與WiFi模塊進行通訊。
但是Ameba自身就具有WiFi模塊的功能,因此,不需要#include。若想要使用Arduino的範例,要先刪掉這一項。
但是Ameba自身就具有WiFi模塊的功能,因此,不需要#include
Materials
Ameba x 1
Procedure
In this example, we use Ameba to scan available WiFi hotspots in the surroundings, and prints the SSID, encryption type, signal strngth information of each detected hotspot.
First, make sure Ameba is selected in Arduino IDE: "Tools" -> "Board" -> "Arduino Ameba"
Open the "ScanNetworks" example in "File" -> "Examples" -> "AmebaWiFi" -> "ScanNetworks":
Then upload the sample code, and press the reset button on Ameba. Afterwards, you can see "**Scan Networks**" message appears, with the detected WiFi hotspots and the information of each hotspot.
First, make sure Ameba is selected in Arduino IDE: "Tools" -> "Board" -> "Arduino Ameba"
Open the "ScanNetworks" example in "File" -> "Examples" -> "AmebaWiFi" -> "ScanNetworks":
Then upload the sample code, and press the reset button on Ameba. Afterwards, you can see "**Scan Networks**" message appears, with the detected WiFi hotspots and the information of each hotspot.
Code Reference
First we use WiFi.macAddress(mac) to getthe MAC address of Ameba:
https://www.arduino.cc/en/Reference/WiFiMACAddress
Then we use WiFi.scanNetworks() to detect WiFi hotspots:
https://www.arduino.cc/en/Reference/WiFiScanNetworks
To get information of detected WiFi hotspot:
We use WiFi.SSID(thisNet) to retrieve SSID of a network:
https://www.arduino.cc/en/Reference/WiFiSSID
We use WiFi.RSSI(thisNet) to get the signal strength of the connection to the router:
https://www.arduino.cc/en/Reference/WiFiRSSI
We use WiFi.encryptionType(thisNet) to get the encryption type of the network:
https://www.arduino.cc/en/Reference/WiFiEncryptionType
https://www.arduino.cc/en/Reference/WiFiMACAddress
Then we use WiFi.scanNetworks() to detect WiFi hotspots:
https://www.arduino.cc/en/Reference/WiFiScanNetworks
To get information of detected WiFi hotspot:
We use WiFi.SSID(thisNet) to retrieve SSID of a network:
https://www.arduino.cc/en/Reference/WiFiSSID
We use WiFi.RSSI(thisNet) to get the signal strength of the connection to the router:
https://www.arduino.cc/en/Reference/WiFiRSSI
We use WiFi.encryptionType(thisNet) to get the encryption type of the network:
https://www.arduino.cc/en/Reference/WiFiEncryptionType
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.







