#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPL6P3TAZrbN"
#define BLYNK_TEMPLATE_NAME "WiFi"
#define BLYNK_AUTH_TOKEN "Pa9Nq_14jZWvsocw3ivXoMH0RkFrMM_E"
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <HTTPClient.h>
int ldr = 34;
String LINE_TOKEN = "egAkuGTGgAO8kfeD1AXFIbJDj1U0Ot3pXtrSYh6zkvZ"; // LINE Token
char auth[] = "Pa9Nq_14jZWvsocw3ivXoMH0RkFrMM_E"; // Blynk authentication token
char ssid[] = "Wokwi-GUEST"; // Wi-Fi SSID
char pass[] = ""; // Wi-Fi password
BlynkTimer timer;
void sendLineNotification(const char* message) {
HTTPClient http;
http.begin("https://notify-api.line.me/api/notify");
http.addHeader("Authorization", "Bearer " + LINE_TOKEN);
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
int httpCode = http.POST("message=" + String(message));
String payload = http.getString();
Serial.println("HTTP Response Code: " + String(httpCode));
Serial.println("Response: " + payload);
http.end();
}
void setup() {
Serial.begin(9600);
pinMode(ldr, INPUT);
Blynk.begin(auth, ssid, pass);
timer.setInterval(10000L, []() {
Blynk.virtualWrite(V1, millis() / 5000);
});
}
void loop() {
int val = analogRead(ldr);
Serial.print("temperature = ");
Serial.println(val);
Blynk.virtualWrite(V7,val);
if(val > 500 ){
sendLineNotification("Cunnyyyyyy!!!");
delay(1000);
}
Blynk.run();
timer.run();
}
// BLYNK_WRITE(V2) {
// int pinValue = param.asInt();
// if (pinValue == 1) {
// sendLineNotification("ตรวจพบเจอภัยสังคม");
// }
// }