I am using a NodeMCU board and have already used 6 digital pins as output for interfacing with the LCD. I intend to use 2 more digital pins, one as input and other as output for interfacing an ultrasonic sensor.

D8, D4 and D3 are the only digital pins remaining. I understand that D8 (GPIO15), D4 (GPIO2) and D3 (GPIO0) pins of the NodeMCU have special boot-controlling uses. So how can I use those pins as generic digital pins. Any help is appreciated.

  • 1
    I would recommend to use an I2C LCD display – Juraj Mar 14 '19 at 10:59
  • you can get an I2C LCD controller for well under $1USD on ebay. – dandavis Mar 14 '19 at 16:28
  • I'm aware of this. I was looking for a way to implement D8, D4 and D3 as gpio pins. Thank you. – maheshmt Mar 14 '19 at 17:00

The boot setup pins have pull-up on board (0, 2) and pull-down (15) to ensure the correct boot. io 0 (D3) is additionally wired to the reset circuit controlled over USB to put the esp8266 into bootloader a.k.a. flashing mode.

io 0 must be HIGH for normal boot, io 2 must not be LOW (can float according to spec).

If you attach a device to this pins, the device must respect the boot state. Some devices will pull-down or pull-up a wired pin. Usually it is not documented. You can't use such devices on boot config pin which requires the other state.

The pull-up and pull-down can influence the attached device or readings from the device. For some elements it can be advantageous.

Best is to use this pins for elements which would need pull-up or pull-down anyway. For example buttons/switches or sensors which behave like buttons or switches.

In my project with Wemos D1 R2 I had signal to relay module on io 0, speaker module (with amplifier) for tone() function on io 2. I could not use a relay or mosfet module on io 2. On io 15 I had a reed relay module control signal, which I didn't want to go HIGH at boot as most esp8266 io pins do.

  • Thank you for the info. So how can interface an ultrasonic sensor to any of those 3 pins. Obviously both the trig and echo pins change states to high or low. – maheshmt Mar 14 '19 at 8:20
  • only the state at startup matters to esp8266. the distance sensor could be disturbed by the pull-ups or pull-downs. you know when you try it. try io 0 and io 15 first. – Juraj Mar 14 '19 at 8:39

Not a direct answer to your question, but some other way that solves your problem, is to use a shift register like 74HC595 and control the 6 pins for the LCD with the 74HC595 which only uses 3 (digital GPIO) pins. That saves you 3 pins for others. Actually you can use 8 pins or even 32 when you daisy chain four 74HC595s.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.