---
# System prepended metadata

title: "#include <ESP8266WiFi.h>\n#inc"

---

```c

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

int LEDShowOffStamp;
int LineMessageStamp;
const char* ssid = "月幻";
const char* password = "20020916";

void setup() {
  Serial.print(millis());
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
  LEDShowOffStamp = -60000;
  LineMessageStamp = -1000;
  Serial.begin(9600);
  pinMode(D2, INPUT);
  pinMode(D1, OUTPUT);

  while (!WiFi.softAP(u8"HW", u8"", 1,false));
  digitalWrite(D1, LOW);
  
  delay(2000);

}

// loop() 裡面的程式會不斷重複執行
void loop() {
  
  if (digitalRead(D2) == HIGH && millis() - LEDShowOffStamp >= 1000) {
    LEDShowOffStamp = millis();
    digitalWrite(D1, HIGH);
    delay(1);
    digitalWrite(D1, LOW);
  }
  if (digitalRead(D2) == HIGH && millis() - LineMessageStamp >= 60000) {
    LineMessageStamp = millis();
    std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure);
    client->setInsecure();
    HTTPClient https;
    https.begin(*client, "https://hook.eu2.make.com/tjkvhu7afh6wf6syn71b7rwdbr1ift69?F=1");
    //http.addHeader("Content-Type", "application/x-www-form-urlencoded");

    int httpResponseCode = https.POST("");

    if (httpResponseCode > 0) {
      String response = https.getString();
      Serial.println(httpResponseCode);
      Serial.println(response);
    }
    else {
      Serial.print("Error on sending POST: ");
      Serial.println(httpResponseCode);
    }
  
    https.end();
  }

}
```