#include #ifdef ESP32 #include #else #include "ESP8266WiFi.h" #include // https://github.com/tzapu/WiFiManager #include #endif #include "fauxmoESP.h" #include //#define WIFI_SSID "Rede2" //Cambiar por tu WIFI SSID //#define WIFI_PASS "02584612345678joule" //Cambiar por tu WIFI password #define SERIAL_BAUDRATE 115200 #define BOT_TOKEN_LENGTH 10 #define D3 3 char NOME_ID[10]=""; /*const long debounce_delay = 30; long tempo_debounce = 0; int debounce_ok = 1; int leitura_anterior = 0; int leitura_anterior_db = 0; unsigned int currentMillis = 0;*/ long tempo_debounce2 = 0; int debounce_ok2 = 1; int leitura_anterior2 = 0; int leitura_anterior_db2 = 0; unsigned int currentMillis2 = 0; const long debounce_reset = 8000; char stado=0; fauxmoESP fauxmo; const int buttonPin = 2; #define RELAY_PIN 3 //flag for saving data bool shouldSaveConfig = false; //callback notifying us of the need to save config void saveConfigCallback () { Serial.println("Should save config"); shouldSaveConfig = true; } void readBotTokenFromEeprom(int offset){ for(int i = offset; i 0) {///SE HOUVER DADOS NA SERIAL VAI PARA ROTINA DE TRATAMENTO //recebe_serial(); stado=Serial.read(); if(stado=='R'){// redefine para parametros inicias //Serial.println("Reset"); WiFi.disconnect(); //Serial.println("Dq"); delay(500); ESP.reset(); } } fauxmo.handle(); // pulso1(); pulso2(); } /*void pulso1() { int leitura_atual = digitalRead(buttonPin); if (leitura_atual != leitura_anterior) { tempo_debounce = millis(); debounce_ok = 1; } if (millis() - tempo_debounce > debounce_delay) { debounce_ok = 1; } if (debounce_ok == 1) { if (leitura_atual == 0 && leitura_anterior_db == 1) { digitalWrite(RELAY1, !digitalRead(RELAY1)); } leitura_anterior_db = leitura_atual; } leitura_anterior = leitura_atual; }*/ void pulso2() { int leitura_atual2 = digitalRead(buttonPin); if (leitura_atual2 != leitura_anterior2) { tempo_debounce2 = millis(); debounce_ok2 = 0; } if (millis() - tempo_debounce2 > debounce_reset) { debounce_ok2 = 1; } if (debounce_ok2 == 1) { if (leitura_atual2 == 0 && leitura_anterior_db2 == 1) { WiFi.disconnect(); delay(500); ESP.reset(); } leitura_anterior_db2 = leitura_atual2; } leitura_anterior2 = leitura_atual2; }