แจ้งเตือนน้ำท่วมผ่าน LINE ด้วย ESP8266
โปรเจคมินิ ระบบแจ้งเตือนน้ำท่วมผ่านไลน์ ด้วย ESP8266 นี้เป็นเพียงการนำเสนอเบื้องต้นของ การฝึกเขียนโปรแกรม Arduino DIE แล้วส่งข้อมูลไปยัง แอพพลิเคชั่นไลน์ เพื่อแจ้งเตือนข้อความสำคัญหรือเหตุการต่าง ๆ และสามารถนำไปประยุกต์ ดัดแปลง ให้เหมาะสมกับงานที่ท่านต้องการได้ ฝากกดไลค์เพจ
https://web.facebook.com/ECBOTS/ เพื่อเป็นกำลังใจให้แอดมินทำบทความดีๆ มานำเสนอด้วยนะครับ ^^
เริ่มกันเล๊ย....
อุปกรณ์ที่ต้องใช้ - ESP8266 D2 R2 หรือ ESP8266 V2 และ ESP8266 V3 ก็ได้เลือกใช้ตามสะดวกได้เลยครับ
-
เซ็นเซอร์ตรวจจับน้ำ / Sensor Water
- สาย Jumper ผู้+เมีย
- สาย Micro USB สำหรับอัพโหลดโปรแกรม
การต่อวงจร
ESP8266 TO Sensor 5V > Vcc
GND > GND
A0 > A0
โปรแกรมสำหรับนำไปพัฒนาต่อ
#include <TridentTD_LineNotify.h> |
#define SSID "********" //Name WIFI |
#define PASSWORD "********" //Password WiFi |
#define LINE_TOKEN "***************************" // Token Line Notify |
int state = 0; |
|
void setup() { |
Serial.begin(115200); Serial.println(); |
Serial.println(LINE.getVersion()); |
WiFi.begin(SSID, PASSWORD); |
Serial.printf("WiFi connecting to %s\n", SSID); |
while (WiFi.status() != WL_CONNECTED) { |
Serial.print("."); |
delay(400); |
} |
Serial.printf("\nWiFi connected\nIP : "); |
Serial.println(WiFi.localIP()); |
LINE.setToken(LINE_TOKEN); |
} |
|
void loop() { |
int Water = analogRead(A0); |
Serial.println(Water); |
delay(100); |
|
if (state == 0) { |
if (Water < 400 ) { |
LINE.notify("เตือน!! น้ำขึ้นสูงถึงระดับเซ็นเซอร์แล้ว"); |
state = 1; |
} |
} |
else if (state == 1) { |
delay(600000); |
state = 0; |
} |
} |
เพิ่มเติม ** สามารถนำไปดัดแปลง หรือ ประยุกต์ใช้ ต่อยอดให้ดีขึ้นได้ตามสะดวกเลยครับ