GPIO input pin questions

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
BigL3g
Posts: 3
Joined: Thu May 19, 2016 1:23 am

GPIO input pin questions

Post by BigL3g » Thu May 19, 2016 1:49 am

I am trying to set up a GPIO pin to look for pin 5 to go from low to high.

in the tutorial http://docs.micropython.org/en/latest/e ... /pins.html it says:

"To make an input pin use:
[code]
>>> pin = machine.Pin(0, machine.Pin.OUT, machine.Pin.PULL_UP)
[/code]
You can either use PULL_UP or None for the input pull-mode. If it’s not specified then it defaults to None, which is no pull resistor."

None gives a syntax error - I think I read in the release notes that this is a known bug?

But in the QuickRef ( http://docs.micropython.org/en/latest/e ... s-and-gpio )it says to use
[code]
p2 = Pin(2, Pin.IN) # create input pin on GPIO2
[/code]

Thinking the tutorial is outdated or a typo I have been using the QuickRef, however the pin always returns high, even without hardware attached. Should I be using the other one?

Thanks!

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: GPIO input pin questions

Post by dhylands » Thu May 19, 2016 2:04 am

Using machine.Pin.OUT will definitely not make the pin an input. That's a bug in the documentation.

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

Re: GPIO input pin questions

Post by deshipu » Thu May 19, 2016 8:08 am

There is another issue. Pins GPIO2, GPIO0 and GPIO15 are used to select the boot mode for ESP8266, and if you are using a development board, they probably have external pull-up or pull-down resistors in there, to make sure the board boots properly.

BigL3g
Posts: 3
Joined: Thu May 19, 2016 1:23 am

Re: GPIO input pin questions

Post by BigL3g » Thu May 19, 2016 3:02 pm

I am using pin 5 as the input. I may try an external 10k pull down resistor in hardware to see if it is just floating and going to rail.

Datasheet for the -12 says High starts as .75 v?

Sent from my SM-G930V using Tapatalk

User avatar
mcauser
Posts: 507
Joined: Mon Jun 15, 2015 8:03 am

Re: GPIO input pin questions

Post by mcauser » Thu Jun 02, 2016 4:56 am

For reference, the WeMos D1 mini dev board has the following configuration:
GPIO0 -> 10k -> 3V3
GPIO2 -> 10k -> 3V3
GPIO15 -> 10k -> GND

Post Reply