Skip to content

Using pinMode, attachInterrupts() and Wifi Access Point breaks #5026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
WolfBSail opened this issue Aug 10, 2018 · 1 comment
Closed

Using pinMode, attachInterrupts() and Wifi Access Point breaks #5026

WolfBSail opened this issue Aug 10, 2018 · 1 comment

Comments

@WolfBSail
Copy link

I have a similar issue as #1020, using ESP12E board. When I am declaring certain pins, using attachInterrupts() and setting up Access Point WiFi in the same void setup() the wifi stops working. I have tested out that if I only declare pins D0, D1, D2, D3, D4, A0 and set up WiFi without the interrupts it does work. Please seen my code below!
I have tried detachInterrupt(), but it did not work.

Does anyone have the same problem? Is there a solution to this problem?

Thank you in advance.

MCVE Sketch

void setup() {
  pinMode(2, INPUT);
  pinMode(1, INPUT);
  pinMode(A0, INPUT_PULLUP);
  pinMode(0, OUTPUT);  //D0

  Serial.begin(9600);

  rtcObject.Begin();
  attachInterrupt(digitalPinToInterrupt(secPin), secondReceive, FALLING);
  attachInterrupt(digitalPinToInterrupt(voltagePin), voltageDrop, FALLING);

  // Init EEPROM
  EEPROM.begin(512);

  // look at whether power-cut time correction is neccessary
  if (EEPROM.read(addr[3]) == 1) {

    clockEnabled = 1;
    startTime = millis();
    Serial.println();
    Serial.println("Blackout has happened, time correction...");
    Serial.println();
    getRtcTime();
    EEPROM.write(addr[6], rtcHour);
    EEPROM.write(addr[7], rtcMinute);
    EEPROM.write(addr[8], rtcSecond);
    powerCutTimeCorrection();
    EEPROM.write(addr[3], 0);
    EEPROM.commit();
    loopTime = millis();
  }
  else {
    configRTC(ntpYear, ntpMonth, ntpDay, ntpHour, ntpMinute, ntpSecond);
    RtcDateTime currentTime = rtcObject.GetDateTime();
    rtcObject.SetDateTime(currentTime);
  }

  //init rtc functions
  rtcObject.SetSquareWavePin(DS3231SquareWavePin_ModeClock);
  rtcObject.SetSquareWavePinClockFrequency(DS3231SquareWaveClock_1Hz); //SQW set to 1Hz

//  detachInterrupt(digitalPinToInterrupt(secPin)); tried these...did not work
//  detachInterrupt(digitalPinToInterrupt(voltagePin));

  //creating the ESP's own network
  WiFi.disconnect();
  WiFi.mode(WIFI_AP);
  WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
  WiFi.softAP(ssidESP, passwordESP);
  Serial.print("Connected to ");
  Serial.println(ssidESP);
  Serial.print("Access Point IP address = ");
  Serial.println(WiFi.softAPIP());
  Serial.println("");


  handleWebsite();   // crating html string;
  dnsServer.start(DNS_PORT, "*", apIP);
  server.on("/", handleWebsite);
  server.on("/generate_204", handleWebsite); // for android captive
  server.on("/fwlink", handleWebsite);       // windows captive
  server.begin();

  server.onNotFound([]() {
    server.send(200, "text/html", webSite);
  });

  webSocket.begin();
  webSocket.onEvent(webSocketEvent);

}
@devyte
Copy link
Collaborator

devyte commented Aug 10, 2018

Code is incomplete, the issue template was ignored. Please open a new issue, follow the instructions on the issue template, and fill out the required info.
Closing.

@devyte devyte closed this as completed Aug 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants