Reading GPIO: what am I doing wrong?
Posted: Wed Jan 21, 2015 1:01 am
Using the ESP8266-01, I am trying to read the states of GPIO:0 and GPIO:2 as I am applying either 3.3 v or 0 v to them.
As can be seen below, I have been getting very strange results:
This is the code that I ran:
The code returned these results (for both 3.3 v and 0 v):
I have tried this with build 20150118 and build 20150108.
I must be doing something wrong. Any hints?
As can be seen below, I have been getting very strange results:
Code: Select all
Voltage | Pin | Mode | Value returned
3.3 v GPIO:0 Pullup 1
3.3 v GPIO:0 Float 1
3.3 v GPIO:2 Pullup 1
3.3 v GPIO:2 Float 1
0 v GPIO:0 Pullup 1
0 v GPIO:0 Float 1
0 v GPIO:2 Pullup 1
0 v GPIO:2 Float 1
This is the code that I ran:
Code: Select all
function readpin (pin, mode)
-- Mode = 0 means float. Mode = 1 means pullup.
gpio.mode(pin, gpio.INPUT, mode)
print("PIN" .. pin .. "=" .. gpio.read(pin) .. ", in mode: " .. mode)
end
readpin(0, 0)
readpin(0, 1)
readpin(2, 0)
readpin(2, 1)
The code returned these results (for both 3.3 v and 0 v):
Code: Select all
PIN0=1, in mode: 0
PIN0=1, in mode: 1
PIN2=1, in mode: 0
PIN2=1, in mode: 1
I have tried this with build 20150118 and build 20150108.
I must be doing something wrong. Any hints?