1

I'm working on a project with reed switches, which are connected between a GPIO pin (in pullup mode) and ground. With some of my NodeMCU ESP-12E boards (HiLetGo brand) that I ordered, whenever the reed switch on GPIO9/SD2 is closed, the board is rebooting. However, some of these same boards do not exhibit this same behavior - the reed switch on this pin works correctly.

The reset reason is Fatal exception:4 flag:1 (WDT)

Is there any reason that some boards would work while others don't? Is this pin generally safe to use as an IO pin? I need at least 8 GPIO pins to work per board, and I'm having a hard time finding enough of them.

Here's my code, for reference

int REED_PIN = 9;
void setup() {
  Serial.begin(9600);
  Serial.println("Setup");
  
  pinMode(REED_PIN, INPUT_PULLUP);
  Serial.println(ESP.getResetInfo());
}

// the loop function runs over and over again forever
void loop() {
  int proximity = digitalRead(REED_PIN);
  if (proximity == LOW) {
    Serial.println("Magnet detected");
  }
}
Tom
  • 11
  • 1
  • GPIO9 is connected to the flash memory chip on the NodeMCU. It should not be used as a general I/O. You can find out more about what NodeMCU pins you can use and for what purposes, [on this page](https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/) – StarCat Nov 15 '21 at 16:25
  • use pin 10 instead and set the flash to DIO to free it up. – dandavis Nov 16 '21 at 18:33

0 Answers0