2020年8月14日 星期五

WIFI07_傳送訊息到Google 表單_ESP32 NodeMCU 32S

程式碼:

https://gist.github.com/clive520/a0c849942cd9041e676cb6353e167883




#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", "00000000");

    wifiMulti.addAP("clive_1F", "12345678");

    wifiMulti.addAP("Free", "00000000");

    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);


}


沒有留言:

張貼留言

聲寶卡式濾心頭蓋

 https://www.ruten.com.tw/item/show?22027794089976 在這裡買的接頭 https://www.ruten.com.tw/item/show?21814839221595 【品名】台製優質濾心頭蓋 (適用3M、EVERPURE濾心)功...