#include "soc/soc.h"           // Disable brownour problems
#include "soc/rtc_cntl_reg.h"

// int inputPin = 19;               // choose the input pin (for PIR sensor)
// int pirCurrentState = LOW;             // we start, assuming no motion detected
// int pirPreviousState = LOW;

void setup() {

  // put your setup code here, to run once:
  // WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);

  Serial.begin(115200);
  Serial.println("Hello, ESP32!");

  Serial.println("Obtain GPS location");
  Serial.println("Report someone is here!!!");
  esp_sleep_enable_ext0_wakeup(GPIO_NUM_33, 1);
 
  Serial.println("Going to sleep now");
  delay(1000);
  esp_deep_sleep_start();
  Serial.println("This will never be printed");
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(10); // this speeds up the simulation

  // pirPreviousState = pirCurrentState;
  // pirCurrentState = digitalRead(inputPin);

  // if (pirPreviousState == LOW && pirCurrentState == HIGH) {   // pin state change: LOW -> HIGH
  //   Serial.println("Motion detected!");
  //   // TODO: turn on alarm, light or activate a device ... here
  // }
  // else if (pirPreviousState == HIGH && pirCurrentState == LOW) {   // pin state change: HIGH -> LOW
  //   Serial.println("Motion stopped!");
  //   // TODO: turn off alarm, light or deactivate a device ... here
  // }

}