GPIO15/D8 on NodeMCU going high by default

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
cefn
Posts: 230
Joined: Tue Aug 09, 2016 10:58 am

GPIO15/D8 on NodeMCU going high by default

Post by cefn » Tue Jun 27, 2017 9:26 am

I've been allocating pins for a project, and ended up with the choice of the following pins which are not already in use...
  • D0/GPIO16
  • D3/GPIO0
  • D8/GPIO15
I need to allocate a power-latching pin for the device to tell itself to power down. Unfortunately I found that GPIO15 powers up with an active high as default, for a reason I can't fathom and I would like to prevent it doing so.

The selected pin needs to wire to OFF on a Polulu latching circuit 2808 https://www.pololu.com/product/2808 and should only send a HIGH pulse when it's ready to power off. The rest of the time it should be 0V.

I did a bunch of research yesterday comparing the pins ( https://github.com/cheapjack/MileCastles/issues/104 ) and drew the conclusion that GPIO15 would be a good choice, as it's already pulled down (by e.g. the NodeMCU v0.9 schematic I could find), to ensure the ESP8266 powers up in the correct mode.

I was therefore expecting that GPIO15 would stay pulled low and after boot I would configure GPIO15 as an output with an explicit value(0). At a later time I would send it a value(1) and the latching circuit would power everything down.

Imagine my surprise when I did a quick test of GPIO15/D8 this morning with an LED in it. After power up, the LED is bright as day, suggesting that GPIO15 is actively driven high for some reason I can't fathom.

Is there a way to prevent GPIO15 from being actively driven high before I get a chance to make it an output and send an active low?

Alternatively can I make use of any of the other pins to wire a software-controlled pin to OFF, which stays low until configured as an active high? I believed none of the other pins would be reliable, because they are frequently pushed HIGH as part of a power-up sequence.

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: GPIO15/D8 on NodeMCU going high by default

Post by deshipu » Tue Jun 27, 2017 10:24 am

The ESP8266 uses the pins gpio0, gpio1, gpio2, gpio3 and gpio15 in its boot process, and there is nothing that can be done about it. The bootloader is hardwired in the chip's ROM memory. If you need the pins in a particular state at boot, choose other pins than the listed.

cefn
Posts: 230
Joined: Tue Aug 09, 2016 10:58 am

Re: GPIO15/D8 on NodeMCU going high by default

Post by cefn » Sun Jul 02, 2017 8:47 am

Thanks for the reply, @deshipu. Sorry for my lack of response, I forget to tick the 'subscribe me for replies' box every darn time.

I totally accept that the dual role of GPIO15 and the related pins is non-negotiable, both in terms of how the ESP8266 responds to them, and also the pull-up wiring that a typical host board has in order to satisfy the boot contract. The issue I am raising already takes account of this, I believe.

I believe my expectations are compatible with this boot contract, unless I have misunderstood something, and if so it would be good to know what I have misunderstood.

1) I thought I understood the dual role of GPIO15, and that it was to be pulled down on boot
2) I wouldn't expect any 'active high' or low behaviour at all from GPIO15 even taking account of its boot role without triggering a high-output specifically in micropython (having a pull-down or pull-up resistor wired to it shouldn't be able to light an LED I think).

The table I'm referring to is at http://www.esp8266.com/wiki/doku.php?id ... llocations (search for the string 'NormalRunning'). It indicates that GPIO15 in 'UploadCode' and 'NormalRunning' mode GPIO15 is to be pulled down, which is perfectly compatible with the use I hope to make of it (pulled to ground until set as an output in my own software and set with pin.value(1). The wiring of the NodeMCU host board that I could find, indicates this is achieved by a hard-wired pull-down resistor to GPIO15.

However, for some reason in the Micropython image, until I assert in my code that GPIO15 is an output, it delivers an active high enough to light an LED. I can't find any commentary that explains this in terms of the boot sequence.

I am therefore either misunderstanding the reference resource, or some software default in the Micropython image is setting it to an active high in a way that I can't find documentation for. Does anyone know which mistake I am making?

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: GPIO15/D8 on NodeMCU going high by default

Post by pythoncoder » Mon Jul 03, 2017 5:54 am

@cefn This does not occur on the Adafruit Feather Huzzah reference board. I have a project which depends on pin 15 remaining low during and after boot. And I've just double-checked with a meter.
Peter Hinch
Index to my micropython libraries.

chrisb2
Posts: 28
Joined: Sat Apr 01, 2017 4:19 am

Re: GPIO15/D8 on NodeMCU going high by default

Post by chrisb2 » Mon Jul 03, 2017 7:01 am

I have this NodeMcu clone and just received my Pololo switch today, experiments show that only the following GPIO pins do not go high during startup:

GPIO5 (D1)
GPIO4 (D2)
GPIO15 (D8)

regards,
Chris

cefn
Posts: 230
Joined: Tue Aug 09, 2016 10:58 am

Re: GPIO15/D8 on NodeMCU going high by default

Post by cefn » Mon Jul 03, 2017 9:37 am

Thanks all for the reference information.

The situation is getting weirder, in that it seems that in my current configuration (different work desk) I can boot the NodeMCU in a breadboard and the LED doesn't light but if I manually remove and replace the LED in the breadboard a few times (with nothing else connected other than the USB cable) then the LED occasionally decides to light up.

Something about my physical setup previously must have been triggering the same physical effect I imagine, although I still find it hard to understand what is going on that could cause the board to 'drift' into full output drive mode on GPIO15 without any software intervention.

However, it is alarming to consider deploying a device with this pin wired to OFF on a soft-latch power module as if the same effect appears again, then it will randomly not power up.

When the circumstances arise for the LED to light itself, and I run (against my cockle module)

Code: Select all

cockle.pins[8].init(mode=Pin.OUT)
...then the LED extinguishes, suggesting that from the point of view of the micropython interpreter, the pin was not previously considered an output.

For reference, the cockle module is at https://github.com/ShrimpingIt/cockle/b ... /cockle.py and helps to re-map the Pin numbers for those printed on the board.

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: GPIO15/D8 on NodeMCU going high by default

Post by deshipu » Mon Jul 03, 2017 10:09 am

Can you post a schematic of your connections?

cefn
Posts: 230
Joined: Tue Aug 09, 2016 10:58 am

Re: GPIO15/D8 on NodeMCU going high by default

Post by cefn » Mon Jul 03, 2017 2:09 pm

The schematic of my circuitry (such as it is);

One Green LED between Anode:D8/GPIO15 and Cathode:GND

...that's it, unless you count the USB lead which is powering the NodeMCUv2 and providing the serial connection back to my laptop.

I tried to get a schematic for the NodeMCUv2, but only found one labelled v0.9 at https://raw.githubusercontent.com/nodem ... IT_SCH.png which I imagine is overall indicative of the way the NodeMCUv2 is wired. See https://github.com/nodemcu/nodemcu-devkit-v1.0/issues/4 for a kind of dead end on getting a V2 schematic.

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: GPIO15/D8 on NodeMCU going high by default

Post by deshipu » Mon Jul 03, 2017 3:03 pm

That really sounds like something is wrong with your development board. But then, if GPIO15 is not pulled low, it would fail to boot into the correct mode and you wouldn't even be able to flash it, so the symptoms you are describing are really confusing.

cefn
Posts: 230
Joined: Tue Aug 09, 2016 10:58 am

Re: GPIO15/D8 on NodeMCU going high by default

Post by cefn » Mon Jul 03, 2017 4:46 pm

Here's a video of the behaviour...

https://www.youtube.com/watch?v=2NqJSPEN1vU

Post Reply