-->
Page 1 of 3

[SOLVED] pinMode(D8, INPUT_PULLUP) not pulling up

PostPosted: Sat Sep 03, 2016 9:34 am
by cems
I have tried the following on a HUZZAH and 2 different nodeMCU 1.0 boards (12E) that I am programming via the Arduino IDE 1.6.10 (I can also use platformIO as an IDE).

I am trying to use the internal pullup on various pins (D8 or D4 which correspond to GPIO15 GPIO2 respectively) without any success. I am modifying the standard Blink program to add the following line to setup()

pinMode(D8,INPUT_PULLUP);

alternatively I also tried instead to use this style of pullup:
pinMode(D8,INPUT);
digitalWrite(D8,true);


Then in the loop() I add:
Serial.println(digitalRead(D8));

I'm expecting to see the input will read as a 1, but what I get is a set of zeros. If I connect something external to the input then I can make the input either a 1 or a 0 so it's working as an input. But the pullup is not working.

Googling I see discussions of, at one time, INPUT_PULLUP not working and then some fellow named zeroday fixing it so it did work. But all these discussions seemed to be about nodeLua so I don't know if they apply to programming in Ardunio IDE.

The Arduino website also says INPUT_PULLUP should work on the ESP8266

Anyhow I'm posting this in sept 2016. Surely this should be working??? all boards behave the same and all the pins i've tried act similarly. (I realize that GPIO 16 is special and I'm not trying that pin)

Code: Select all#include <Arduino.h>
#define ESP8266_LED 2

void setup()
{

  pinMode(ESP8266_LED, OUTPUT);
  Serial.begin(9600);
  Serial.println("setup");
  pinMode(D8,INPUT_PULLUP);

}

void loop()
{
 
  Serial.println(D8);
  Serial.println(digitalRead(D8));
  digitalWrite(ESP8266_LED, HIGH);
  delay(500);
  digitalWrite(ESP8266_LED, LOW);
  delay(2500);
  Serial.println("loop de doop bb");
}

Re: pinMode(D8, INPUT_PULLUP) not pulling up any pin

PostPosted: Sat Sep 03, 2016 10:29 am
by martinayotte
Since GPIO15 (D8) is used by the boot mode process, most of the boards have this pin pulled down by an external resistor, which is stronger than internal weak pullup.

SOLVED Re: pinMode(D8, INPUT_PULLUP) not pulling up any pin

PostPosted: Sat Sep 03, 2016 4:40 pm
by cems
Thanks.

SO THE SOLUTION TO MY PROBLEM IS THAT I RANDOMLY DECIDED TO USE PIN D8 for the test and of all the pins this one is pulled down externally. GAAH! And then I totally confused myself by then choosing D4 (GPIO2) as the next randomly chosen pin and it's the only other pin this fails on due to the the external wiring to the LED.

:lol: FACE PALM.

I've alos noticed that some other pins cause problems as well (like GPIO 1 which kills the serial monitor when pulled high). and some pins are pulled high externally.

Is there a good way I should be able to know these externalities in advance?

Re: [SOLVED] pinMode(D8, INPUT_PULLUP) not pulling up

PostPosted: Sat Sep 03, 2016 4:55 pm
by martinayotte
By looking at the schematic of NodeMCU ... :ugeek: