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");
}
}