Page 1 of 1
Using the GPIO0 /GPIO2 for OUTPUT and RX for INPUT
Posted: Wed Jun 20, 2018 5:25 pm
by tonyldo
how can i write this code with micropython?
Code: Select all
void Setup() {
Serial.begin(115200,SERIAL_8N1,SERIAL_TX_ONLY);
pinMode(2, OUTPUT);
pinMode(0, OUTPUT);
pinMode(3, INPUT_PULLUP);
...
I will use on this circuit:
https://www.forward.com.au/pfod/ESP8266 ... UTPUTS.jpg
Re: Using the GPIO0 /GPIO2 for OUTPUT and RX for INPUT
Posted: Wed Jun 20, 2018 7:53 pm
by kevinkk525
You might want to have a look at the documentation:
https://docs.micropython.org/en/latest/ ... /pins.html
What board are you trying to use?
Re: Using the GPIO0 /GPIO2 for OUTPUT and RX for INPUT
Posted: Thu Jun 21, 2018 12:29 am
by tonyldo
The documentation doesn't talk about the use of RX pin (gpio 3, esp01 module) as ordinary input pin and anything about disable the input serial comunication with something like this statement:
Code: Select all
Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
Enviado de meu XT1580 usando o Tapatalk
Re: Using the GPIO0 /GPIO2 for OUTPUT and RX for INPUT
Posted: Thu Jun 21, 2018 3:26 pm
by tonyldo
I'll test this in boot.py:
Code: Select all
import uos, machine
TX_PIN = 1
uos.dupterm(none, 1)
uos.dupterm(machine.UART(0, 115200, pins=(TX_PIN, None)), 1)
and in main.py:
Code: Select all
import machine
RX_PIN = 3
pin = machine.Pin(RX_PIN , machine.Pin.IN, machine.Pin.PULL_UP)
Re: Using the GPIO0 /GPIO2 for OUTPUT and RX for INPUT
Posted: Sat Jul 28, 2018 4:17 pm
by newb
[quote=tonyldo post_id=28282 time=1529594788 user_id=4089]
I'll test this in boot.py:
[CODE]
import uos, machine
TX_PIN = 1
uos.dupterm(none, 1)
uos.dupterm(machine.UART(0, 115200, pins=(TX_PIN, None)), 1)
[/CODE]
and in main.py:
[CODE]
import machine
RX_PIN = 3
pin = machine.Pin(RX_PIN , machine.Pin.IN, machine.Pin.PULL_UP)
[/CODE]
[/quote]
Have you managed to solve this? I'm in the same situation - I'd like to use RX (pin 3) for button input, but it it doesn't work.
Re: Using the GPIO0 /GPIO2 for OUTPUT and RX for INPUT
Posted: Sat Jul 28, 2018 7:28 pm
by newb
Looks like I solved it myself.
Just needed to disable the UART:
https://github.com/micropython/micropyt ... 303fec6ed3
import machine
import uos
uart = machine.UART(0, 115200)
uos.dupterm(uart, 0)
And RX works as normal input pin