How to make Rx TX of ESP8266 as normal GPIO?

amelia's picture

Offline

Joined: Sep 25, 2018

Replies: 2
How to make Rx TX of ESP8266 as normal GPIO?
July 4, 2019 - 5:54pm

hi, i want extra gpio's in my project. is it possible to make use of Rx Tx of the esp8266 into a normal gpio pins. This will add two extra pins if it can be done. 

Abhiemanyu Pandit's picture

Offline

Joined: Jan 21, 2019

Replies: 37
How to make Rx TX of ESP8266 as normal GPIO?
July 4, 2019 - 6:03pm

hie amelia,

you can do this by adding some lines of code in the begining of your code i.e. it can be addeed in the setup() function. Add these below lines in the beginning of setup() function.  

/////////////////change pin 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); 
///////////////////////

keep in mind that since you are changing the function of Rx Tx pin, this means that you cannot access serial monitor after this. also if you want to flash the esp8266 then it can be done in the flash mode of gpio which converts the gpio back in to rx and tx and when you boot the esp8266 in normal mode it will take rx tx as gpio. 

if you want to revert to normal rx tx function then replace  above lines wwith following one.

////////////////change pin to rx tx again//////////
//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); 
/////////////////////////
amelia's picture

Offline

Joined: Sep 25, 2018

Replies: 2
Thank you
July 4, 2019 - 6:03pm

thank you i will try and let you know

Abhiemanyu Pandit's picture

Offline

Joined: Jan 21, 2019

Replies: 37
How to make Rx TX of ESP8266 as normal GPIO?
July 4, 2019 - 6:04pm

do let me know about the success.