When programming an ESP-01 with Arduino IDE, how can I make the Tx and Rx into a generic I/O pins reliably? I think there's a command to swap the Tx and Tx with other pins. I tried serial.swap() but it didn't work. So how to get done with Arduino IDE or is it even possible?. I am using an ESP-01, which means there will be four GPIO pins once this question in answered.

I want to achieve same as in the video, How to add more GPIOs to ESP8266 (ESP-01), but without soldering wire.

Add this to your code at the beginning of set void setup():

//********** CHANGE PIN FUNCTION  TO GPIO **********
//GPIO 1 (TX) swap the pin to a GPIO.
pinMode(1, FUNCTION_3); 
//GPIO 3 (RX) swap the pin to a GPIO.
pinMode(3, FUNCTION_3); 
//**************************************************

You will no longer be able to use the Serial Monitor as TX will now be a GPIO pin and not transmit Serial data. You can still Flash your device as when you boot the device in flash mode it converts GPIO1 and GPIO3 back to TX/RX. Once you reboot into regular running mode GPIO1 and GPIO3 will go back to being GPIO pins.

To change GPIO1 and GPIO3 back to being TX/RX for regular Serial Monitor use add this to your code at the beginning of set void setup():

//********** CHANGE PIN FUNCTION  TO TX/RX **********
//GPIO 1 (TX) swap the pin to a TX.
pinMode(1, FUNCTION_0); 
//GPIO 3 (RX) swap the pin to a RX.
pinMode(3, FUNCTION_0); 
//***************************************************

If I understand the ESP-01 correctly the pins CANNOT be both TX/RX and GPIO pins at the same time.

Tx = GPIO 1

Rx = GPIO 3

Should work but be careful cause if they burn, you won't be able to program or even talk to the ESP anymore.

  • Im not sure I understood your answer- so with your arduino code in your answer will it swap the tx, rx pins with others that cant be accessed (except without soldering wire) so that the previously unaccessible pins , which you refer to as gpio 3 and gpio 1 can be used like the gpio 0 and gpio 2 as input or output pins – vzxc Oct 7 '16 at 2:09
  • I mean that if you want to use the Tx pin as a OUTPUT / INPUT, declare it and consider it as GPIO 1. Same applies for the Rx pin. – Dat Ha Oct 7 '16 at 2:11
  • So it will work like the video I referenced in the question?-except without soldering of course. and it would mean the serial pins tx and rx cant be used for serial communication-which is ok – vzxc Oct 7 '16 at 2:14
  • 1
    true, just remember to be CAREFUL to not short those 2 pins – Dat Ha Oct 7 '16 at 2:17

Maybe a little late but it might helps someone else.

ESP-01 GPIO pins (1&3)

  • 7
    Don't just link to an external page, especially when the answer is buried in it somewhere. (External pages change and disappear.) Instead, write an answer here that directly answers the question, using information from that page (and still linking to it with a mention that that's where you got the information). – Curt J. Sampson Apr 10 '17 at 13:23

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.