#include <WiFi.h>
#include <HTTPClient.h>
// WiFi
const char* ssid = "Wokwi-GUEST";
const char* password = " ";
// LINE Notify
const char* lineToken = "1UFjUTD4arR6IvUNQ5dPgCQwVgKGZIlVG0ypFMT7aPi";
// Flame Sensor
const int flamePin = 16;
// Buzzer
const int buzzerPin = 2;
// Initialize WiFi and LINE Notify
WiFiClientSecure client;
1UFjUTD4arR6IvUNQ5dPgCQwVgKGZIlVG0ypFMT7aPi ln(&client);
void setup() {
// Initialize Serial
Serial.begin(115200);
// Connect to WiFi
WiFi.begin("Wokwi-GUEST", ""4");
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
// Initialize LINE Notify
ln.setToken(lineToken);
}
void loop() {
// Read Flame Sensor
int flameState = digitalRead(flamePin);
// Check Flame Sensor
if (flameState == HIGH) {
// Send Notification to LINE
String message = "Fire Detected!";
if (ln.notify(message) == 0) {
Serial.println("Send notification to LINE failed.");
} else {
Serial.println("Send notification to LINE succeeded.");
}
// Turn on Buzzer
digitalWrite(buzzerPin, HIGH);
} else {
// Turn off Buzzer
digitalWrite(buzzerPin, LOW);
}
delay(100);
}