Last active
August 14, 2020 01:41
-
-
Save clive520/a0c849942cd9041e676cb6353e167883 to your computer and use it in GitHub Desktop.
WIFI07_傳送訊息到Google 表單_ESP32 NodeMCU 32S
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <WiFi.h> | |
#include <WiFiMulti.h> | |
WiFiMulti wifiMulti; | |
#define LED_BUILTIN 2 // 連接到WIFI時,亮內建的LED | |
//連接LINE | |
#include <WiFiClientSecure.h> | |
WiFiClientSecure Secure_client; | |
void setup() | |
{ | |
pinMode(LED_BUILTIN, OUTPUT); | |
digitalWrite(LED_BUILTIN,LOW) ; | |
Serial.begin(9600); | |
delay(10); | |
//連接WIFI | |
wifiMulti.addAP("clive_lef", "12345678"); | |
wifiMulti.addAP("clive_1F", "00000000"); | |
wifiMulti.addAP("Free", "87654321"); | |
wifiMulti.addAP("book", "12345678"); | |
Serial.println("Connecting Wifi..."); | |
if(wifiMulti.run() == WL_CONNECTED) { //連接多個WIFI | |
delay(50); | |
Serial.println(""); | |
Serial.print("Successful Connecting to Access Point:"); | |
Serial.println(WiFi.SSID()); | |
Serial.print("SSID Signal strength:"); | |
Serial.println(WiFi.RSSI());//WiFi.RSSI()訊號強度 | |
Serial.println("WiFi connected"); | |
Serial.print("IP address: "); | |
Serial.println(WiFi.localIP());//WiFi.localIP()連接到的IP | |
for (int count = 0; count < 5; count++) { //成功時亮內建的LED,閃爍5次 | |
digitalWrite(LED_BUILTIN, HIGH) ; | |
delay(500); | |
digitalWrite(LED_BUILTIN, LOW) ; | |
delay(500); | |
} | |
} | |
//連接WIFI結束 | |
} | |
void loop() | |
{ | |
if (Secure_client.connect("docs.google.com", 443)) { | |
Secure_client.println("GET /forms/d/e/1FAIpQLSea6mK8h9L8q8r8Ix2pkkwXaLXb49zRdK1zHq0p9vuV9r2vFg/formResponse?entry.1738208934="+ String(33)+"&entry.1494936504="+ String(85)+"&submit=Submit HTTP/1.1"); | |
//上面{1FAIpQLSea6mK8h9L8q8r8Ix2pkkwXaLXb49zRdK1zHq0p9vuV9r2vFg)是API_KEY | |
//(1738208934)和(1494936504)是表格ID | |
//String(33)和String(85)是要傳送的資料 | |
Secure_client.println("Host: docs.google.com"); | |
Secure_client.println("Connection: close"); | |
Secure_client.println(); | |
Secure_client.stop(); | |
} | |
delay(60000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment