ESP8266 12F Interrupt GPIOs

Which pins are available for interrup in esp8266 12f? ( I.E. attachInterrupt(digitalPinToInterrupt(5), checkPin, CHANGE);

GOOGLE is your friend… a quick search of your title phrase found this at the top:

http://www.esp8266.com/wiki/doku.php?id=esp8266_gpio_pin_allocations

Interrupts

Pin interrupts are supported through attachInterrupt(), detachInterrupt() functions. Interrupts may be attached to any GPIO pin except GPIO16, but since GPIO6-GPIO11 are typically used to interface with the flash memory ICs on most esp8266 modules, applying interrupts to these pins are likely to cause problems. Standard Arduino interrupt types are supported: CHANGE, RISING, FALLING.

Thanks Gunner, when I push the buttom (Interrup to GND) seems that the interruption is fired and the system crash, I mean it goes offline and stop making all the other instructions, what can be the reason?

    //needed for library
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>         //https://github.com/tzapu/WiFiManager


 // ****************************************************************
 
 #include <Ultrasonic.h>  // se incluye la librería ultrasónica

 Ultrasonic ultrasonic(14,4); // (Trig PIN,Echo PIN)

 // *************************************************************

#include "DHT.h"

#define DHTPIN 0    // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)
DHT dht(DHTPIN, DHTTYPE);

//  ******************************************************************

#include <SimpleTimer.h>
SimpleTimer timer;

//  ****************************************************************

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "8a9c8df766c84ed99380391f34d653ea";



WidgetLED led1(V10);
WidgetLED led2(V12);


void checkPin()                                       // *************************************************PARA INTERRUPCION EXTERNA

{

  // Invert state, since button is "Active LOW"
  Serial.print(" INTERRUPCION ");  

  if (digitalRead(5)) {

    led1.off();
    //digitalWrite(12,LOW);
    

  } else {

    led1.on();
    //digitalWrite(12,HIGH);
    

  }

}


//void CONECTAR()



void sendTEMP()
{
  
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit
  float f = dht.readTemperature(true);

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  // Compute heat index in Celsius (isFahreheit = false)
  float hic = dht.computeHeatIndex(t, h, false);

  int pir = digitalRead(16);  // ***********************************  Sensor PIR conectado a GPIO16

  float ult = ultrasonic.Ranging(CM); // CM o INC

  

  Serial.print(" Temperatura *C: " );  
  Serial.println(t);     

  Serial.print(" Humedad %: " );  
  Serial.println(h);     

  Serial.print(" Sensacion termica *C: ");  
  Serial.println(hic);

  Serial.print(" Sensor de movimiento: ");
  Serial.println(pir);

  Serial.print(" Distancia en cm: ");   
  Serial.println(ult);

                      
  Blynk.virtualWrite(V1,t);
  Blynk.virtualWrite(V2,h);
  Blynk.virtualWrite(V3,hic);
  Blynk.virtualWrite(V4,pir);
  Blynk.virtualWrite(V5,ult);

  //led1.on();
  led2.setValue(128);
  

  }


//  ********************************************************************************

void setup()              //---------------------------------------------------------------------- SETUP -------------------------------------------------------------
{
  Serial.begin(115200);   

  //timer.setInterval(4000, CONECTAR); //1000=1s
  
  WiFiManager wifiManager;
  //reset settings - for testing
  //wifiManager.resetSettings();

  //sets timeout until configuration portal gets turned off
  //useful to make it all retry or go to sleep
  //in seconds
 //******************************************* wifiManager.setTimeout(180);
  
  //fetches ssid and pass and tries to connect
  //if it does not connect it starts an access point with the specified name
  //here  "AutoConnectAP"
  //and goes into a blocking loop awaiting configuration
  wifiManager.autoConnect("arvac");

  Blynk.config(auth);

 
  pinMode(5, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(5), checkPin, CHANGE);

  
  //**********************************************************************    AGREGADO PARA SYNC
    
while (Blynk.connect() == false) {  }
    
  Blynk.syncAll(); 

  //**********************************************************************

  dht.begin();                      // INICIAR SENSOR DE TEMPERATURA

  timer.setInterval(5000, sendTEMP); //1000=1s

  //************************************************************************
}


void loop()                                                           // --------------------------------   LOOP -----------------------------------------------

{

  
   Blynk.run();
  
  timer.run();

//************************************************************



}

Albaro solved the problem with interruptions and blynk … is that I also do not work a program that I’m doing and that uses blynk and interruptions … if I don’t using blynk the program that works.

Lo pongo tambien en castellano que mi ingles no es muy bueno.
Albaro solucionaste el problema con las interrupcciones y blynk … es que a mi tampoco me funciona un programa que estoy haciendo y que usa blynk e interrupciones … si dejo de usar blynk si que funciona.

S2

@gurues Old topic :stuck_out_tongue: If you have an issue, please create your own topic and we will try to assist.