
/* 
HyM Tecnologies
Contador de 4 Canales con Doble Sensor por Canal 
4CH 8S - 4 Canales 8 Sensores 


Only RTC IO can be used as a source for external wake
source. They are pins: 0,2,4,12-15,25-27,32-39.*/

RTC_DATA_ATTR int bootCount = 0;
RTC_DATA_ATTR int ContCH1 = 995;

void setup(){
  
  delay(20); //Take some time to open up the Serial Monitor
  
  pinMode(2,INPUT);
  pinMode(4,INPUT);
  //pinMode(22, OUTPUT);
   
}

void loop(){
 //CH1-A:

  esp_sleep_enable_ext0_wakeup(GPIO_NUM_2,0); //1 = High, 0 = Low
 
  int estP2 = digitalRead(2);
if (estP2==1)
{
  ContCH1++;
  Serial.begin(115200);
  Serial.print("HIGH");
  Serial.println(ContCH1);
  delay(20);
  }

else
{
 esp_sleep_enable_ext0_wakeup(GPIO_NUM_2,1);

 Serial.begin(115200);
 Serial.println("LOW");
  delay(20);
 
  }

esp_deep_sleep_start();
  //This is not going to be called
}