Default off for output pins on esp8266

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
trashguy
Posts: 1
Joined: Tue Jun 20, 2017 7:14 am

Default off for output pins on esp8266

Post by trashguy » Tue Jun 20, 2017 7:18 am

This may be a simple question but I have looked around and haven't searched for the right thing yet I guess :D Is there a way to set the GPIO pins on an esp8266 to be off at boot. I have a relay board connected to the GPIO pins and when the esp8266 boots it cycles the relays on before my code can load. Thanks in advance.

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

Re: Default off for output pins on esp8266

Post by deshipu » Tue Jun 20, 2017 10:28 pm

In short, no.

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

Re: Default off for output pins on esp8266

Post by pythoncoder » Wed Jun 21, 2017 3:54 am

The usual behaviour of GPIO pins on microcontrollers is that on boot they are high impedance. This means that their logical state can be determined with an external resistor to pull them up or down. For example most ESP8266 boards have a pull down resistor on pin 15; that pin will start in a low state until you configure it as an output and determine its state in code.

In the absence of a schematic for the relay board it's hard to be sure. It would seem that it's reacting to the high impedance state by turning the relays on (which seems surprising). I'd suggest experimenting with external resistors (say 1KΩ) to pull the lines to the required level (presumably 0v) to ensure the relays start in the off state.
Peter Hinch
Index to my micropython libraries.

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

Re: Default off for output pins on esp8266

Post by deshipu » Wed Jun 21, 2017 8:31 am

Many of ESP8266's pins don't stay high-z on boot, but are instead used for the bootloader for signalling various things. gpio0, gpio2 and gpio15 select the boot mode, gpio1, gpio2 and gpio3 give debugging serial output, etc. Since the bootloader is hardcoded and doesn't allow disabling this, there is nothing you can do except for using pins that are not booby-trapped this way.

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

Re: Default off for output pins on esp8266

Post by pythoncoder » Thu Jun 22, 2017 10:38 am

To expand on this P15 has a pulldown and P0 and P2 have pullups; that is the case on the reference board and WeMos Mini schematics. On the reference board P0 and P2 drive the red and blue LED's which do flash on boot. UART 1 transmits on P2. As you say, P1 and P3 are UART 0.

So we're left with P4, P5, P12, P13, P14 and P16 which presumably stay hi-z on boot. As far as I know P15 remains low throughout boot - I think it plays some role as an input for boot mode detection.
Peter Hinch
Index to my micropython libraries.

Post Reply