ตู้ไปรษณีย์แจ้งเตือนทาง Line สอนทำแบบระเอียดยิ๊บ..
---------------------
จากเมื่อสัปดาห์ที่แล้วผมได้โพสต์วีดีโอทดสอบการทำงานของตู้ไปรษณีย์แจ้งเตือนทางไลน์ไป ก็มีหลายๆคนสนใจผมจึงได้ทำคลิปขึ้นมา เพื่อพาทุกคนทำ ผมวังว่าคลิปนี้จะมีประโยชน์สำหรับใครหลายคนนะครับผม😊
-------------------------------------------------
คลิป https://www.youtube.com/watch?v=_cVsQ1oRuRA&t=108s
--------------------------------------------------
โค้ด
void Line_Notify1(String message1) ;
#include <ESP8266WiFi.h>
#include <DHT.h>
#define WIFI_SSID "ชื่อ wifi" /////////////*************แก้
#define WIFI_PASSWORD "รหัส wifi"////////**************แก้
#define LINE_TOKEN_PIR "line token"////***************แก้
#define PirPin D6
#define DHTPIN D7
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
String message1 = "ข้อความแจ้งเตือน";//****************แก้
bool beep_state = false;
bool send_state = false;
uint32_t ts, ts1, ts2;
void setup() {
Serial.begin(115200);
Serial.println();
pinMode(PirPin, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
dht.begin();
Serial.println("connecting");
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("connecting");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("connected: ");
Serial.println(WiFi.localIP());
delay(10000);
Serial.println("Pir Ready!!");
read_sensor();
ts = ts1 = ts2 = millis();
}
void loop() {
ts = millis();
if (WiFi.status() == WL_CONNECTED) {
digitalWrite(LED_BUILTIN, LOW);
} else {
digitalWrite(LED_BUILTIN, HIGH);
}
if ((ts - ts2 >= 60000) && (WiFi.status() == WL_CONNECTED)) {
read_sensor();
}
if ((ts - ts1 >= 5000) && (beep_state == true)) {
beep_state = false;
}
if ((digitalRead(PirPin) == HIGH) && (beep_state == false) && (WiFi.status() == WL_CONNECTED)) {
while (digitalRead(PirPin) == HIGH) delay(100);
Serial.println("Detect !");
Line_Notify1(message1);
beep_state = true;
}
delay(10);
}
void Line_Notify1(String message) {
WiFiClientSecure client;
if (!client.connect("notify-api.line.me", 443)) {
Serial.println("connection failed");
delay(2000);
return;
}
String req = "";
req += "POST /api/notify HTTP/1.1\r\n";
req += "Host: notify-api.line.me\r\n";
req += "Authorization: Bearer " + String(LINE_TOKEN_PIR) + "\r\n";
req += "Cache-Control: no-cache\r\n";
req += "User-Agent: ESP8266\r\n";
req += "Content-Type: application/x-www-form-urlencoded\r\n";
req += "Content-Length: " + String(String("message=" + message1).length()) + "\r\n";
req += "\r\n";
req += "message=" + message1;
// Serial.println(req);
client.print(req);
delay(20);
while (client.connected()) {
String line = client.readStringUntil('\n');
if (line == "\r") {
break;
}
}
}
void read_sensor() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C ");
}
----------------------------------------------------------
同時也有10000部Youtube影片,追蹤數超過2,910的網紅コバにゃんチャンネル,也在其Youtube影片中提到,...
「authorization: bearer」的推薦目錄:
- 關於authorization: bearer 在 Audom Idea Facebook 的最佳貼文
- 關於authorization: bearer 在 コバにゃんチャンネル Youtube 的最讚貼文
- 關於authorization: bearer 在 大象中醫 Youtube 的精選貼文
- 關於authorization: bearer 在 大象中醫 Youtube 的精選貼文
- 關於authorization: bearer 在 開發者必備知識- HTTP認證(HTTP Authentication) 的評價
- 關於authorization: bearer 在 Why is 'Bearer' required before the token in 'Authorization ... 的評價
- 關於authorization: bearer 在 Bearer Token Authentication via scripting - YouTube 的評價
- 關於authorization: bearer 在 fastify-bearer-auth - GitHub 的評價
- 關於authorization: bearer 在 node.js - Confusions about "Authorization: Bearer ... 的評價
authorization: bearer 在 コバにゃんチャンネル Youtube 的最讚貼文
authorization: bearer 在 大象中醫 Youtube 的精選貼文
authorization: bearer 在 大象中醫 Youtube 的精選貼文
authorization: bearer 在 Why is 'Bearer' required before the token in 'Authorization ... 的推薦與評價
A Bearer Token is set in the Authorization header of every Inline Action HTTP Request and Bearer itself determines the type of ... ... <看更多>
authorization: bearer 在 Bearer Token Authentication via scripting - YouTube 的推薦與評價
In this video, we will discuss how we could get the bearer token out from one request and set it into an environment variable and use it as ... ... <看更多>
authorization: bearer 在 開發者必備知識- HTTP認證(HTTP Authentication) 的推薦與評價
Client會在request header加入以下資料來認證自己: Authorization: <type> <credentials>. type:認證方式,例如Basic, Digest... ... <看更多>