attachInterrupt during wifi.begin

mojesp32s
Posts: 4
Joined: Wed Aug 22, 2018 5:01 pm

attachInterrupt during wifi.begin

Postby mojesp32s » Sun Sep 02, 2018 10:00 am

Hi

I have a question about attachInterrupt during wifi.begin.

I have a simple rain sensor working with attachInterrupt.

Problem is when i start wifi.begin it takes around 10 seconds to connect but during that time attachInterrupt doesnt work. I mean it doesnt trigger.

So my question is this normal that attachInterrupt doesnt work when wifi is trying to connect or there is something wrong with my code? It works normally after connections is established.

Code: Select all

void IRAM_ATTR handleInterruptRain() {
  portENTER_CRITICAL_ISR(&sensorRain_mux);
  sensorRain_interruptCounter++;
  portEXIT_CRITICAL_ISR(&sensorRain_mux);
}

void setup() {
{

    pinMode(sensorRain_PIN, INPUT_PULLUP);
    attachInterrupt(digitalPinToInterrupt(sensorRain_PIN), handleInterruptRain, FALLING);

    wd_timer_rain = timer.setInterval(10, readRain);

    while (WiFi.status() != WL_CONNECTED) {
       WifiSettings();
    }

}

void readRain() {
    portENTER_CRITICAL(&sensorRain_mux);
    sensorRain_interruptCounter--;
    portEXIT_CRITICAL(&sensorRain_mux);

   do something ...
}

void WifiSettings() {

      WiFi.begin(AAAAAAAAA, passssss);

      int waitTimeLimit = 15;
      unsigned int startTime = millis()/1000;
      unsigned int endTime= millis()/1000;

      while (WiFi.status() != WL_CONNECTED && (endTime - startTime) <= waitTimeLimit) {
        endTime = millis()/1000;
      }
      
      if (WiFi.status() == WL_CONNECTED) {
        #ifdef DEBUG_WIFI
          Serial.println(String("WIFI - Connected to ") + WiFi.SSID());
        #endif
      }
}

Who is online

Users browsing this forum: lbernstone and 119 guests