很重要很重要很重要
用 Arduino IDE 時, GPIO2 必須 HIGH
用 pietty 連接 COM port 時, GPIO2 要拔掉
載入 ESP8266WiFi.h 後
如果要用 pietty COM port 看執行結果
GPIO0 跟 GPIO2 都要接 HIGH
修改 example -> ESP8266WIFI -> WiFiClient
測試讀一個網址, 不帶任何參數
前略
const char* ssid = "無線網路的 SSID";
const char* password = "無線網路的 Password";
const char* host = "測試的網址";
後略
void loop() {
略
// This will send the request to the server
client.print(String("GET ") + " / HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n");
略
}
測試讀一個網址底下的目錄服務, 並且不帶任何參數
前略
const char* ssid = "無線網路的 SSID";
const char* password = "無線網路的 Password";
const char* host = "測試的網址";
後略
void loop() {
略
String url = "/完整路徑"; //ex: /app/do.html
略
// This will send the request to the server
client.print(String("GET ") + url + " HTTP/1.1\r\n" +"Host: " + host + "\r\n" + "Connection: close\r\n\r\n");
略
}
測試讀一個網址底下的目錄服務, 並且帶參數
前略
const char* ssid = "無線網路的 SSID";
const char* password = "無線網路的 Password";
const char* host = "測試的網址";
後略
void loop() {
略
String url = "/完整路徑"; //ex: /app/do.html
url += "?參數名稱I=參數值I";
url += "&參數名稱II=參數值II";
略
// This will send the request to the server
client.print(String("GET ") + url + " HTTP/1.1\r\n" +"Host: " + host + "\r\n" + "Connection: close\r\n\r\n");
略
}