|
|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
#include <LiquidCrystal_I2C.h>
|
|
|
|
|
#include <ESP8266WiFi.h>
|
|
|
|
|
#include <PubSubClient.h>
|
|
|
|
|
#include <ArduinoJson.h>
|
|
|
|
|
|
|
|
|
|
const int deviceId = 0;
|
|
|
|
|
|
|
|
|
|
@ -74,7 +75,8 @@ void reconnect()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setup(){
|
|
|
|
|
void setup()
|
|
|
|
|
{
|
|
|
|
|
Serial.begin(115200);
|
|
|
|
|
|
|
|
|
|
lcd.init();
|
|
|
|
|
@ -82,16 +84,33 @@ void setup(){
|
|
|
|
|
pinMode(buzzerPin, OUTPUT);
|
|
|
|
|
|
|
|
|
|
setup_wifi();
|
|
|
|
|
reconnect();
|
|
|
|
|
client.setServer(mqtt_server, 1883);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void loop(){
|
|
|
|
|
bool isArmed()
|
|
|
|
|
{
|
|
|
|
|
DynamicJsonDocument doc(1024);
|
|
|
|
|
|
|
|
|
|
doc["deviceId"] = deviceId;
|
|
|
|
|
|
|
|
|
|
char buffer[1024];
|
|
|
|
|
size_t n = serializeJson(doc, buffer);
|
|
|
|
|
client.publish("display/disarm", buffer, n);
|
|
|
|
|
lcd.print("Aarmed");
|
|
|
|
|
delay(10000);
|
|
|
|
|
lcd.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
|
{
|
|
|
|
|
// digitalWrite(buzzerPin, HIGH);
|
|
|
|
|
// lcd.print("Piss off, ghosts!");
|
|
|
|
|
// lcd.print(deviceId);
|
|
|
|
|
// delay(1000);
|
|
|
|
|
// lcd.clear();
|
|
|
|
|
// digitalWrite(buzzerPin, LOW);
|
|
|
|
|
// delay(1000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
client.loop();
|
|
|
|
|
isArmed();
|
|
|
|
|
}
|