 
 //// Sensor Config ////
 
-#define FLAME_PIN             0
-#define FLAME_ALERT_THRESHOLD 190
-#define LIGHT_PIN             1
+#define FLAME_PIN             0     // analog
+#define FLAME_ALERT_THRESHOLD 100
+
+#define MQ2_PIN               2     // analog
+#define MQ2_ALERT_THRESHOLD   115
+
+#define PIR_PIN               8     // digital
 
 #include <Adafruit_Sensor.h>
 #include <Adafruit_BMP085_U.h>
 #include <DHT.h>
 #include <DHT_U.h>
 
-#define DHT_PIN  0
+#define DHT_PIN  0 // digital
 #define DHT_TYPE DHT11
 DHT_Unified dht(DHT_PIN, DHT_TYPE);
 

#define BUZZER_PIN  5
#define BUZZER_HIGH 30

//// LCD Config ////

#include <PCD8544_SPI.h>

PCD8544_SPI lcd;

//// Data Memory ////

static uint8_t temp;
static uint8_t humidity;
static uint8_t flame;
static uint16_t light;
static float pressure;

//// Setup & Loop ////

void setup(void) {
  lcd.begin(false, 0xBD, 0x04, 0x13);
  bmp.begin();
  dht.begin();
  if (ether.begin(sizeof Ethernet::buffer, mymac, 4) == 0)
    Serial.println(F("Eth"));
  if (!ether.dhcpSetup())
    Serial.println(F("DHCP"));
  coap_ethercard_begin();
}

static uint32_t timer;

void loop(void) {
  timer = millis();

  char rspc[3]; itoa(flame, rspc, 10); \
  CONTENT(COAP_CONTENTTYPE_TEXT_PLAIN, rspc); \
}) \
ROUTE(gas, COAP_METHOD_GET, URL("gas"), ";if=\"sensor\"", { \
  char rspc[5]; itoa(mq2_gas, rspc, 10); \
  CONTENT(COAP_CONTENTTYPE_TEXT_PLAIN, rspc); \
}) \
ROUTE(motion, COAP_METHOD_GET, URL("motion"), ";if=\"sensor\"", { \
  char rspc[2];  itoa(motion, rspc, 10); \
  CONTENT(COAP_CONTENTTYPE_TEXT_PLAIN, rspc); \
}) \
ROUTE(buzzer, COAP_METHOD_POST, URL("buzzer"), ";if=\"alarm\"", { \
