ความรู้แน่น ฟรีสำหรับชุมชน ArduinoAll ที่นี่เท่านั้น

ฟรีและดีที่สุด คอร์สอบรม Arduino + NodeMCU
ทำเพื่อแบ่งปัน ห้ามนำไปจำหน่าย หรือเก็บเงินค่าเรียน
  !!!


  


AllNewStep รับประกันคุณภาพทุกชิ้น วันจันทร์-ศุกร์แจ้งชำระสินค้าก่อน 14.00 จัดส่งทันทีวันนี้ค่ะ

กรุงเทพ /ภาคกลาง ได้พรุ่งนี้


*** สินค้าทุกชิ้น ถ้าสามารถทำรายการสั่งซื้อได้ แสดงว่ามีครบทุกรายการค่ะ *** 

พิมพ์ค้นหาบทความ หัวข้อกระทู้ และสินค้าในเว็บ AllNewStep ได้ที่นี่
QUOTE 

ทำesp8266 เเจ้งเตือนไปline notifyไม่ได้

Sitthisak Laoyawila

 คือผมทำrunโปรเเกรมเสร็จเเล้วมันยอมส่งไปที่line notifyอ่ะคับ พี่

QUOTE 
ความคิดเห็นที่ #1
เจ้าของร้าน

ตามนี้ครับ

 

ESP32 ส่งแจ้งเตือนผ่าน Line

Line มี API ที่สามารถสั่งงานด้วย ESP32 
สามารถใช้งานได้ง่าย โดยใช้ไลบารี TridentTD_LineNotify มีความสามารถดังนี้

  • ส่งข้อความ ภาษาไทย/อังกฤษ
  • ส่งสติกเกอร์
  • ส่งรูปภาพด้วย URL

1. อันดับแรก เราต้องสร้าง Line Token ก่อน ดังนี้


ตั้งชื่อ และเลือกกลุ่มที่ต้องการส่งข้อความไปหา


จะได้ Token ให้ก็อปปี้ข้อความเก็บไว้ก่อน Your token is :



2. ดาวน์โหลดและติดตั้งไลบารี TridentTD_LineNotify ที่นี่

3. ก็อปปี้และแก้ไขโคดตรง LINE_TOKEN ให้เป็นตามที่เราได้สร้างไว้ อัพโหลดดูผลลัพธ์



มีชุดสติกเกอร์สำหรับส่งข้อความเพิ่มเติมดังนี้

QUOTE 
ความคิดเห็นที่ #2
Sitthisak Laoyawila

void Line_Notify(String message) ;

#include <ESP8266WiFi.h>

 

// Update these with values suitable for your network.

 

const char* ssid = "chelsea";

const char* password = "11111111";

 

int counter = 0;

int previousReading = LOW;

 

 

#define LINE_TOKEN "ESiWrEaFdnzPzv3H2qNNztj1xp1d8k2gLv3AKCHoAjG" // แก้ LINE TOKEN

String message = "มีคนเข้าบ้าน"; // ใส่ข้อความที่ต้องการส่ง

WiFiClient espClient; 

 

long lastMsg = 0;

char msg[50];

int value = 0;

 

void setup_wifi() {

 

  delay(10);

  // We start by connecting to a WiFi network

  Serial.println();

  Serial.print("Connecting");

  Serial.println(ssid);

 

  WiFi.begin(ssid, password);

 

  while (WiFi.status() != WL_CONNECTED) {

    delay(500);

    Serial.print(".");

  }

 

  Serial.println("");

  Serial.println("WiFi connected");

  Serial.println("IP address: ");

  Serial.println(WiFi.localIP());

}

void setup() {

  // put your setup code here, to run once:

 

  pinMode(BUILTIN_LED, OUTPUT);     // Initialize the BUILTIN_LED pin as an output

  Serial.begin(57600);

  setup_wifi();

 

  pinMode(5, INPUT);

 

}

 

void loop() {

  // put your main code here, to run repeatedly:

 

   int reading = digitalRead(55);

  Serial.println(reading);

  if (previousReading == LOW && reading == HIGH) {

    counter++;

    Line_Notify(message);

   

    Serial.print("Triggered " );

    Serial.print(counter);

    Serial.print("xs! ");

    delay(1000);

  }

  previousReading = reading;

 }

 

 

  void Line_Notify(String message) {

      WiFiClientSecure client;

      

      if (!client.connect("notify-api.line.me", 443)) {

      Serial.println("connection failed");

      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) + "\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=" + message).length()) + "\r\n";

      req += "\r\n";

      req += "message=" + message;

      Serial.println(req);

      client.print(req);

      delay(20);

      

      Serial.println("-------------");

      while (client.connected()) {

      String line = client.readStringUntil('\n');

      if (line == "\r") {

      break;

      }

      Serial.println(line);

      }

      Serial.println("-------------");

      }

QUOTE 
ความคิดเห็นที่ #3
เจ้าของร้าน

ลองแค่ในโคดตัวอย่างก่อนครับ จะได้รู้ว่าส่ง line ได้หรือไม่

QUOTE 
ความคิดเห็นที่ #4
Sitthisak Laoyawila

ทำได้ละคับพี่

QUOTE 
ความคิดเห็นที่ #5
เจ้าของร้าน

ยินดีด้วยครับ

QUOTE 
ความคิดเห็นที่ #6
ojke

ผมทำตามตัวอย่าง ทำไมมันส่งไม่ส่งข้อมูลเข้าไลน์ครับ

ใช้ esp32 ครับ

แสดงความคิดเห็นที่ 1-6 จากทั้งหมด 6 ความคิดเห็น
ขาย ARDUINO
คุณภาพ อันดับ 1

ได้รับรางวัลร้านยอดเยี่ยม
ตั้งแต่ปี 2558
ขาย Arduino
วีดีโอสอน Arduino

สอน esp8266

สอน Arduino IoT
สอน Arduino แบบเร็ว

สอน NodeMCU

อุปกรณ์ Arduino

MEMBER ZONE

พูดคุย-สอบถาม