Created
March 3, 2025 18:39
-
-
Save maxpromer/0b6e13c519eca7003d2fb4821d23aac6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <WiFiManager.h> // นำเข้าไลบรารี่ WiFiManager | |
#include <ArtronShop_LineMessaging.h> // นำเข้าไลบารี่ ArtronShop_LineMessaging | |
#define LINE_TOKEN "LINE Token" // Channel access token | |
WiFiManager wm; | |
void setup() { | |
Serial.begin(115200); // เริ่มต้นใช้ Serial ที่ความเร็ว 115200 | |
wm.resetSettings(); // ล้างการตั้งค่า WiFi ก่อนหน้านี้ (ใช้งานจริงต้องลบบรรทัดนี้ออก) | |
bool res = wm.autoConnect("ESP32_Notify"); // กำหนด ESP32 กระจาย WiFi รออุปกรณ์อื่นเข้ามาตั้งค่า | |
if (!res) { // ถ้ารับการตั้งค่าไม่สำเร็จ | |
Serial.println("Failed to connect"); // | |
ESP.restart(); // รีเซ็ตบอร์ด | |
} | |
LINE.begin(LINE_TOKEN); // เริ่มต้นใช้ LINE Notify | |
} | |
void loop() { | |
if (digitalRead(0) == LOW) { // ถ้ากดปุ่ม IO0 | |
if (LINE.send("User ID/Group ID", "แจ้งเตือนกดปุ่ม")) { // ส่งข้อความ "แจ้งเตือนกดปุ่ม" ไปที่ LINE | |
Serial.println("Send notify successful"); // ส่งข้อความ "Send notify successful" ไปที่ Serial Monitor | |
} else { // ถ้าส่งไม่สำเร็จ | |
Serial.printf("Send notify fail. check your token (code: %d)\n", LINE.status_code); // ส่งข้อความ "Send notify fail" ไปที่ Serial Monitor | |
} | |
while(digitalRead(0) == LOW) delay(10); // รอจนกว่าจะปล่อยสวิตช์ IO0 | |
} | |
delay(10); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment