Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPIO pins not working when set to output #10

Closed
goran-mahovlic opened this issue Nov 29, 2014 · 8 comments
Closed

GPIO pins not working when set to output #10

goran-mahovlic opened this issue Nov 29, 2014 · 8 comments

Comments

@goran-mahovlic
Copy link

Hi, I have put some LED on 0,1,2,3 and only pin 1 is working ok, is this normal?
I set them as output, write HIGH or LOW, read value, but values does not change, and leds are not starting, except pin1, GPIO13 is working ok.

0 GPIO12 not working as output
1 GPIO13 working OK
2 GPIO14 not working as output
3 GPIO15 not working as output
8 GPIO0 can this pin be output?
9 GPIO2 can this pin be output?

@nodemcu
Copy link
Collaborator

nodemcu commented Nov 29, 2014

check the hardware, to see if these pins are connected to GND or VCC

@gorec2005
Copy link

I have check
2 GPIO14
8 GPIO0
9 GPIO2
work for output (i connect to this pin's reley module with optocoupler) well...

@ra3vld
Copy link

ra3vld commented Nov 30, 2014

At me after executing gpio.read(pin) (when it set to output ), this pin set to a high level.

@goran-mahovlic
Copy link
Author

I tried to write on all pins, and 5 6 7 are resetting module, those pin coud be connected to VCC
I have module 01 and applied ugly patch so may be that I did something wrong
here is the list of working pin (sets pin HIGH LOW with software, didi not check it with diodes)
http://pastebin.com/DsFFyxsG
I can confirm that pin10 - GPIO4 is working with diode
here is my working sample to change diode state thrue the telnet so you can write similar sample other samples I did find on internet did not work
http://www.lemilica.com/esp8266-wifi-modul/
If someone can test other pins on diferent modules it woud be great
Here is blink led sample thatI used with removed 5 6 7 pins
http://pastebin.com/vDA7HNs1

@Scott--R
Copy link

My apologies if I'm posting incorrectly. I'm new to Git, programming, and well, everything involving this chip actually. A week ago I knew nothing about HTML, LUA, etc and today I know little more.
I have been working with GPIO2 (pin 9), and setting to output is no problem, and writing to it is no problem. I have created PHT pages that nicely control GPIO2 output using the web server code. However, I have noticed that when I read the port using a command like print(gpio.read(9)), or any command that includes reading the port gpio.read(9) it will return the correct value, but then immediately set the output to LOW.

@JamesNewton
Copy link

I don't understand why you would want to read a pin that is set as an
output. If it's an output, then you are controlling it's level from the
program. E.g. if you set it as an output and high, then why read it? You
know it's going to be high! If you set it as output low, you know its low.
Outputs are not read. Inputs are read.

Now this part I'm not sure about, but I would guess that when you do a
read, the chip is "thinking" "He is reading this pin, he must want to use
it as an input now, I'll change it from output to input and then read the
value on the pin". So you are seeing a low after read because it is now an
input, not because the output value was changed.

Again, the real issue is: What are you trying to accomplish by reading an
output pin?

On Fri, Dec 12, 2014 at 7:29 AM, Scott--R notifications@github.com wrote:

My apologies if I'm posting incorrectly. I'm new to Git, programming, and
well, everything involving this chip actually. A week ago I knew nothing
about HTML, LUA, etc and today I know little more.
I have been working with GPIO2 (pin 9), and setting to output is no
problem, and writing to it is no problem. I have created PHT pages that
nicely control GPIO2 output using the web server code. However, I have
noticed that when I read the port using a command like print(gpio.read(9)),
or any command that includes reading the port gpio.read(9) it will return
the correct value, but then immediately set the output to LOW.


Reply to this email directly or view it on GitHub
#10 (comment)
.

James Newton
MassMind.org http://www.MassMind.org
1-970-462-7764

@Scott--R
Copy link

Thanks James. The purpose for the port read is to invert the output from its current state. So, for example, I have a section of code that checks the current status of the output. If it is currently high, then change it to low. If it is currently low, change it to high. I could do this by creating a status variable I suppose, and then check that variable instead of reading the GPIO directly. And you may be correct on the whole "change output to input" thing as well. Thanks for the feedback. This is quite the challenge - I have to learn HTTP, encryption, HTML, PHT, LUA, and probably a bunch of other stuff I haven't even discovered yet to get all of this working. But it's FUN! I've got a bunch of the latest modules on the way over to play with.

@JamesNewton
Copy link

Ah. Google "read modify write problem" for more on why a status variable
(aka shadow register) is a good idea.
On Dec 12, 2014 10:07 AM, "Scott--R" notifications@github.com wrote:

Thanks James. The purpose for the port read is to invert the output from
its current state. So, for example, I have a section of code that checks
the current status of the output. If it is currently high, then change it
to low. If it is currently low, change it to high. I could do this by
creating a status variable I suppose, and then check that variable instead
of reading the GPIO directly. And you may be correct on the whole "change
output to input" thing as well. Thanks for the feedback. This is quite the
challenge - I have to learn HTTP, encryption, HTML, PHT, LUA, and probably
a bunch of other stuff I haven't even discovered yet to get all of this
working. But it's FUN! I've got a bunch of the latest modules on the way
over to play with.


Reply to this email directly or view it on GitHub
#10 (comment)
.

@nodemcu nodemcu closed this as completed Jan 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants